From: Li Chen <me@linux.beauty>
To: "Arnd Bergmann" <arnd@arndb.de>
Cc: "Catalin Marinas" <catalin.marinas@arm.com>,
"Will Deacon" <will@kernel.org>,
"Rob Herring" <robh+dt@kernel.org>,
"Frank Rowand" <frowand.list@gmail.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Li Chen" <lchen@ambarella.com>,
"Linux ARM" <linux-arm-kernel@lists.infradead.org>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"DTML" <devicetree@vger.kernel.org>,
"Linux-MM" <linux-mm@kvack.org>
Subject: Re: [PATCH 1/4] of: add struct page support to rmem
Date: Mon, 11 Jul 2022 22:51:04 +0800 [thread overview]
Message-ID: <181edbe0f3d.e1336ef3387914.4730240512950880256@linux.beauty> (raw)
In-Reply-To: <CAK8P3a1WbJSWHsfegTtLhzSRwAoN8WfdezTTedRk9-FCiM8+GA@mail.gmail.com>
Hi Arnd,
Thanks for your review!
---- On Mon, 11 Jul 2022 21:36:12 +0800 Arnd Bergmann <arnd@arndb.de> wrote ---
> On Mon, Jul 11, 2022 at 2:24 PM Li Chen <me@linux.beauty> wrote:
>
> > +config OF_RESERVED_MEM_DIO_SUPPORT
> > + bool "add Direct I/O support to reserved_mem"
> > + depends on ZONE_DEVICE && ARCH_KEEP_MEMBLOCK
> > + help
> > + By default, reserved memory don't get struct page support, which
> > + means you cannot do Direct I/O from this region. This config takes
> > + uses of ZONE_DEVICE and treats rmem as hotplug mem to get struct
> > + page and DIO support.
>
> This probably does not need to be user visible, it's enough to select it from
> the drivers that need it.
When you say "user visible", do you mean the config can be dropped or something else like Kconfig type other than bool?
>
> > @@ -72,7 +72,6 @@ void __init fdt_reserved_mem_save_node(unsigned long node, const char *uname,
> > rmem->size = size;
> >
> > reserved_mem_count++;
> > - return;
> > }
>
> This change is not wrong, but it does not belong into the same patch
> as the rest, just drop it.
>
> > +/**
> > + * get_reserved_mem_from_dev() - get reserved_mem from a device node
> > + * @dev: device pointer
> > + *
> > + * This function look for reserved_mem from given device.
> > + *
> > + * Returns a reserved_mem pointer, or NULL on error.
> > + */
> > +struct reserved_mem *get_reserved_mem_from_dev(struct device *dev)
> > +{
> > + struct device_node *np = dev_of_node(dev);
> > + struct device_node *rmem_np;
> > + struct reserved_mem *rmem = NULL;
> > +
> > + rmem_np = of_parse_phandle(np, "memory-region", 0);
> > + if (!rmem_np) {
> > + dev_err(dev, "failed to get memory region node\n");
> > + return ERR_PTR(-ENODEV);
> > + }
> > +
> > + rmem = of_reserved_mem_lookup(rmem_np);
> > + if (!rmem) {
> > + dev_err(dev, "Failed to lookup reserved memory\n");
> > + return ERR_PTR(EINVAL);
>
> This needs to be a negative error code rather than the positive EINVAL.
> No need to initialize rmem=NULL first if you override it here.
>
> > + if (likely(reserved_mem_dio_in_region(pfn << PAGE_SHIFT, PAGE_SIZE, rmem) <
> > + 0))
> > + goto out;
>
> It's not performance critical, so just drop the 'likely()' and put the
> rest into one line.
>
>
> > + if (page) {
> > + *page = pfn_to_page(pfn);
> > + get_page(*page);
> > + }
> > +
> > + ret = 0;
> > +
> > +out:
> > + pte_unmap(pte);
> > + return ret;
> > +}
>
> Should you perhaps return an error when 'page' is NULL?
>
> > +#ifdef CONFIG_OF_RESERVED_MEM_DIO_SUPPORT
> > +int reserved_mem_dio_mmap(struct file *file, struct vm_area_struct *vma, struct reserved_mem *rmem);
> > +void *reserved_mem_memremap_pages(struct device *dev, struct reserved_mem *rmem);
> > +#endif
>
> The '#ifdef' check can be dropped here, declarations are normally
> not hidden like this.
>
> Arnd
>
These will be fixed in v2.
Regards,
Li
next prev parent reply other threads:[~2022-07-11 14:51 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-11 12:24 [PATCH 0/4] add struct page and Direct I/O support to reserved memory Li Chen
2022-07-11 12:24 ` [PATCH 1/4] of: add struct page support to rmem Li Chen
2022-07-11 13:36 ` Arnd Bergmann
2022-07-11 14:51 ` Li Chen [this message]
2022-07-11 15:06 ` Arnd Bergmann
2022-07-12 3:13 ` Li Chen
2022-07-16 0:38 ` kernel test robot
2022-07-18 13:21 ` Dan Carpenter
2022-07-11 12:24 ` [PATCH 2/4] mm/sparse: skip no-map memblock check when fill_subsection_map Li Chen
2022-07-11 14:53 ` David Hildenbrand
2022-07-12 4:23 ` Li Chen
2022-07-12 7:31 ` David Hildenbrand
2022-07-12 9:31 ` Li Chen
2022-07-14 18:45 ` kernel test robot
2022-07-11 12:24 ` [PATCH 3/4] arm64: mm: move memblock_clear_nomap after __add_pages Li Chen
2022-07-11 12:24 ` [PATCH 4/4] sample/reserved_mem: Introduce a sample of struct page and dio support to no-map rmem Li Chen
2022-07-11 13:28 ` Arnd Bergmann
2022-07-12 0:26 ` Li Chen
2022-07-12 7:50 ` Arnd Bergmann
2022-07-12 9:58 ` Li Chen
2022-07-12 10:08 ` Arnd Bergmann
2022-07-12 10:20 ` Arnd Bergmann
2022-07-12 10:55 ` Li Chen
2022-07-12 12:10 ` Arnd Bergmann
2022-08-04 7:17 ` Li Chen
2022-08-04 8:24 ` Arnd Bergmann
2022-08-04 10:07 ` Li Chen
2022-08-05 14:09 ` Arnd Bergmann
2022-08-05 15:28 ` David Hildenbrand
2022-07-11 15:01 ` [PATCH 0/4] add struct page and Direct I/O support to reserved memory Christoph Hellwig
2022-07-11 16:05 ` Li Chen
2022-07-11 16:09 ` Christoph Hellwig
2022-07-12 0:14 ` Li Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=181edbe0f3d.e1336ef3387914.4730240512950880256@linux.beauty \
--to=me@linux.beauty \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=catalin.marinas@arm.com \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=lchen@ambarella.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=robh+dt@kernel.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).