Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753903AbdLMU4u (ORCPT ); Wed, 13 Dec 2017 15:56:50 -0500 Received: from mail-cys01nam02on0075.outbound.protection.outlook.com ([104.47.37.75]:53696 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753144AbdLMU4s (ORCPT ); Wed, 13 Dec 2017 15:56:48 -0500 Date: Wed, 13 Dec 2017 12:56:37 -0800 From: Sinclair Yeh To: Arnd Bergmann Cc: VMware Graphics , Thomas Hellstrom , David Airlie , Deepak Singh Rawat , Tomi Valkeinen , Arvind Yadav , Ravikant B Sharma , Joe Perches , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] vmwgfx: use monotonic event timestamps Message-ID: <20171213205635.GB16788@promb-2n-dhcp36.eng.vmware.com> References: <20171127111629.1682286-1-arnd@arndb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171127111629.1682286-1-arnd@arndb.de> User-Agent: Mutt/1.8.2 (2017-04-18) X-Originating-IP: [208.91.1.34] X-ClientProxiedBy: MWHPR04CA0091.namprd04.prod.outlook.com (10.174.173.32) To CY4PR05MB3288.namprd05.prod.outlook.com (10.171.247.160) X-MS-Office365-Filtering-Correlation-Id: b305de19-e94c-4337-d7aa-08d5426c05bd X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603307);SRVR:CY4PR05MB3288; X-Microsoft-Exchange-Diagnostics: 1;CY4PR05MB3288;3:JF88htT3W0w5aK0xR5fkhLqZTtJHOSd0Y+umg1W2V5kwG2vzlOSfTV/4G3sYDatB+qvN6VGD2lKv6mLGwRK7KI/hilOBP7kJbKUewXny8JA6/JFcmd5Uu7P04kRTxmWGN7CnIfWSMinS5Z9EKjae1hUNcxUOyMFfh3S7UP2Kat161jkZyhMvb66LH5vGMQcIb9RKQB8SrcTZ3hybhRerFJCoqL9SW+5PgO4r1rII1PrCuAwWETTBFupYSqWGFfAY;25:RMVPnpHveHLRN0iJ/bt2VgvNCLYMOUB0cavFO/dgDBzaIPzPs81Mlm4kFCETGJ5jdSWnVkjqkRJT9UoPdOE95yMjzpw0czSkgPt++TW669+VuZtuYmr7PN4G+0UWDNdQUmuqU8XGNRxhGW9KCyxalKJsG7F1CDgwoW3hBULunCqpNDLOdl4K9o/mwYoSsb6gw9jQbde6MWpsHS0POoxCvwWiuLi8ev0gP/hbxOT8Ub4Y365owiDn4gejiUywb3YTK/8QBtwOP4m0194QJuDCgzUaPWD2Ss7jLzyPvzdNPWFysZWneNQdh8vXuV1NTmKheXhtVnTcH+3swUvoQBhYng==;31:eJFeR/GPOtd3CpSUbjRCZ3oiLKC1mhtHHKNswoWMLPBB4QEeZlkD4+c9eJbMTFygKRPqIDdbmk1HngcvfDTbToG1S777p2I9C76hfdRce3D0uSzDA5BeeN9QuZyozYVajD2fZGM5iJ+BvUYzCfeRHgtQMFEbqvyQWrKsh/KUDgzJ84iZpFyrkSxb0Caxy3nLJR1FDwwxQwn/gdlDAdSqENXwTyh9rOtjOJg3vUqjLJo= X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PR05MB3288: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=syeh@vmware.com; X-Microsoft-Exchange-Diagnostics: 1;CY4PR05MB3288;20:v/CdDzPKJpmiLNi+6V61tvZUgT6dCXIhbtDfHG0XyH1rfbF+OLmkCBvA5WNxKGi94QY6Knm8Ae97U2Ubx4j07yVcpNYHzmuBevagknr0YE4FXWEh/89FAqVadN7JHzpU9+pbbF4HFDudxl4b/4SECBLe37PIvQvuGQn72csQRSL6QZKN7gTHLbjN3ENL1Pd/ckhrhv8wLjIcZfpUd5BJb41GYBfEBEtTvRCtEhZ43S2oXVNnNthQnq4VjK0ZLMKhPvvYQ8q+LN2c3+B6qRPFbzZVfAko438yh2c6CkPISzItEWl3nijPGfb37WxRXcXOO5SRSdelsU7aD84V03hIhojf/XCcUAAI6Tc9PmHfxcgs4lrtL/ObV6b6g7uFVL3QZEW9GK+uBVkzfEA3T6mCihs9K1kVtq2YrJ338/zBTEYIG1xlDX/eRS0YioqNwNUBnlSXslmw5VQr+cWXMgDdE/D3cQBuWdmARtHSizjuFi6310V/uLILtOZqn+ypF+lw;4:Xmh+uzlqcBerG08vDvI/7YICcDNsR68BeG4/UcCCxHpSVGqtB+GgEukhj63O2y+Wc3DSQYZ2Xb9zH+zDbB9aN7YNyToiy04eGItTvv7tU6JFTBc4PLcN6ON6iS6MXZoTi9DH35syRtmvTcuD6zpq77GuZ68tPkC+XOYVjECG/+q5oRVE1aKNipBb++5D3C1hGrF9876nguTXiyLWIt1UVO31Fd7xqvq5vig3BX0cZYkeL/4DguwXQroUnC+QbOtu5Z/HwYemh07+f4SLJzYJOg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231023)(3002001)(10201501046)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(20161123560025)(20161123564025)(20161123562025)(6072148)(201708071742011);SRVR:CY4PR05MB3288;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:CY4PR05MB3288; X-Forefront-PRVS: 052017CAF1 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(346002)(376002)(396003)(366004)(39860400002)(189003)(199004)(24454002)(105586002)(575784001)(86362001)(316002)(47776003)(6246003)(4326008)(53936002)(39060400002)(66066001)(106356001)(25786009)(33656002)(58126008)(16586007)(68736007)(8936002)(54906003)(16526018)(83506002)(305945005)(52116002)(97736004)(7696005)(50466002)(386003)(55016002)(6116002)(3846002)(478600001)(76176011)(2906002)(81166006)(229853002)(8676002)(5660300001)(81156014)(1076002)(6666003)(59450400001)(2950100002)(23726003)(6916009)(7736002)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR05MB3288;H:promb-2n-dhcp36.eng.vmware.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY4PR05MB3288;23:nFxPcctbnzaXG8N3kZQTJwObZk/atQhiBsuUlKSZf?= =?us-ascii?Q?PEjsaJeEQZvVGnd6yLnIqOb5OyeMNaVrUMRl+GoqWkdFcbLKklqEtqAlIWJ5?= =?us-ascii?Q?4b1EmVPZo4UnFjf5S1/xVmfJKy9P3rX7MtzrkNzwvmTNDAySjyvIOd7c9wZf?= =?us-ascii?Q?u6jAABP9V3X68qUYrICier5e4VjXn/T6aDRIKB/GVSjqirGlHzMl+M8HWbe/?= =?us-ascii?Q?55eLAZSz4+NnjyRjyY+guv6BYGUXlcbziGUVNfFTmJ2P6WINec7HHe5PRoYI?= =?us-ascii?Q?l2z823XHbw1eA7Mi61eCnRJiIJx7fgpp0ekJpaiUpRo91kvDV4CP/91Y/kCW?= =?us-ascii?Q?/DRYY0XFz7qbyxlJ6xypzFUWXlj/1ANrQ14c8R7Tk935wJU49t556aeuMLK9?= =?us-ascii?Q?BzmBeyxwSPcO8/xN/jdq7wH6L1Gno6Nnx4/Nn1rn94GVkBQoPBA2YNjPDFvU?= =?us-ascii?Q?Gq0mL2k6AFJaOEIC2SbdML9heEIYmmJMORK3o5/U4bhbLLEtsoQR0i1sx6XR?= =?us-ascii?Q?ovKkhzC7yKk14Jh54etK2bbBVtcxFk6HYz7yAYVILRWoDa9L1u71SYbGtIeO?= =?us-ascii?Q?8NO/W9YN8pfuijo9eA9hquP2uj+v6Xbf577oQb69rRIYGZCZS7Pzq60c80NF?= =?us-ascii?Q?5/l1H1PUdwCoaT1brB48osoqHGd1d5pAkP8J71dHJgPs+5u7GvPbTduApt3f?= =?us-ascii?Q?kclhPJki5Mb7+VA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dVXlnmjFVazrh7qvNKt1VGF1cIbRaPi331aDMM3c+eX6G/JGL+4PrF5suHYre+wByjKXrcSSP6qAC+pAQjnN2vvEx0ZobdRxtxulmksedab3QA70vYH7Gtbtgs1CoTJ/SJ2kqdx55BGu2rU=;24:cOrm6ifECTnG5FC2dbY/mKwbViCWacI7st5XMIbBd4KgAbdAbhNfqf64FtX8JNmQgNp+m8lwdYyceP/jV+i8XTe+dYYKHzJO6OI5xcPIAb4=;7:XMQiXdHXe93ZOIgWfkcUo452C/5+ehWtP81kCqupChprLDq3OT7PahfC1XjdZc6DrS2NRrGuSwy0YlC7gQsRvRDpWWCvGH1fxVYa/pgKbQtYSE2YL9QLQkDmzTSz5A+XXrLzn9pq2Nd1aFQzxZv8OYDgzrBY1ANjleiIuDVQnx2EfuYWvkZh/o1Z/JIUq+pMVOu+dhXYePt5aEXRk4GkjeQY4ezYCDONpWYE05rQNGg7eXQBWrNc3raLpQsMfcI1 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY4PR05MB3288;20:10tvf0WM2s08kZ3UmRgiumSHtde7RTfQo2J5l7Nx2qw38qEC/LOBJO0gFmQrzh+XoCH38/0txoJY0BpZA88HRhg1Netf3YZGQ8FnjSapn9n1Z3VD6NaN+IdrM2qvGHJg5dETvRWx6OCTtPGUucnUQTW7f06A7Cg0qY9GKV7LsE4= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2017 20:56:45.3959 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b305de19-e94c-4337-d7aa-08d5426c05bd X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR05MB3288 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1913 Lines: 56 This looks okay to me. Although we should change eaction->tv_* type to 64-bit as well. I'll roll this in to our next pull request. thanks, Sinclair On Mon, Nov 27, 2017 at 12:16:19PM +0100, Arnd Bergmann wrote: > DRM_VMW_EVENT_FENCE_SIGNALED (struct drm_vmw_event_fence) and > DRM_EVENT_VBLANK (struct drm_event_vblank) pass timestamps in 32-bit > seconds/microseconds format. > > As of commit c61eef726a78 ("drm: add support for monotonic vblank > timestamps"), other DRM drivers use monotonic times for drm_event_vblank, > but vmwgfx still uses CLOCK_REALTIME for both events, which suffers from > the y2038/y2106 overflow as well as time jumps. > > For consistency, this changes vmwgfx to use ktime_get_ts64 as well, > which solves those problems and avoids the deprecated do_gettimeofday() > function. > > This should be transparent to to user space, as long as it doesn't > compare the time against the result of gettimeofday(). > > Signed-off-by: Arnd Bergmann > --- > drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c > index d6b1c509ae01..55214d0da66e 100644 > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c > @@ -897,11 +897,12 @@ static void vmw_event_fence_action_seq_passed(struct vmw_fence_action *action) > spin_lock_irq(&dev->event_lock); > > if (likely(eaction->tv_sec != NULL)) { > - struct timeval tv; > + struct timespec64 ts; > > - do_gettimeofday(&tv); > - *eaction->tv_sec = tv.tv_sec; > - *eaction->tv_usec = tv.tv_usec; > + ktime_get_ts64(&ts); > + /* monotonic time, so no y2038 overflow */ > + *eaction->tv_sec = ts.tv_sec; > + *eaction->tv_usec = ts.tv_nsec / NSEC_PER_USEC; > } > > drm_send_event_locked(dev, eaction->event); > -- > 2.9.0 >