[PATCH 4/4] sample/reserved_mem: Introduce a sample of struct page and dio support to no-map rmem
Arnd Bergmann
arnd at arndb.de
Tue Jul 12 00:50:46 PDT 2022
On Tue, Jul 12, 2022 at 2:26 AM Li Chen <me at linux.beauty> wrote:
> ---- On Mon, 11 Jul 2022 21:28:10 +0800 Arnd Bergmann <arnd at arndb.de> wrote ---
> > On Mon, Jul 11, 2022 at 2:24 PM Li Chen <me at linux.beauty> wrote:
> > >
> > > From: Li Chen <lchen at ambarella.com>
> > >
> > > This sample driver shows how to build struct pages support to no-map rmem.
> > >
> > > Signed-off-by: Li Chen <lchen at ambarella.com>
> >
> > 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.
>
> Totally agree, but we plan to start rewriting our video driver in a long time, it
> has many legacy codes and I need to rewrite a lot of codes to migrate to v4l2.
> That's why I also submit a sample driver here: to make the review progress
> easier and don't need reviewers to read video driver codes.
The problem is that this patch may not be the right solution for your new
driver either. As Christoph also commented, what you do here is rather
unusual, and without seeing the video driver first, we have no way of
knowing whether there is something the driver should be doing
differently to solve the original problem.
> > > +/*
> > > + * dts example
> > > + * rmem: rmem at 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.
>
> Gotcha, but IMO dts + rmem is the only choice for our use case. In our real
> case, we use reg instead of size to specify the physical address, so
> memremap cannot be used.
Does your hardware require a fixed address for the buffer? If it can be
anywhere in memory (or at least within a certain range) but just has to
be physically contiguous, the normal way would be to use a CMA area
to allocate from, which gives you 'struct page' backed pages.
Arnd
More information about the linux-arm-kernel
mailing list