xenomai.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: xenomai@lists.linux.dev
Cc: wg@denx.de, rpm@xenomai.org, Richard Weinberger <richard@nod.at>
Subject: [PATCH] cobalt/drvlib: Prefault io memory again
Date: Tue,  5 Dec 2023 21:22:10 +0100	[thread overview]
Message-ID: <20231205202210.25477-1-richard@nod.at> (raw)

This issue was fixed a long time ago by
03d5b0b0083c ("cobalt/rtdm: fix caching and page fault issues with rtdm_iomap_to_user()"),
later with commit c8e9e166b ("cobalt/rtdm: introduce mmap() support")
iomap code lost again the call to cobalt_machine.prefault().

I have no idea why this took so longer to come up again.
Last week, while upgrading an aarch32 setup from Xenomai 2 to Xenomai 3, the application
failed due to massive latencies caused by page faults after writing to io memory.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 kernel/cobalt/rtdm/drvlib.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c
index 30455c3d7..620be27fa 100644
--- a/kernel/cobalt/rtdm/drvlib.c
+++ b/kernel/cobalt/rtdm/drvlib.c
@@ -1761,6 +1761,7 @@ static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa)
 {
 	pgprot_t prot = PAGE_SHARED;
 	unsigned long len;
+	int ret;
 
 	len = vma->vm_end - vma->vm_start;
 #ifndef CONFIG_MMU
@@ -1774,8 +1775,17 @@ static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa)
 #endif
 	vma->vm_page_prot = pgprot_noncached(prot);
 
-	return remap_pfn_range(vma, vma->vm_start, pa >> PAGE_SHIFT,
-			       len, vma->vm_page_prot);
+	ret = remap_pfn_range(vma, vma->vm_start, pa >> PAGE_SHIFT,
+			      len, vma->vm_page_prot);
+	if (ret)
+		return ret;
+
+#ifdef CONFIG_MMU
+	if (cobalt_machine.prefault)
+		cobalt_machine.prefault(vma);
+#endif
+
+	return 0;
 }
 
 static int mmap_buffer_helper(struct rtdm_fd *fd, struct vm_area_struct *vma)
-- 
2.35.3


             reply	other threads:[~2023-12-05 20:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-05 20:22 Richard Weinberger [this message]
2023-12-07  9:12 ` [PATCH] cobalt/drvlib: Prefault io memory again Jan Kiszka
2024-01-16  8:22   ` Richard Weinberger
2024-01-22 13:14     ` Philippe Gerum
2024-02-14 14:27 ` Jan Kiszka

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=20231205202210.25477-1-richard@nod.at \
    --to=richard@nod.at \
    --cc=rpm@xenomai.org \
    --cc=wg@denx.de \
    --cc=xenomai@lists.linux.dev \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).