From patchwork Mon Sep 10 20:22:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 10594763 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 C74ED1515 for ; Mon, 10 Sep 2018 20:22:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8D3129081 for ; Mon, 10 Sep 2018 20:22:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC8A329108; Mon, 10 Sep 2018 20:22:21 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58D42290A7 for ; Mon, 10 Sep 2018 20:22:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726043AbeIKBSH (ORCPT ); Mon, 10 Sep 2018 21:18:07 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:45733 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726795AbeIKBSH (ORCPT ); Mon, 10 Sep 2018 21:18:07 -0400 Received: by mail-lj1-f196.google.com with SMTP id u83-v6so18993114lje.12 for ; Mon, 10 Sep 2018 13:22:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:cc:organization:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=CSaF2mzUL3++xaeUIgm6R6h/zUjEGQG59ZvNSMQ4BN4=; b=iRff3ylXSmw4QPo5uGNA44aOnWhXErK9QK8h4+btlyyxGXnDen/P2NVB8z1k8VJatq ZHgf3941W3AN4av4xVAhENKLyYcfwNzF+akwHow4gaN+iOqci49mbtbx6qfTib1UlaV6 QNCR9xH9cnndoH8l/FWQVYuM2nMc65Q6eQJm5ob5d7M3Douj9eSHCLPyQR9MTQZhtZFw Zp5HsAFYB6Rpeq4bVrw/QND0QNlqGFsyZh5lUJywuIF4TTOp5C+VFPXPfs5SKohtJJgV Bk0g2Te6X94ywDnziFNIO3vFe+LEKACNqkRQzrCtdE7gaexQ0dGz0rjBn/e5ysiZvuQN FsiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:organization:message-id:date :user-agent:mime-version:content-language:content-transfer-encoding; bh=CSaF2mzUL3++xaeUIgm6R6h/zUjEGQG59ZvNSMQ4BN4=; b=OL7h/Rg2SgAWj5xfRYVq7RVEmIrDM7Ktzox3HBSyF93BCww6bccT9M9b0otrSKqR8g 41mjyGq1DVeghNNy4u/9qzmrRYFhRpZd96OydUm1uOQk2Mxf/9ivplMSwLJtK4q8ML88 w2D8bCAhtRZYTt0GUIEt6TSnw86kuCkkYphiyaAeZBRecAgX9IMw8AmC2kaA+DtFS00s 3Ay51M+m9h8y1XHMt3nZRde+MazLjA4zHuc8iR/hifb7aPUttLlQ3CTpSV6DbDQVNjVV b99Maj6WSuYtu8mkOc7sjj6EZmu9ol3immtystwc6hhJ+yfjSIrQnXnk14UYUJZBH2uW m8RQ== X-Gm-Message-State: APzg51B1NgjqU1fudj68O3W8HWbOsfRlRWGBF9qm7s6/fV6xAovYcC4F 1L9T1XjdcbEKiiSVjG1QXXKb8cSApJQ= X-Google-Smtp-Source: ANB0VdZ06Fx6EaqljUcoCcqhUToKjEHIFc7dfdS3HyVtuhHd8juTK4mmB4VS5TMvKJ2W0XeFoW81fQ== X-Received: by 2002:a2e:1248:: with SMTP id t69-v6mr12974409lje.129.1536610938335; Mon, 10 Sep 2018 13:22:18 -0700 (PDT) Received: from wasted.cogentembedded.com ([31.173.81.12]) by smtp.gmail.com with ESMTPSA id f9-v6sm2955809ljf.9.2018.09.10.13.22.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Sep 2018 13:22:17 -0700 (PDT) From: Sergei Shtylyov Subject: [PATCH] clocksource: sh_cmt: fix clocksource width for 32-bit machines To: Daniel Lezcano , Thomas Gleixner , linux-renesas-soc@vger.kernel.org Cc: Vladimir Barinov , Andrey Gusakov , Mikhail Ulyanov , linux-sh@vger.kernel.org Organization: Cogent Embedded Message-ID: <749e6480-aed6-041c-0209-8dc74c07f344@cogentembedded.com> Date: Mon, 10 Sep 2018 23:22:16 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 Content-Language: en-MW Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The driver seems to abuse *unsigned long* not only for the (32-bit) register values but also for the 'sh_cmt_channel::total_cycles' which needs to always be 64-bit -- as a result, the clocksource's mask is needlessly clamped down to 32-bits on the 32-bit machines... Reported-by: Geert Uytterhoeven Signed-off-by: Sergei Shtylyov Reviewed-by: Simon Horman Reviewed-by: Geert Uytterhoeven --- This patch is against the 'tip.git' repo's 'timers/core' branch plus the fixup for the 64-bit machines reposted last Saturday... drivers/clocksource/sh_cmt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) Index: tip/drivers/clocksource/sh_cmt.c =================================================================== --- tip.orig/drivers/clocksource/sh_cmt.c +++ tip/drivers/clocksource/sh_cmt.c @@ -108,7 +108,7 @@ struct sh_cmt_channel { raw_spinlock_t lock; struct clock_event_device ced; struct clocksource cs; - unsigned long total_cycles; + u64 total_cycles; bool cs_enabled; }; @@ -613,8 +613,8 @@ static u64 sh_cmt_clocksource_read(struc { struct sh_cmt_channel *ch = cs_to_sh_cmt(cs); unsigned long flags; - unsigned long value; u32 has_wrapped; + u64 value; u32 raw; raw_spin_lock_irqsave(&ch->lock, flags); @@ -688,7 +688,7 @@ static int sh_cmt_register_clocksource(s cs->disable = sh_cmt_clocksource_disable; cs->suspend = sh_cmt_clocksource_suspend; cs->resume = sh_cmt_clocksource_resume; - cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); + cs->mask = CLOCKSOURCE_MASK(sizeof(u64) * 8); cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; dev_info(&ch->cmt->pdev->dev, "ch%u: used as clock source\n",