Re: [PATCH 4/4] sample/reserved_mem: Introduce a sample of struct page and dio support to no-map rmem

From: Arnd Bergmann
Date: Mon Jul 11 2022 - 09:28:37 EST


On Mon, Jul 11, 2022 at 2:24 PM Li Chen <me@linux.beauty> wrote:
>
> From: Li Chen <lchen@xxxxxxxxxxxxx>
>
> This sample driver shows how to build struct pages support to no-map rmem.
>
> Signed-off-by: Li Chen <lchen@xxxxxxxxxxxxx>

Not sure what a sample driver helps here if there are no actual users in-tree.

It would make more sense to merge the driver that wants to actually use this
first, and then add the additional feature.

> Change-Id: Ie78494fa86fda40ceb73eab3b8ba505d0ad851a1

Please drop these lines, the Change-Id fields are useless in a public
repository.

> +/*
> + * dts example
> + * rmem: rmem@1 {
> + * compatible = "shared-dma-pool";
> + * no-map;
> + * size = <0x0 0x20000000>;
> + * };
> + * perf {
> + * compatible = "example,rmem";
> + * memory-region = <&rmem>;
> + * };

The problem here is that the DT is meant to describe the platform in an OS
independent way, so having a binding that just corresponds to a user space
interface is not a good abstraction.

> + vaddr = reserved_mem_memremap_pages(dev, rmem);
> + if (IS_ERR_OR_NULL(vaddr))
> + return PTR_ERR(vaddr);

Using IS_ERR_OR_NULL() is usually an indication of a bad interface.

For the reserved_mem_memremap_pages(), you should decide whether to return
NULL on error or an error pointer, but not both.

Arnd