aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/soc/apple/rtkit.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2025-02-28soc: apple: rtkit: Cut syslog messages after the first '\0'Janne Grunau1-1/+1
Certain messages from DCP contain NUL bytes in the random data after the NUL terminated syslog message. Since the syslog message ends with '\n' this results in a dev_info() message terminated with two newlines and an empty printed line in the kernel log. Signed-off-by: Janne Grunau <j@jannau.net> Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Link: https://lore.kernel.org/r/20250226-apple-soc-misc-v2-4-c3ec37f9021b@svenpeter.dev Signed-off-by: Sven Peter <sven@svenpeter.dev>
2025-02-28soc: apple: rtkit: Use high prio work queueJanne Grunau1-1/+1
rtkit messages as communication with the DCP firmware for framebuffer swaps or input events are time critical so use WQ_HIGHPRI to prevent user space CPU load to increase latency. With kwin_wayland 6's explicit sync mode user space load was able to delay the IOMFB rtkit communication enough to miss vsync for surface swaps. Minimal test scenario is constantly resizing a glxgears Xwayland window. Signed-off-by: Janne Grunau <j@jannau.net> Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Link: https://lore.kernel.org/r/20250226-apple-soc-misc-v2-3-c3ec37f9021b@svenpeter.dev Signed-off-by: Sven Peter <sven@svenpeter.dev>
2025-02-28soc: apple: rtkit: Implement OSLog buffers properlyHector Martin1-22/+34
Apparently nobody can figure out where the old logic came from, but it seems like it has never been actually used on any supported firmware to this day. OSLog buffers were apparently never requested. But starting with 13.3, we actually need this implemented properly for MTP (and later AOP) to work, so let's actually do that. Signed-off-by: Hector Martin <marcan@marcan.st> Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Link: https://lore.kernel.org/r/20250226-apple-soc-misc-v2-2-c3ec37f9021b@svenpeter.dev Signed-off-by: Sven Peter <sven@svenpeter.dev>
2025-02-28soc: apple: rtkit: Add and use PWR_STATE_INIT instead of _ONJanne Grunau1-1/+2
This state is needed to wake the dcp IOP after m1n1 shut it down and works for all other co-processors as well. Signed-off-by: Janne Grunau <j@jannau.net> Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Link: https://lore.kernel.org/r/20250226-apple-soc-misc-v2-1-c3ec37f9021b@svenpeter.dev Signed-off-by: Sven Peter <sven@svenpeter.dev>
2025-02-18soc: apple: rtkit: Fix use-after-free in apple_rtkit_crashlog_rx()Harshit Mogalapalli1-1/+2
This code calls kfree(bfr); and then passes "bfr" to rtk->ops->crashed() which is a use after free. The ->crashed function pointer is implemented by apple_nvme_rtkit_crashed() and it doesn't use the "bfr" pointer so this doesn't cause a problem. But it still looks sketchy as can be. Fix this by moving kfree() after the last usage of bfr. Fixes: bf8b4e49777d ("soc: apple: rtkit: Pass the crashlog to the crashed() callback") Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> Reviewed-by: Eric Curtin <ecurtin@redhat.com> Link: https://lore.kernel.org/r/20250212085853.1357906-1-harshit.m.mogalapalli@oracle.com Signed-off-by: Sven Peter <sven@svenpeter.dev>
2025-02-18soc: apple: rtkit: Pass the crashlog to the crashed() callbackAsahi Lina1-1/+1
Client drivers might want a copy of the crashlog to stash into a devcoredump blob. Since device memory management can be very variable, the actual devcoredump implementation is left to client drivers. Pass the raw crashlog buffer to the client callback so it can use it if desired. Signed-off-by: Asahi Lina <lina@asahilina.net> Reviewed-by: Jens Axboe <axboe@kernel.dk> Link: https://lore.kernel.org/r/20250202-rtkit-crashdump-v1-1-9d38615b4e12@asahilina.net Signed-off-by: Sven Peter <sven@svenpeter.dev>
2025-02-18soc: apple: rtkit: Check & log more failuresAsahi Lina1-10/+34
Check and log the following failures: * regular messages * management messages * failed buffer requests This helps debugging. Signed-off-by: Asahi Lina <lina@asahilina.net> Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Neal Gompa <neal@gompa.dev> Link: https://lore.kernel.org/r/20250211-rtkit-more-logging-v1-1-93334e9c1c77@rosenzweig.io Signed-off-by: Sven Peter <sven@svenpeter.dev>
2023-11-23soc: apple: rtkit: Port to the internal mailbox driverHector Martin1-73/+28
Now that we have a mailbox driver in drivers/soc/apple, port the RTKit code to it. This mostly just entails replacing calls through the mailbox subsystem with direct calls into the driver. Acked-by: Eric Curtin <ecurtin@redhat.com> Acked-by: Neal Gompa <neal@gompa.dev> Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-23soc: apple: rtkit: Get rid of apple_rtkit_send_message_waitHector Martin1-32/+0
It is fundamentally broken and has no users. Just remove it. Acked-by: Eric Curtin <ecurtin@redhat.com> Acked-by: Neal Gompa <neal@gompa.dev> Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Signed-off-by: Hector Martin <marcan@marcan.st>
2023-03-28soc: apple: rtkit: Crop syslog messagesMartin Povišer1-1/+13
Crop trailing whitespace, null, and newline characters in syslog messages received from coprocessors. Notably DCP sends its messages including a trailing newline, so prior to this change we would end up cluttering the kernel log by repeated newlines at the end of messages. Signed-off-by: Martin Povišer <povik+lin@cutebit.org> Reviewed-by: Hector Martin <marcan@marcan.st> Signed-off-by: Hector Martin <marcan@marcan.st>
2023-03-28soc: apple: rtkit: Fix buffer address field widthAsahi Lina1-1/+1
The buffer address field is missing two bits. This matters for the GPU, which uses upper-half 64-bit addresses on the ASC and those get sign extended from the mailbox message field, so the right number of high bits need to be set. Signed-off-by: Asahi Lina <lina@asahilina.net> Reviewed-by: Sven Peter <sven@svenpeter.dev> Signed-off-by: Hector Martin <marcan@marcan.st>
2023-01-31soc: apple: rtkit: Export non-devm init/free functionsAsahi Lina1-5/+10
While we normally encourage devm usage by drivers, some consumers (and in particular the upcoming Rust abstractions) might want to manually manage memory. Export the raw functions to make this possible. Signed-off-by: Asahi Lina <lina@asahilina.net> Reviewed-by: Sven Peter <sven@svenpeter.dev> Reviewed-by: Eric Curtin <ecurtin@redhat.com> Signed-off-by: Hector Martin <marcan@marcan.st>
2023-01-31soc: apple: rtkit: Add apple_rtkit_idle() functionHector Martin1-0/+21
This is yet another low power mode, used by DCP. Reviewed-by: Eric Curtin <ecurtin@redhat.com> Reviewed-by: Sven Peter <sven@svenpeter.dev> Signed-off-by: Hector Martin <marcan@marcan.st>
2022-11-28soc: apple: rtkit: Stop casting function pointer signaturesSven Peter1-3/+4
Fixes: 9bd1d9a0d8bb ("soc: apple: Add RTKit IPC library") Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Sven Peter <sven@svenpeter.dev> Signed-off-by: Hector Martin <marcan@marcan.st>
2022-09-17soc: apple: rtkit: Add apple_rtkit_pollHector Martin1-0/+6
This allows a client to receive messages in atomic context, by polling. Signed-off-by: Hector Martin <marcan@marcan.st> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Reviewed-by: Sven Peter <sven@svenpeter.dev> Reviewed-by: Eric Curtin <ecurtin@redhat.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-05-01soc: apple: Add RTKit IPC librarySven Peter1-0/+958
Apple SoCs such as the M1 come with multiple embedded co-processors running proprietary firmware. Communication with those is established over a simple mailbox using the RTKit IPC protocol. This cannot be implemented inside the mailbox subsystem since on top of communication over channels we also need support for starting, hibernating and resetting these co-processors. We also need to handle shared memory allocations differently depending on the co-processor and don't want to split that across multiple drivers. Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Sven Peter <sven@svenpeter.dev>