Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2354654imm; Mon, 28 May 2018 06:36:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr9zwJuJlHVUhUaPO+UsVMuDmSVNZN/v138hMXIyR9/Ff714JFkzDYxxiP7Dgz00HP1mTQu X-Received: by 2002:a17:902:a5c7:: with SMTP id t7-v6mr13823084plq.360.1527514600765; Mon, 28 May 2018 06:36:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527514600; cv=none; d=google.com; s=arc-20160816; b=Xm1EtGbrAKYfXtFNX0497AxiwuCB0nHtSEMF4s3NZ+Djjufdd6lEBk+mdb39FNLwDx KPiupjZt0tg5wm2wBYK9Y4yGGfYTz9814w1THBAlntFJxhliMhIgJh3J+hD+XbkyrDSD 6fmMDikZgmvL3LoBTIzaNhOC4mel8Z98vxKriOPmed2E4zUdY3Vd6PikSogCTRgnoK5R iKxWsz+MX3LPirpm2bX969ck1VUY7998SH87Ny3A6RWVzUEQtrk6bkW+7eiX9iIswuKC ZVxaEOlrP/0rX9GcDeiwp8rjlcb/XBm2a4B7pdm0ZufNCOHIBtdy2QFd75x8ObUpIGcE GoJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=TyWCGOvv0ah/7KZKA9UeekFL3QmOThXxDLXp80lxmUM=; b=R4x3Yo6uL79+tpvG472h9fOuCNM1hiG0RKD8kS2PLGSwqL2NYehyysNMKtUrGAhvpY wyB6tRyksG8nOPSp3cLZfiFLsSbdNPujwI8X2k2TCmKXsSqWCNt+d0jJkOMlcU+JQqLa 4VZjgNCEgKktL+50+/GxVIYyyyYLQXE5HORIFbHMgQbNKTZywY4fztnBlHzVoQx47U5c rNnlnd4YTKJrnG1fdlM66w79SRHf6QWZkbYTK0kKyDr+cZcQQRa5qUx9Q0nFLe0PduSH QmsN3oIHAWNJStKGuq+yk3r93UUFrLtJKwCl2CoSy9fMYtVr+eX6NIulanlzGZP86V1Z eg7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dChcuoH7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n4-v6si30282419pfk.277.2018.05.28.06.36.25; Mon, 28 May 2018 06:36:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dChcuoH7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937539AbeE1Kpk (ORCPT + 99 others); Mon, 28 May 2018 06:45:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:36066 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161134AbeE1Kph (ORCPT ); Mon, 28 May 2018 06:45:37 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C6BC6204EE; Mon, 28 May 2018 10:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527504336; bh=PVQnszdsMEYrzWXt/gOop5ApVrNgKqzzrPlJSucVGlA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dChcuoH7OlH1qbfoQob6CyPo1D7O7MgpEcRVjdPAx+4BnyK0cqMzclsb4c4KE4F8T HKjcfcwkoxu12aAow5UTcF2U6uU4QzyeYqnwk/jJ/qF8e9bumnrKa/eOm42dSWazsA 9LHVIeAUlzRVQ/FznVg09qNucGyS4nxwpul3tn5w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tobias Jakobi , Arnd Bergmann , Inki Dae , Sasha Levin Subject: [PATCH 4.14 100/496] drm/exynos: g2d: use monotonic timestamps Date: Mon, 28 May 2018 11:58:05 +0200 Message-Id: <20180528100324.068402142@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arnd Bergmann [ Upstream commit a588a8bb7b25a3fb4f7fed00feb7aec541fc2632 ] The exynos DRM driver uses real-time 'struct timeval' values for exporting its timestamps to user space. This has multiple problems: 1. signed seconds overflow in y2038 2. the 'struct timeval' definition is deprecated in the kernel 3. time may jump or go backwards after a 'settimeofday()' syscall 4. other DRM timestamps are in CLOCK_MONOTONIC domain, so they can't be compared 5. exporting microseconds requires a division by 1000, which may be slow on some architectures. The code existed in two places before, but the IPP portion was removed in 8ded59413ccc ("drm/exynos: ipp: Remove Exynos DRM IPP subsystem"), so we no longer need to worry about it. Ideally timestamps should just use 64-bit nanoseconds instead, but of course we can't change that now. Instead, this tries to address the first four points above by using monotonic 'timespec' values. According to Tobias Jakobi, user space doesn't care about the timestamp at the moment, so we can change the format. Even if there is something looking at them, it will work just fine with monotonic times as long as the application only looks at the relative values between two events. Link: https://patchwork.kernel.org/patch/10038593/ Cc: Tobias Jakobi Signed-off-by: Arnd Bergmann Reviewed-by: Tobias Jakobi Signed-off-by: Inki Dae Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/exynos/exynos_drm_g2d.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c @@ -926,7 +926,7 @@ static void g2d_finish_event(struct g2d_ struct drm_device *drm_dev = g2d->subdrv.drm_dev; struct g2d_runqueue_node *runqueue_node = g2d->runqueue_node; struct drm_exynos_pending_g2d_event *e; - struct timeval now; + struct timespec64 now; if (list_empty(&runqueue_node->event_list)) return; @@ -934,9 +934,9 @@ static void g2d_finish_event(struct g2d_ e = list_first_entry(&runqueue_node->event_list, struct drm_exynos_pending_g2d_event, base.link); - do_gettimeofday(&now); + ktime_get_ts64(&now); e->event.tv_sec = now.tv_sec; - e->event.tv_usec = now.tv_usec; + e->event.tv_usec = now.tv_nsec / NSEC_PER_USEC; e->event.cmdlist_no = cmdlist_no; drm_send_event(drm_dev, &e->base);