From patchwork Fri Nov 8 21:32:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178999 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3315526ilf; Fri, 8 Nov 2019 13:37:40 -0800 (PST) X-Google-Smtp-Source: APXvYqyUcbrcdcA5fpDjuwBvisKw+OE6LlI37V2Hzwlk7qzwX7u+wbFlGgkb2wI76ryj87ypqQdt X-Received: by 2002:a63:e801:: with SMTP id s1mr6877609pgh.213.1573249060319; Fri, 08 Nov 2019 13:37:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573249060; cv=none; d=google.com; s=arc-20160816; b=th37rj5weLSxJXlI3+vss6gtCmbuL4ozUW6aEhZ6DdueciCc5TfIKZ+ApPpqRBfIz/ s4s2bl0cjtqpyUt10PM8AGL44NWc3d+pB85mLnKWrCyBQrJwmvWovrZ1478aO9SJ8HKE Jx02liHNOQXFrfekLewKT8jrk4TRLFVTdemx3c5GNK4UiVxOjzOCYybQPcqZQ8Oh/udL JfJ0Px4d6sv2Va9f0z3vd4kGb/9rU69gOJnKbD+I0j8wVJ+7UwuvcAVRrDcGtAEv2coP TQlTSGrO4onNU8q607cdQp39+XX5tyaCvNOwAi/GORR7L395xm8WL67fuoy3N6S/jJT1 Xa0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:delivered-to; bh=QKuezpHE7H0MePc7JrUVtKkL5Im+LYyZixT//uBdUb4=; b=BQcMv8MNLuQj0kXwQlEAwOKZ+fCeLC0EK9tLt4966m5FsJzpTJIRNOt/oIRIw9m65S mJsbmF1tzeC855uLK3JVWLuUqRu1hSnwTqBwqcNYAsRzEn78bN2gMRlMaxwKAn7wYlgU qUWNh7g/s6/eZwO57mTu4RsF9kPsxqo9iHL9puT709CewCeiGmW+ciLYlkovuVL8a/y9 9G3rkCEOM0CCwQRJDZ6TgClDSsByHgKRQ06ltgKiRIOgv6gtM1QDk7SNKCFrIsyxTNYc hOFsmilSwaDWBtc2eq/dlW2cW23NYccXoVezq6Ih3DtAB+kixMUIyK+KePYRKE108khR ZYvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id w11si8306560plp.258.2019.11.08.13.37.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Nov 2019 13:37:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 507F96FA92; Fri, 8 Nov 2019 21:37:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.187]) by gabe.freedesktop.org (Postfix) with ESMTPS id E06396FA92 for ; Fri, 8 Nov 2019 21:37:37 +0000 (UTC) Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1N3sye-1hkxG40Ils-00zl9w; Fri, 08 Nov 2019 22:37:20 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, Rob Clark , Sean Paul , David Airlie , Daniel Vetter Subject: [PATCH 14/16] drm/msm: avoid using 'timespec' Date: Fri, 8 Nov 2019 22:32:52 +0100 Message-Id: <20191108213257.3097633-15-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108213257.3097633-1-arnd@arndb.de> References: <20191108213257.3097633-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:RjEXZPsu7wpFhVxxI0dg1gh3Sz1Hs1tSIhY/d+ypW54uoydpUSG AmGQqqAY8JV5SlTDcXhYy28Cbwi6/UGOCD0adGaB381dFQFh/45M+dKBA0PhUP+o9KaobMD qQ4+kG6gGE9DhvaaTxM/81sndh8nhZ8P0Vu53TlGZW7N7R5T5iUpKVXTQlPxMFUkAtL5rs2 msQ7tFAGZ+6hiDk9RernQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:D5yuQNG3OL4=:+hVgFS2myj/sb8ogFE78Gf FbKWcflcE8+US9yHfM4XVrV8foC/5BoESWZWiO/u184ma1eEMd/MnwSldHbYazHDHwj+Hk0cc w1ZZoSZHw4i2n04uf7GQRD305sbby6a/ARii8mddT6zRtv89NmMt7YKRV2k6pa2McGa46TLXI 27ESG6TqgROSWOlECco2f8f6/fAopAzdxTLoLuQQSdHwFAHO4VOhbQRmpC6yZ8gP75krH1mxD 7RpqwXn3BD8r/pG1dTm/d6vf0KUkeMhjmjhvMn35EUGy10yqOyibgRSRNggUOVk+JXvqcbADt k+HAhYEhuPLgVd0+QAe1B4po/j2ou2y1fW0/nx9zGNC0/cRdk9b+ndgOFHcmTRdjHOxOEwmTb ibhZMHBgI7GoZJzMrt1nQ7+PYx+XcaL8O7kFdja71uOK/2P9ZFdFLRyROE0XQztIxXE+r3eF1 YfSIi582gUSMzpxM4iIcFe3ieBp8J6DKYq6NX8x8B4ylUAUAs0I9f6B6kp4Pnwz2JAsjHWEwG h6f/GW3C8Uczi7An1srzRVP1SZriDAsuGBZvIamli9X7+IKnh09hTiJng40aSYHPBbKor/nDS gLMC3fT2lbdLzt5MYBKransgJZ2pbKZ8Np/YdZxRnO69REzQyXI449mSspVn/wbf/VeQoL144 DUMHUqUPSL4P6uzETmFemX8tGWajJnhrjGeV0NLaelE2Lxhvsxn7IM3NAJW59eNULBS0RcMiD IZQ2f7Gv6anhh/MtSw2sEO5tpQ7Ggk+81o17ssiA635dGoVymkpMfpRJxjJmoh6SY9w3HbS+D nEhwjGkP08t6b86oomYL9qFNuRI5fmLgCcd45bPGdaCNzD2zaFO0+hUcD5kHmsalbPgc0w11X zFmCZZt7G4MqQdjIlmUw== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: freedreno@lists.freedesktop.org, Jonathan Marek , Arnd Bergmann , linux-arm-msm@vger.kernel.org, "Kristian H. Kristensen" , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Joe Perches , Sam Ravnborg , Thomas Gleixner Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The timespec structure and associated interfaces are deprecated and will be removed in the future because of the y2038 overflow. The use of ktime_to_timespec() in timeout_to_jiffies() does not suffer from that overflow, but is easy to avoid by just converting the ktime_t into jiffies directly. Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/msm/msm_drv.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 71547e756e29..740bf7c70d8f 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -454,8 +454,7 @@ static inline unsigned long timeout_to_jiffies(const ktime_t *timeout) remaining_jiffies = 0; } else { ktime_t rem = ktime_sub(*timeout, now); - struct timespec ts = ktime_to_timespec(rem); - remaining_jiffies = timespec_to_jiffies(&ts); + remaining_jiffies = ktime_divns(rem, NSEC_PER_SEC / HZ); } return remaining_jiffies; From patchwork Fri Nov 8 21:32:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 179001 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3315928ilf; Fri, 8 Nov 2019 13:38:02 -0800 (PST) X-Google-Smtp-Source: APXvYqwXHPjwQdorGwgLyrtusPhHaEzFX1Axh0dGaglOfD/IIYwQksv9QEeOSDGzkz21tDmGmp+U X-Received: by 2002:a17:90a:1048:: with SMTP id y8mr16636814pjd.22.1573249082640; Fri, 08 Nov 2019 13:38:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573249082; cv=none; d=google.com; s=arc-20160816; b=IrE5y+Am18XSg7LRGsEshLlbVRAqV9TEPtfgU6NBSvEka/O8utVVAoDP1FwMnsfxSf Hc/NrxeVGvz3qOCFzUJ5Jp+zH6V7eO9v87vPOmxFFCt6iP6KCVPwyMSNBdIocuP+Jj+P 7QnheeeSGaJi9jofyt4r2jxIX9F7m1BTYyuZOj5ntmahyvn6JJ/ElQNKrl2hilsz5vyE BudBVfM83ORuJd+b51QbS/XSAMprlq4X1cBfoZzIe2ZDNiKjQ5L/Ydua2BwqAHfCkjqD DzmbiIyGIKx310vNM/6Eiu8rI1OkK6y5mv1G0JU4v21zBMp1wrsOSqwICdfYcYUPUhzF s7xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:delivered-to; bh=oFCoWGjgFVieQllvpRNaY8YK7YUy5NcPHCBzbyPi3UU=; b=U86EivsIB+jOFR83LNzIgCzRYf58J++J6R9197gol274TLVA296NegbApvJhqS40+p le87TS7vhUnv5+AD+rRMmB5DnCt+2ak77PUc9hRahK5aQp9o0Uuw5RFnxXH6v7ku0A/b HRAB11tLEK5HSw0tDF05rb8UGXBnAlsOGJnqIgPjjYNinejQEym7y0muIO83wRr0Vf4X mpxFtg7QE/JscPZQuNdxWtTM+YsHyRHDFINQWLJ7ZSIUILQIWOMq/yFcwC8fNeKJx8iC JoeYhbjLXwTXlmyhYQJQcYJRf3XpYO3qQolu5dYAiybnqlQvpMPx9T0c+Tk50wIZnZeX zNXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id s5si7203986pjn.69.2019.11.08.13.38.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Nov 2019 13:38:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9F0046FA93; Fri, 8 Nov 2019 21:38:01 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.134]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F5EA6FA93 for ; Fri, 8 Nov 2019 21:38:00 +0000 (UTC) Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1Mn2Fb-1i1nwX1PPz-00k9z1; Fri, 08 Nov 2019 22:37:50 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, Lucas Stach , David Airlie , Daniel Vetter Subject: [PATCH 15/16] drm/etnaviv: use ktime_t for timeouts Date: Fri, 8 Nov 2019 22:32:53 +0100 Message-Id: <20191108213257.3097633-16-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108213257.3097633-1-arnd@arndb.de> References: <20191108213257.3097633-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:0mG/AeRqRfllKNyxjsRTf1Lcjrue4mA0fTazDskyMcSc5mlcPDP zbVsx/cHjwgO02t9e22UWWZH0DGv7RXqjSXbPD3DPZRjW5iWLttQosFa3M1orsc35xqlood /rkgvkWdLpjLCGamV2uyd9Sryst2A5hYqyZWYH/dUS/hCt8Wq+k4A3DvFqlkufIJb052pjX VppE3uMwAwBi6LBZ1hkIg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:F261wtjEcT0=:5B/i1CyfuUrOw9eZBz/PLK hjY0gVwJQdkRM7obOi8iEsKCYl+fPz3Dv27PPeQlVcVrhOw3R+dP6IpEdAxei2BjnXxYDjh66 aPS3OBOQHslKZ3OeyDJe9DmgX80C9S4tPkEbPHSgPVbUtvgJy8vtHxnoJ4xm7PnhRQxegtk9a GcsKvnDoZG+y63G/aYXmWuGOfC78Z2a4TJsnmCnF90pjnwXkC+yX1pGfkWd+FTfvrZLnSBn+v JGpXkQOSAzUDk/drEENpyjc5UA0Ydbigu7yyJzGxQTJUF8HL50B1HrvxI8QUI4QQsRfD85Fop kZ3a/3mhjjoZ9cxBYB5UbA+uWxoUe95Envho17lWGtXR8cuxetz5LiB20PGbXjCH7YTAVinpv VJkM63TNTTBs70tRux/sfx+Bw0nsTEzzWqeZzagG1U4LG5SgdWMO/R98kfP+KVIi1W/mC0kNX WGlMUs6ky38u2v1UBIUHLUm0ncTwQR6YYIngKvnAB6UFI9mYlQLkdL8q7wh3qweT4UE0o2v5d 9vOK2DGYLusxNChy8p6OOfl6MNxMO6+EiPQMzhTKCWofZZFPuSPY6kJeTcPZWmQBaIc2WMfaF yUZKM7Wkw8plvQjy7E3cQ2TORmryKWPOZMd3fOeIxRw0Gevld+v64UDQRoYGqP7D7I10e2HfE hXQ72fC34kg8nUPPlRxm8dZdtXI/B5P3FLJ1UdMjYVWs/HD/EC+PfeiGvR1FOLBunfS81QB4y w1BVo7MZVUOrUaC27tXh3gQP4MIW2IQp8aYYhs2Pc5GNL3SjdDY4KNDGtcH5pUATj4TkMBpsD KP2LkzB5gi4EglpnawANVaSU3QqOZyZfqt8ei3wG3DyKxlUJGPpYjXvaIbX+ihtBYPK0NI0J8 bYuwzkontVfVbF+ibFlQ== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , =?utf-8?q?Guido_G=C3=BCnther?= , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, etnaviv@lists.freedesktop.org, Russell King , Sam Ravnborg , =?utf-8?q?Christian_K=C3=B6nig?= , Emil Velikov Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" struct timespec is being removed from the kernel because it often leads to code that is not y2038-safe. In the etnaviv driver, monotonic timestamps are used, which do not suffer from overflow, but using ktime_t still leads to better code overall. The conversion is straightforward for the most part, except for etnaviv_timeout_to_jiffies(), which needs to handle arguments larger than MAX_JIFFY_OFFSET on 32-bit architectures. Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 19 +++++++++---------- drivers/gpu/drm/etnaviv/etnaviv_drv.h | 21 +++++++++------------ drivers/gpu/drm/etnaviv/etnaviv_gem.c | 5 ++--- drivers/gpu/drm/etnaviv/etnaviv_gem.h | 2 +- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 4 ++-- drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 4 ++-- 6 files changed, 25 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index 1f9c01be40d7..1250c5e06329 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -282,16 +282,13 @@ static int etnaviv_ioctl_gem_new(struct drm_device *dev, void *data, args->flags, &args->handle); } -#define TS(t) ((struct timespec){ \ - .tv_sec = (t).tv_sec, \ - .tv_nsec = (t).tv_nsec \ -}) - static int etnaviv_ioctl_gem_cpu_prep(struct drm_device *dev, void *data, struct drm_file *file) { struct drm_etnaviv_gem_cpu_prep *args = data; struct drm_gem_object *obj; + ktime_t timeout = ktime_set(args->timeout.tv_sec, + args->timeout.tv_nsec); int ret; if (args->op & ~(ETNA_PREP_READ | ETNA_PREP_WRITE | ETNA_PREP_NOSYNC)) @@ -301,7 +298,7 @@ static int etnaviv_ioctl_gem_cpu_prep(struct drm_device *dev, void *data, if (!obj) return -ENOENT; - ret = etnaviv_gem_cpu_prep(obj, args->op, &TS(args->timeout)); + ret = etnaviv_gem_cpu_prep(obj, args->op, timeout); drm_gem_object_put_unlocked(obj); @@ -354,7 +351,8 @@ static int etnaviv_ioctl_wait_fence(struct drm_device *dev, void *data, { struct drm_etnaviv_wait_fence *args = data; struct etnaviv_drm_private *priv = dev->dev_private; - struct timespec *timeout = &TS(args->timeout); + ktime_t timeout = ktime_set(args->timeout.tv_sec, + args->timeout.tv_nsec); struct etnaviv_gpu *gpu; if (args->flags & ~(ETNA_WAIT_NONBLOCK)) @@ -368,7 +366,7 @@ static int etnaviv_ioctl_wait_fence(struct drm_device *dev, void *data, return -ENXIO; if (args->flags & ETNA_WAIT_NONBLOCK) - timeout = NULL; + timeout = ktime_set(0, 0); return etnaviv_gpu_wait_fence_interruptible(gpu, args->fence, timeout); @@ -403,7 +401,8 @@ static int etnaviv_ioctl_gem_wait(struct drm_device *dev, void *data, { struct etnaviv_drm_private *priv = dev->dev_private; struct drm_etnaviv_gem_wait *args = data; - struct timespec *timeout = &TS(args->timeout); + ktime_t timeout = ktime_set(args->timeout.tv_sec, + args->timeout.tv_nsec); struct drm_gem_object *obj; struct etnaviv_gpu *gpu; int ret; @@ -423,7 +422,7 @@ static int etnaviv_ioctl_gem_wait(struct drm_device *dev, void *data, return -ENOENT; if (args->flags & ETNA_WAIT_NONBLOCK) - timeout = NULL; + timeout = ktime_set(0, 0); ret = etnaviv_gem_wait_bo(gpu, obj, timeout); diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.h b/drivers/gpu/drm/etnaviv/etnaviv_drv.h index 32cfa5a48d42..57a4e247bbcf 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.h @@ -60,8 +60,7 @@ struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev, int etnaviv_gem_prime_pin(struct drm_gem_object *obj); void etnaviv_gem_prime_unpin(struct drm_gem_object *obj); void *etnaviv_gem_vmap(struct drm_gem_object *obj); -int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op, - struct timespec *timeout); +int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op, ktime_t timeout); int etnaviv_gem_cpu_fini(struct drm_gem_object *obj); void etnaviv_gem_free_object(struct drm_gem_object *obj); int etnaviv_gem_new_handle(struct drm_device *dev, struct drm_file *file, @@ -106,22 +105,20 @@ static inline size_t size_vstruct(size_t nelem, size_t elem_size, size_t base) * We need to calculate the timeout in terms of number of jiffies * between the specified timeout and the current CLOCK_MONOTONIC time. */ -static inline unsigned long etnaviv_timeout_to_jiffies( - const struct timespec *timeout) +static inline unsigned long etnaviv_timeout_to_jiffies(ktime_t timeout) { - struct timespec64 ts, to; - - to = timespec_to_timespec64(*timeout); - - ktime_get_ts64(&ts); + s64 remain = ktime_to_ns(ktime_sub(timeout, ktime_get())); /* timeouts before "now" have already expired */ - if (timespec64_compare(&to, &ts) <= 0) + if (remain < 0) return 0; - ts = timespec64_sub(to, ts); +#ifndef CONFIG_64BIT + if (remain > ((s64)MAX_JIFFY_OFFSET * NSEC_PER_SEC / HZ)) + return MAX_JIFFY_OFFSET; +#endif - return timespec64_to_jiffies(&ts); + return nsecs_to_jiffies(remain); } #endif /* __ETNAVIV_DRV_H__ */ diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c index cb1faaac380a..febe5196788e 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c @@ -372,8 +372,7 @@ static inline enum dma_data_direction etnaviv_op_to_dma_dir(u32 op) return DMA_BIDIRECTIONAL; } -int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op, - struct timespec *timeout) +int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op, ktime_t timeout) { struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj); struct drm_device *dev = obj->dev; @@ -431,7 +430,7 @@ int etnaviv_gem_cpu_fini(struct drm_gem_object *obj) } int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj, - struct timespec *timeout) + ktime_t timeout) { struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj); diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.h b/drivers/gpu/drm/etnaviv/etnaviv_gem.h index d6270acce619..a3461a554a6c 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.h @@ -112,7 +112,7 @@ struct etnaviv_gem_submit { void etnaviv_submit_put(struct etnaviv_gem_submit * submit); int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj, - struct timespec *timeout); + ktime_t timeout); int etnaviv_gem_new_private(struct drm_device *dev, size_t size, u32 flags, const struct etnaviv_gem_ops *ops, struct etnaviv_gem_object **res); void etnaviv_gem_obj_add(struct drm_device *dev, struct drm_gem_object *obj); diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index d47d1a8e0219..e42b1c4d902c 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c @@ -1132,7 +1132,7 @@ static void event_free(struct etnaviv_gpu *gpu, unsigned int event) * Cmdstream submission/retirement: */ int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu, - u32 id, struct timespec *timeout) + u32 id, ktime_t timeout) { struct dma_fence *fence; int ret; @@ -1179,7 +1179,7 @@ int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu, * that lock in this function while waiting. */ int etnaviv_gpu_wait_obj_inactive(struct etnaviv_gpu *gpu, - struct etnaviv_gem_object *etnaviv_obj, struct timespec *timeout) + struct etnaviv_gem_object *etnaviv_obj, ktime_t timeout) { unsigned long remaining; long ret; diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h index 8f9bd4edc96a..6d352a435427 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h @@ -169,9 +169,9 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m); void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu); void etnaviv_gpu_retire(struct etnaviv_gpu *gpu); int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu, - u32 fence, struct timespec *timeout); + u32 fence, ktime_t timeout); int etnaviv_gpu_wait_obj_inactive(struct etnaviv_gpu *gpu, - struct etnaviv_gem_object *etnaviv_obj, struct timespec *timeout); + struct etnaviv_gem_object *etnaviv_obj, ktime_t timeout); struct dma_fence *etnaviv_gpu_submit(struct etnaviv_gem_submit *submit); int etnaviv_gpu_pm_get_sync(struct etnaviv_gpu *gpu); void etnaviv_gpu_pm_put(struct etnaviv_gpu *gpu);