Skip to content

Commit e9972cc

Browse files
committed
dma: Drop syscalls
DMA syscalls as they were implemented were unsafe. Accepting a void* was never acceptable as many things could not be verified about it. Accepting a channel identifier meant that a user mode thread could start/stop any DMA channel which in theory could be owned by any other driver. This shouldn't be possible. Signed-off-by: Tom Burdick <[email protected]>
1 parent 16f4d6c commit e9972cc

File tree

3 files changed

+7
-56
lines changed

3 files changed

+7
-56
lines changed

drivers/dma/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ zephyr_library_sources_ifdef(CONFIG_DMAMUX_STM32 dmamux_stm32.c)
1313
zephyr_library_sources_ifdef(CONFIG_DMA_DW dma_dw.c dma_dw_common.c)
1414
zephyr_library_sources_ifdef(CONFIG_DMA_NIOS2_MSGDMA dma_nios2_msgdma.c)
1515
zephyr_library_sources_ifdef(CONFIG_DMA_SAM0 dma_sam0.c)
16-
zephyr_library_sources_ifdef(CONFIG_USERSPACE dma_handlers.c)
1716
zephyr_library_sources_ifdef(CONFIG_DMA_MCUX_EDMA dma_mcux_edma.c)
1817
zephyr_library_sources_ifdef(CONFIG_DMA_MCUX_EDMA_V3 dma_mcux_edma.c)
1918
zephyr_library_sources_ifdef(CONFIG_DMA_MCUX_EDMA_V4 dma_mcux_edma.c)

drivers/dma/dma_handlers.c

Lines changed: 0 additions & 26 deletions
This file was deleted.

include/zephyr/drivers/dma.h

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,7 @@ static inline int dma_reload(const struct device *dev, uint32_t channel,
451451
* @retval 0 if successful.
452452
* @retval Negative errno code if failure.
453453
*/
454-
__syscall int dma_start(const struct device *dev, uint32_t channel);
455-
456-
static inline int z_impl_dma_start(const struct device *dev, uint32_t channel)
454+
static inline int dma_start(const struct device *dev, uint32_t channel)
457455
{
458456
const struct dma_driver_api *api =
459457
(const struct dma_driver_api *)dev->api;
@@ -479,9 +477,7 @@ static inline int z_impl_dma_start(const struct device *dev, uint32_t channel)
479477
* @retval 0 if successful.
480478
* @retval Negative errno code if failure.
481479
*/
482-
__syscall int dma_stop(const struct device *dev, uint32_t channel);
483-
484-
static inline int z_impl_dma_stop(const struct device *dev, uint32_t channel)
480+
static inline int dma_stop(const struct device *dev, uint32_t channel)
485481
{
486482
const struct dma_driver_api *api =
487483
(const struct dma_driver_api *)dev->api;
@@ -506,9 +502,7 @@ static inline int z_impl_dma_stop(const struct device *dev, uint32_t channel)
506502
* @retval -EINVAL If invalid channel id or state.
507503
* @retval -errno Other negative errno code failure.
508504
*/
509-
__syscall int dma_suspend(const struct device *dev, uint32_t channel);
510-
511-
static inline int z_impl_dma_suspend(const struct device *dev, uint32_t channel)
505+
static inline int dma_suspend(const struct device *dev, uint32_t channel)
512506
{
513507
const struct dma_driver_api *api = (const struct dma_driver_api *)dev->api;
514508

@@ -534,9 +528,7 @@ static inline int z_impl_dma_suspend(const struct device *dev, uint32_t channel)
534528
* @retval -EINVAL If invalid channel id or state.
535529
* @retval -errno Other negative errno code failure.
536530
*/
537-
__syscall int dma_resume(const struct device *dev, uint32_t channel);
538-
539-
static inline int z_impl_dma_resume(const struct device *dev, uint32_t channel)
531+
static inline int dma_resume(const struct device *dev, uint32_t channel)
540532
{
541533
const struct dma_driver_api *api = (const struct dma_driver_api *)dev->api;
542534

@@ -562,11 +554,7 @@ static inline int z_impl_dma_resume(const struct device *dev, uint32_t channel)
562554
* @retval dma channel if successful.
563555
* @retval Negative errno code if failure.
564556
*/
565-
__syscall int dma_request_channel(const struct device *dev,
566-
void *filter_param);
567-
568-
static inline int z_impl_dma_request_channel(const struct device *dev,
569-
void *filter_param)
557+
static inline int dma_request_channel(const struct device *dev, void *filter_param)
570558
{
571559
int i = 0;
572560
int channel = -EINVAL;
@@ -607,11 +595,7 @@ static inline int z_impl_dma_request_channel(const struct device *dev,
607595
* @param channel channel number
608596
*
609597
*/
610-
__syscall void dma_release_channel(const struct device *dev,
611-
uint32_t channel);
612-
613-
static inline void z_impl_dma_release_channel(const struct device *dev,
614-
uint32_t channel)
598+
static inline void dma_release_channel(const struct device *dev, uint32_t channel)
615599
{
616600
const struct dma_driver_api *api =
617601
(const struct dma_driver_api *)dev->api;
@@ -643,11 +627,7 @@ static inline void z_impl_dma_release_channel(const struct device *dev,
643627
* @retval Negative errno code if not support
644628
*
645629
*/
646-
__syscall int dma_chan_filter(const struct device *dev,
647-
int channel, void *filter_param);
648-
649-
static inline int z_impl_dma_chan_filter(const struct device *dev,
650-
int channel, void *filter_param)
630+
static inline int dma_chan_filter(const struct device *dev, int channel, void *filter_param)
651631
{
652632
const struct dma_driver_api *api =
653633
(const struct dma_driver_api *)dev->api;
@@ -812,6 +792,4 @@ static inline uint32_t dma_burst_index(uint32_t burst)
812792
}
813793
#endif
814794

815-
#include <zephyr/syscalls/dma.h>
816-
817795
#endif /* ZEPHYR_INCLUDE_DRIVERS_DMA_H_ */

0 commit comments

Comments
 (0)