From patchwork Mon Oct 8 18:24:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10631227 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5C363933 for ; Mon, 8 Oct 2018 18:24:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 510A72995C for ; Mon, 8 Oct 2018 18:24:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 432262994A; Mon, 8 Oct 2018 18:24:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 00CA12994A for ; Mon, 8 Oct 2018 18:24:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B1E26E14F; Mon, 8 Oct 2018 18:24:28 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yb1-xb43.google.com (mail-yb1-xb43.google.com [IPv6:2607:f8b0:4864:20::b43]) by gabe.freedesktop.org (Postfix) with ESMTPS id B3E576E14F for ; Mon, 8 Oct 2018 18:24:26 +0000 (UTC) Received: by mail-yb1-xb43.google.com with SMTP id w80-v6so8662477ybe.10 for ; Mon, 08 Oct 2018 11:24:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nnW1GD8FMhmkvXFMTGM3fuoSI0e+urMspecQXEu4FRI=; b=cYd6IkSfZ1oJ9xO6grQfgioweHVFIpQb8M8kpFgkQpJCnz038IpVwST5auCM7Idlqf z2PoTNf7t7KvKCM5Q1852ehes6LelxsQQTEmekrmBxeAwukLzpz77jPBTqH3v/tPR8q0 pkOb/IqKPFPehWRwYDVqykTdupbhkyZPvgshJMUQjDvXZ/O5RIFdpuPInDnqIA0JYWrl ENDP9ArkZshGU0/pI7pEf+gm2AAP2UXGrlHC+++LNUblYzmiwWbmGJqOPgrSkqoRH6JO mXD0t7Fyk1m7VD+u2mEbpV3HPwwGTD4/bFRAPhPMMb/H6u09kobHg4aMhfakc8gdASXH Rz3Q== X-Gm-Message-State: ABuFfoiDvtmkd6o7nyvpJzQiprBVfzXEw0AoDwgFGlR/20VDuVl7UyQN wnBROqruuKNfN1sbKiLClE+oVB9NpjRKWQ== X-Google-Smtp-Source: ACcGV613E0WLStyQJOePxpfSWzntryH71ijzS5MKnv0eU7hrUVb2njLliCk2qywLLW+kl+i/hl31BQ== X-Received: by 2002:a25:2143:: with SMTP id h64-v6mr7862658ybh.30.1539023065589; Mon, 08 Oct 2018 11:24:25 -0700 (PDT) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:ad55:b1db:adfe:3b9f]) by smtp.gmail.com with ESMTPSA id g126-v6sm6028452ywf.9.2018.10.08.11.24.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 11:24:25 -0700 (PDT) From: Sean Paul To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm/msm: a5xx: Remove unneeded parens Date: Mon, 8 Oct 2018 14:24:13 -0400 Message-Id: <20181008182424.108745-1-sean@poorly.run> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog MIME-Version: 1.0 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: Sean Paul , linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Paul A small fixup I posted with my v2 patch [1] that was dropped. [1]- https://lists.freedesktop.org/archives/freedreno/2018-October/003647.html Signed-off-by: Sean Paul --- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c index eabe9252ae1e..48b5304f460c 100644 --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c @@ -1443,8 +1443,8 @@ static unsigned long a5xx_gpu_busy(struct msm_gpu *gpu) busy_cycles = gpu_read64(gpu, REG_A5XX_RBBM_PERFCTR_RBBM_0_LO, REG_A5XX_RBBM_PERFCTR_RBBM_0_HI); - busy_time = (busy_cycles - gpu->devfreq.busy_cycles); - do_div(busy_time, (clk_get_rate(gpu->core_clk) / 1000000)); + busy_time = busy_cycles - gpu->devfreq.busy_cycles; + do_div(busy_time, clk_get_rate(gpu->core_clk) / 1000000); gpu->devfreq.busy_cycles = busy_cycles; From patchwork Mon Oct 8 18:24:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10631231 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5BAA317E3 for ; Mon, 8 Oct 2018 18:24:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EE6D2994A for ; Mon, 8 Oct 2018 18:24:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4234F2995F; Mon, 8 Oct 2018 18:24:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F0C412994A for ; Mon, 8 Oct 2018 18:24:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DDEE06E15C; Mon, 8 Oct 2018 18:24:49 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw1-xc43.google.com (mail-yw1-xc43.google.com [IPv6:2607:f8b0:4864:20::c43]) by gabe.freedesktop.org (Postfix) with ESMTPS id CC7F96E157 for ; Mon, 8 Oct 2018 18:24:45 +0000 (UTC) Received: by mail-yw1-xc43.google.com with SMTP id l79-v6so8460740ywc.7 for ; Mon, 08 Oct 2018 11:24:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2U006oFD13T1ZQFyCFmAPZ2kcT8tzJ3+iBHAxULc1bc=; b=P7Z+3/N9EEPOMWqJ8cNeHF0NGF3Nn/VwEqiwuZgP2KQvM/QwQhcLzcZu+UK4+R9sUS Xvs4lIZ76sTeB29mlLe9MtOswNA4Dv2Hm4ofT2pxfHOfotXSt+H/DFgtWD+uaL+l/Eey 5hRhvVAXB64F0TlngmpMnhdAoGCgSnvRcxedWCUVbvIXV1uVs+93tsiOH/fhhDXtDphV 0bmKJyOsYXO52WRQ/tld7rjS4/Cm215FHGU11Gl46cJe3VG8KDyMcFhF1Q93it04eQrm XTgiwd9faSnH+5mMkbOvznZQh7HA0m1Dg/wkq7mNk7KxIqiq29q44TTp5ezlu+u++ol6 al0w== X-Gm-Message-State: ABuFfoh0ZAO6vKTh32TKpU8txSdTZa1/hnCh0uMaFG1W2r+ZEoEnqOgO svCWSkij14SuQPaLNnUSHVUK8BddxvAQFQ== X-Google-Smtp-Source: ACcGV60ND90+HwZDWtSjGsNdGEwTi1rKd/zoE13MJbrL5euZRlq9GGHAgptYz8XrGyfnyhoeAVY0fg== X-Received: by 2002:a81:d10a:: with SMTP id w10-v6mr10827542ywi.245.1539023084841; Mon, 08 Oct 2018 11:24:44 -0700 (PDT) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:ad55:b1db:adfe:3b9f]) by smtp.gmail.com with ESMTPSA id g126-v6sm6028452ywf.9.2018.10.08.11.24.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 11:24:44 -0700 (PDT) From: Sean Paul To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm/msm: a6xx: Fix improper u64 division Date: Mon, 8 Oct 2018 14:24:14 -0400 Message-Id: <20181008182424.108745-2-sean@poorly.run> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog In-Reply-To: <20181008182424.108745-1-sean@poorly.run> References: <20181008182424.108745-1-sean@poorly.run> MIME-Version: 1.0 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: linux-arm-msm@vger.kernel.org, Sharat Masetty , Sean Paul , freedreno@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Paul This patch uses the proper do_div() macro to perform u64 division and guards against overflow if the result is too large for the unsigned long return type Fixes: a2c3c0a54d4c drm/msm/a6xx: Add devfreq support for a6xx Cc: Sharat Masetty Signed-off-by: Sean Paul --- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index cdc3d59a659d..631257c297fd 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -761,18 +761,21 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu) { struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu); - u64 busy_cycles; - unsigned long busy_time; + u64 busy_cycles, busy_time; busy_cycles = gmu_read64(&a6xx_gpu->gmu, REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_L, REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H); - busy_time = ((busy_cycles - gpu->devfreq.busy_cycles) * 10) / 192; + busy_time = (busy_cycles - gpu->devfreq.busy_cycles) * 10; + do_div(busy_time, 192); gpu->devfreq.busy_cycles = busy_cycles; - return busy_time; + if (WARN_ON(busy_time > ~0LU)) + return ~0LU; + + return (unsigned long)busy_time; } static const struct adreno_gpu_funcs funcs = {