[PATCH 4/9] soc: apple: Add SART driver

Arnd Bergmann arnd at arndb.de
Mon Mar 21 10:07:39 PDT 2022


On Mon, Mar 21, 2022 at 5:50 PM Sven Peter <sven at svenpeter.dev> wrote:
>
> The NVMe co-processor on the Apple M1 uses a DMA address filter called
> SART for some DMA transactions. This adds a simple driver used to
> configure the memory regions from which DMA transactions are allowed.
>
> Co-developed-by: Hector Martin <marcan at marcan.st>
> Signed-off-by: Hector Martin <marcan at marcan.st>
> Signed-off-by: Sven Peter <sven at svenpeter.dev>

Can you add some explanation about why this uses a custom interface
instead of hooking into the dma_map_ops?

> +static void sart2_get_entry(struct apple_sart *sart, int index, u8 *flags,
> +                           phys_addr_t *paddr, size_t *size)
> +{
> +       u32 cfg = readl_relaxed(sart->regs + APPLE_SART2_CONFIG(index));
> +       u32 paddr_ = readl_relaxed(sart->regs + APPLE_SART2_PADDR(index));

Why do you use the _relaxed() accessors here and elsewhere in the driver?

> +struct apple_sart *apple_sart_get(struct device *dev)
> +{
> +       struct device_node *sart_node;
> +       struct platform_device *sart_pdev;
> +       struct apple_sart *sart;
> +
> +       sart_node = of_parse_phandle(dev->of_node, "apple,sart", 0);
> +       if (!sart_node)
> +               return ERR_PTR(ENODEV);

The error pointers need to take negative values, like 'ERR_PTR(-ENODEV)',
here and everywhere else in the driver.

       Arnd



More information about the linux-arm-kernel mailing list