* [PATCH] drm/dp: Allow signals to interrupt drm_aux-dev reads/writes
@ 2016-04-27 19:43 ville.syrjala
2016-04-28 8:49 ` Jani Nikula
0 siblings, 1 reply; 3+ messages in thread
From: ville.syrjala @ 2016-04-27 19:43 UTC (permalink / raw)
To: dri-devel
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
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 <rafael.antognolli@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
drivers/gpu/drm/drm_dp_aux_dev.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/drm_dp_aux_dev.c b/drivers/gpu/drm/drm_dp_aux_dev.c
index f73b38b33a8e..3334baacf43d 100644
--- a/drivers/gpu/drm/drm_dp_aux_dev.c
+++ b/drivers/gpu/drm/drm_dp_aux_dev.c
@@ -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 ?
--
2.7.4
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] drm/dp: Allow signals to interrupt drm_aux-dev reads/writes
2016-04-27 19:43 [PATCH] drm/dp: Allow signals to interrupt drm_aux-dev reads/writes ville.syrjala
@ 2016-04-28 8:49 ` Jani Nikula
2016-04-28 9:48 ` Daniel Vetter
0 siblings, 1 reply; 3+ messages in thread
From: Jani Nikula @ 2016-04-28 8:49 UTC (permalink / raw)
To: ville.syrjala, dri-devel
On Wed, 27 Apr 2016, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> 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 <rafael.antognolli@intel.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/drm_dp_aux_dev.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_dp_aux_dev.c b/drivers/gpu/drm/drm_dp_aux_dev.c
> index f73b38b33a8e..3334baacf43d 100644
> --- a/drivers/gpu/drm/drm_dp_aux_dev.c
> +++ b/drivers/gpu/drm/drm_dp_aux_dev.c
> @@ -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 ?
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] drm/dp: Allow signals to interrupt drm_aux-dev reads/writes
2016-04-28 8:49 ` Jani Nikula
@ 2016-04-28 9:48 ` Daniel Vetter
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Vetter @ 2016-04-28 9:48 UTC (permalink / raw)
To: Jani Nikula; +Cc: dri-devel
On Thu, Apr 28, 2016 at 11:49:12AM +0300, Jani Nikula wrote:
> On Wed, 27 Apr 2016, ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > 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 <rafael.antognolli@intel.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Applied to drm-misc, thanks.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-04-28 9:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-27 19:43 [PATCH] drm/dp: Allow signals to interrupt drm_aux-dev reads/writes ville.syrjala
2016-04-28 8:49 ` Jani Nikula
2016-04-28 9:48 ` Daniel Vetter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.