From patchwork Mon Jun 20 04:09:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seung-Woo Kim X-Patchwork-Id: 9186555 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8038C60756 for ; Mon, 20 Jun 2016 04:09:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C2D2223A6 for ; Mon, 20 Jun 2016 04:09:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60B4722F4A; Mon, 20 Jun 2016 04:09:50 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham 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 8358822BF1 for ; Mon, 20 Jun 2016 04:09:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750885AbcFTEJs (ORCPT ); Mon, 20 Jun 2016 00:09:48 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:59043 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750835AbcFTEJr (ORCPT ); Mon, 20 Jun 2016 00:09:47 -0400 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O9102VZQY88KSA0@mailout4.samsung.com>; Mon, 20 Jun 2016 13:09:44 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.113]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 74.2F.05161.88C67675; Mon, 20 Jun 2016 13:09:44 +0900 (KST) X-AuditID: cbfee68f-f79476d000001429-95-57676c88acd6 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id B3.AD.04429.88C67675; Sun, 19 Jun 2016 21:09:44 -0700 (MST) Received: from localhost.localdomain ([10.113.62.209]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O91005L8Y87DG40@mmp2.samsung.com>; Mon, 20 Jun 2016 13:09:44 +0900 (KST) From: Seung-Woo Kim To: jh80.chung@samsung.com, ulf.hansson@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, sw0312.kim@samsung.com Subject: [PATCH v3] mmc: dw_mmc: remove UBSAN warning in dw_mci_setup_bus() Date: Mon, 20 Jun 2016 13:09:45 +0900 Message-id: <1466395785-3715-1-git-send-email-sw0312.kim@samsung.com> X-Mailer: git-send-email 1.7.4.1 In-reply-to: <1466140609-5773-1-git-send-email-sw0312.kim@samsung.com> References: <1466140609-5773-1-git-send-email-sw0312.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJLMWRmVeSWpSXmKPExsWyRsSkULcjJz3c4M9+fYsbv9pYLS7vmsNm ceR/P6PFjMkv2SyOrw13YPW4c20Pm0ffllWMHp83yQUwR3HZpKTmZJalFunbJXBlbHp4hrXg qHTFys8NTA2MZ8S6GDk5JARMJP7+f8QKYYtJXLi3nq2LkYtDSGAFo8SROwdZYYpuLJ7KDGIL CcxilDhwQgWi6AejxJym24wgCTYBHYn9S36zgiREBFoZJfasmgWWEBbwlnh6rZUFxGYRUJX4 svcCUBE7B6+Aq8RiJoj5ChIL7r1lA7E5Bdwkljz7zAixy1ViS89HsIMkBN6zSdzfvI4JYoyA xLfJh4BGcgAlZCU2HWCGmCMpcXDFDZYJjEILGBlWMYqm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4f7xp6a+7a6z4Dzf9 PvfoWt37A913r51f8rle/MqLCQsasx49mXBbrT6M68vTcFvPj7E/b77Vz2uWmu0/ITuOw3UN +zRmayWW4oxEQy3mouJEAITgAuGZAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch removes following UBSAN warnings in dw_mci_setup_bus(). UBSAN: Undefined behaviour in drivers/mmc/host/dw_mmc.c:1102:14 shift exponent 250 is too large for 32-bit type 'unsigned int' Call trace: [] dump_backtrace+0x0/0x380 [] show_stack+0x14/0x20 [] dump_stack+0xe0/0x120 [] ubsan_epilogue+0x18/0x68 [] __ubsan_handle_shift_out_of_bounds+0x18c/0x1bc [] dw_mci_setup_bus+0x3a0/0x438 [...] UBSAN: Undefined behaviour in drivers/mmc/host/dw_mmc.c:1132:27 shift exponent 250 is too large for 32-bit type 'unsigned int' Call trace: [] dump_backtrace+0x0/0x380 [] show_stack+0x14/0x20 [] dump_stack+0xe0/0x120 [] ubsan_epilogue+0x18/0x68 [] __ubsan_handle_shift_out_of_bounds+0x18c/0x1bc [] dw_mci_setup_bus+0x384/0x438 [...] The warnings are caused because of bit shift which is used to filter spamming message for CONFIG_MMC_CLKGATE, but the config is already removed. So this patch just removes the shift. Signed-off-by: Seung-Woo Kim --- drivers/mmc/host/dw_mmc.c | 14 +++++--------- drivers/mmc/host/dw_mmc.h | 4 ---- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 2cc6123..bada11e 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1099,12 +1099,11 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit) div = (host->bus_hz != clock) ? DIV_ROUND_UP(div, 2) : 0; - if ((clock << div) != slot->__clk_old || force_clkinit) - dev_info(&slot->mmc->class_dev, - "Bus speed (slot %d) = %dHz (slot req %dHz, actual %dHZ div = %d)\n", - slot->id, host->bus_hz, clock, - div ? ((host->bus_hz / div) >> 1) : - host->bus_hz, div); + dev_info(&slot->mmc->class_dev, + "Bus speed (slot %d) = %dHz (slot req %dHz, actual %dHZ div = %d)\n", + slot->id, host->bus_hz, clock, + div ? ((host->bus_hz / div) >> 1) : + host->bus_hz, div); /* disable clock */ mci_writel(host, CLKENA, 0); @@ -1127,9 +1126,6 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit) /* inform CIU */ mci_send_cmd(slot, sdmmc_cmd_bits, 0); - - /* keep the clock with reflecting clock dividor */ - slot->__clk_old = clock << div; } host->current_speed = clock; diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h index 1e8d838..5961037 100644 --- a/drivers/mmc/host/dw_mmc.h +++ b/drivers/mmc/host/dw_mmc.h @@ -245,9 +245,6 @@ extern int dw_mci_resume(struct dw_mci *host); * @queue_node: List node for placing this node in the @queue list of * &struct dw_mci. * @clock: Clock rate configured by set_ios(). Protected by host->lock. - * @__clk_old: The last updated clock with reflecting clock divider. - * Keeping track of this helps us to avoid spamming the console - * with CONFIG_MMC_CLKGATE. * @flags: Random state bits associated with the slot. * @id: Number of this slot. * @sdio_id: Number of this slot in the SDIO interrupt registers. @@ -262,7 +259,6 @@ struct dw_mci_slot { struct list_head queue_node; unsigned int clock; - unsigned int __clk_old; unsigned long flags; #define DW_MMC_CARD_PRESENT 0