Skip to contentSkip to conversation

drm/dp: Allow signals to interrupt drm_aux-dev reads/writes

PATCH Applied [email protected] 3 participants 3 messages Apr 27, 2016 – Apr 28, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/dp: Allow signals to interrupt drm_aux-dev reads/writes

From: Ville Syrjälä <[email protected]>

Let's be nice and interrupt the dpcd aux-dev reads/writes when there's a signal pending. Much nicer if the user can hit ^C instead of having to sit around waiting for the read/write to finish.

time dd if=/dev/drm_dp_aux0 bs=$((1024*1024))
^C

before:
real 0m34.681s
user 0m0.003s
sys 0m6.880s

after:
real 0m0.222s
user 0m0.006s
sys 0m0.057s

Cc Rafael Antognolli <[email protected]>
---
 drivers/gpu/drm/drm_dp_aux_dev.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/gpu/drm/drm_dp_aux_dev.c +12 -0
index f73b38b33a8e..3334baacf43d 100644
@@ -159,6 +159,12 @@ static ssize_t auxdev_read(struct file *file, char __user *buf, size_t count,
 		uint8_t localbuf[DP_AUX_MAX_PAYLOAD_BYTES];
 		ssize_t todo = min_t(size_t, bytes_pending, sizeof(localbuf));
 
+		if (signal_pending(current)) {
+			res = num_bytes_processed ?
+				num_bytes_processed : -ERESTARTSYS;
+			goto out;
+		}
+
 		res = drm_dp_dpcd_read(aux_dev->aux, *offset, localbuf, todo);
 		if (res <= 0) {
 			res = num_bytes_processed ? num_bytes_processed : res;
@@ -202,6 +208,12 @@ static ssize_t auxdev_write(struct file *file, const char __user *buf,
 		uint8_t localbuf[DP_AUX_MAX_PAYLOAD_BYTES];
 		ssize_t todo = min_t(size_t, bytes_pending, sizeof(localbuf));
 
+		if (signal_pending(current)) {
+			res = num_bytes_processed ?
+				num_bytes_processed : -ERESTARTSYS;
+			goto out;
+		}
+
 		if (__copy_from_user(localbuf,
 				     buf + num_bytes_processed, todo)) {
 			res = num_bytes_processed ?
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · On Wed, 27 Apr 2016, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Let's be nice and interrupt the dpcd aux-dev reads/writes when there's a signal pending. Much nicer if the user can hit ^C instead of having to sit around waiting for the read/write to finish.

time dd if=/dev/drm_dp_aux0 bs=$((1024*1024))
^C

before:
real 0m34.681s
user 0m0.003s
sys 0m6.880s

Quoted 7 lines

after:
real 0m0.222s
user 0m0.006s
sys 0m0.057s

Cc Rafael Antognolli <[email protected]>
Quoted 34 lines
---
 drivers/gpu/drm/drm_dp_aux_dev.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/gpu/drm/drm_dp_aux_dev.c +12 -0
index f73b38b33a8e..3334baacf43d 100644
@@ -159,6 +159,12 @@ static ssize_t auxdev_read(struct file *file, char __user *buf, size_t count,
 		uint8_t localbuf[DP_AUX_MAX_PAYLOAD_BYTES];
 		ssize_t todo = min_t(size_t, bytes_pending, sizeof(localbuf));
 
+		if (signal_pending(current)) {
+			res = num_bytes_processed ?
+				num_bytes_processed : -ERESTARTSYS;
+			goto out;
+		}
+
 		res = drm_dp_dpcd_read(aux_dev->aux, *offset, localbuf, todo);
 		if (res <= 0) {
 			res = num_bytes_processed ? num_bytes_processed : res;
@@ -202,6 +208,12 @@ static ssize_t auxdev_write(struct file *file, const char __user *buf,
 		uint8_t localbuf[DP_AUX_MAX_PAYLOAD_BYTES];
 		ssize_t todo = min_t(size_t, bytes_pending, sizeof(localbuf));
 
+		if (signal_pending(current)) {
+			res = num_bytes_processed ?
+				num_bytes_processed : -ERESTARTSYS;
+			goto out;
+		}
+
 		if (__copy_from_user(localbuf,
 				     buf + num_bytes_processed, todo)) {
 			res = num_bytes_processed ?
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
Quoted 20 lines · Jani Nikula
Quoted 19 lines · On Wed, 27 Apr 2016, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Let's be nice and interrupt the dpcd aux-dev reads/writes when there's a signal pending. Much nicer if the user can hit ^C instead of having to sit around waiting for the read/write to finish.

time dd if=/dev/drm_dp_aux0 bs=$((1024*1024))
^C

before:
real 0m34.681s
user 0m0.003s
sys 0m6.880s

after:
real 0m0.222s
user 0m0.006s
sys 0m0.057s

Quoted 4 lines
Quoted 2 lines
Cc Rafael Antognolli <[email protected]>

Applied to drm-misc, thanks.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel