Skip to contentSkip to conversation

drivers/firewire/core-iso.c: Convert to use vm_insert_range

PATCH Superseded Souptick Joarder 2 participants 3 messages Dec 17, 2018 – Dec 19, 2018

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 3/9 drivers/firewire/core-iso.c: Convert to use vm_insert_range

Convert to use vm_insert_range to map range of kernel memory to user vma.

---
 drivers/firewire/core-iso.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/firewire/core-iso.c +2 -13
index 35e784c..7bf28bb 100644
@@ -107,19 +107,8 @@ int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card,
 int fw_iso_buffer_map_vma(struct fw_iso_buffer *buffer,
 			  struct vm_area_struct *vma)
 {
-	unsigned long uaddr;
-	int i, err;
-
-	uaddr = vma->vm_start;
-	for (i = 0; i < buffer->page_count; i++) {
-		err = vm_insert_page(vma, uaddr, buffer->pages[i]);
-		if (err)
-			return err;
-
-		uaddr += PAGE_SIZE;
-	}
-
-	return 0;
+	return vm_insert_range(vma, vma->vm_start, buffer->pages,
+				buffer->page_count);
 }
 
 void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer,
Signature · 1 line
1.9.1
#1 lore raw
Quoted 22 lines · Souptick Joarder

Convert to use vm_insert_range to map range of kernel memory to user vma.

---
 drivers/firewire/core-iso.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/firewire/core-iso.c +0 -5
index 35e784c..7bf28bb 100644
@@ -107,19 +107,8 @@ int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card,
 int fw_iso_buffer_map_vma(struct fw_iso_buffer *buffer,
 			  struct vm_area_struct *vma)
 {
-	unsigned long uaddr;
-	int i, err;
-
-	uaddr = vma->vm_start;
-	for (i = 0; i < buffer->page_count; i++) {

drivers/firewire/core-iso.c int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, · line 111

Quoted 10 lines
drivers/firewire/core-iso.c +2 -8
-		err = vm_insert_page(vma, uaddr, buffer->pages[i]);
-		if (err)
-			return err;
-
-		uaddr += PAGE_SIZE;
-	}
-
-	return 0;
+	return vm_insert_range(vma, vma->vm_start, buffer->pages,
+				buffer->page_count);

This looks functionally equivalent. Note that if we go with my proposal to your patch 4, that would cause an issue for this implementation.

Maybe we need two functions, but that then causes problems with which function should be used (which makes it easy to get wrong.)

I'm beginning to wonder if the risks of causing regressions and introducing bugs is actually worth the effort of trying to clean this up.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up
#2 lore raw
Quoted 39 lines · Russell King - ARM Linux
Quoted 22 lines · Souptick Joarder

Convert to use vm_insert_range to map range of kernel memory to user vma.

---
 drivers/firewire/core-iso.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/firewire/core-iso.c +0 -5
index 35e784c..7bf28bb 100644
@@ -107,19 +107,8 @@ int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card,
 int fw_iso_buffer_map_vma(struct fw_iso_buffer *buffer,
                        struct vm_area_struct *vma)
 {
-     unsigned long uaddr;
-     int i, err;
-
-     uaddr = vma->vm_start;
-     for (i = 0; i < buffer->page_count; i++) {

drivers/firewire/core-iso.c int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, · line 111

Quoted 10 lines
drivers/firewire/core-iso.c +2 -8
-             err = vm_insert_page(vma, uaddr, buffer->pages[i]);
-             if (err)
-                     return err;
-
-             uaddr += PAGE_SIZE;
-     }
-
-     return 0;
+     return vm_insert_range(vma, vma->vm_start, buffer->pages,
+                             buffer->page_count);

This looks functionally equivalent. Note that if we go with my proposal to your patch 4, that would cause an issue for this implementation.

Quoted 2 lines

Maybe we need two functions, but that then causes problems with which function should be used (which makes it easy to get wrong.)

I think, apart from patch [4/9] and [6/9], all others places can be directly replaced
with vm_insert_range(). [4/9] and [6/9] are the places where *vma->vm_pgoff* need to be
considered and need to adjust *count* accordingly. In my opinion, bugs around these
[4/9] & [6/9] can be fixed (raised during review) to accommodate it to use vm_insert_range().

Quoted 9 lines

I'm beginning to wonder if the risks of causing regressions and introducing bugs is actually worth the effort of trying to clean this up.

--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up