From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [PATCH] xf86drm.c: add counter for ioctl restarting Date: Fri, 13 Apr 2012 15:42:16 +0200 Message-ID: <20120413134216.GG4525@phenom.ffwll.local> References: <20120413172642.4c423352@boyarsh.office.altlinux.ru> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-we0-f177.google.com (mail-we0-f177.google.com [74.125.82.177]) by gabe.freedesktop.org (Postfix) with ESMTP id A0F81A0BF1 for ; Fri, 13 Apr 2012 06:41:23 -0700 (PDT) Received: by werp11 with SMTP id p11so2355529wer.36 for ; Fri, 13 Apr 2012 06:41:22 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20120413172642.4c423352@boyarsh.office.altlinux.ru> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: "Anton V. Boyarshinov" Cc: DRI mailing list List-Id: dri-devel@lists.freedesktop.org On Fri, Apr 13, 2012 at 05:26:42PM +0400, Anton V. Boyarshinov wrote: > In some cases ioclt->alarm->ioctl loop can be infinite: > ioctl(7, 0x40086482, 0xbfb62738) = ? ERESTARTSYS (To be restarted) > --- SIGALRM (Alarm clock) @ 0 (0) --- > sigreturn() = ? (mask now []) > ioctl(7, 0x40086482, 0xbfb62738) = ? ERESTARTSYS (To be restarted) > and forever. > > It seems, that limiting ioctl restarting by some resonable number of trys > is a dirty but working way to prevent Xorg lockups. > > Signed-off-by: Anton V. Boyarshinov > --- > xf86drm.c | 3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) > > diff --git a/xf86drm.c b/xf86drm.c > index 6ea068f..9663f21 100644 > --- a/xf86drm.c > +++ b/xf86drm.c > @@ -162,10 +162,11 @@ int > drmIoctl(int fd, unsigned long request, void *arg) > { > int ret; > + int count=0; > > do { > ret = ioctl(fd, request, arg); > - } while (ret == -1 && (errno == EINTR || errno == EAGAIN)); > + } while (ret == -1 && (errno == EINTR || errno == EAGAIN) && ++count < 100 ); We rely on restarting after signals when blocking for the gpu, busy gpu plus mouse wiggling can easily reach that. NACKed-by: Daniel Vetter Obviously if we have a dead gpu, we need to break out of this loop. But detecting a dead gpu (and returning an appropriate error like EIO) is the kernel's job. Cheers, Daniel > return ret; > } > > -- > 1.7.5.4 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Mail: daniel@ffwll.ch Mobile: +41 (0)79 365 57 48