From patchwork Thu Apr 10 19:22:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Porter X-Patchwork-Id: 28242 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f200.google.com (mail-yk0-f200.google.com [209.85.160.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8F82C212DC for ; Thu, 10 Apr 2014 19:22:42 +0000 (UTC) Received: by mail-yk0-f200.google.com with SMTP id q9sf8616078ykb.7 for ; Thu, 10 Apr 2014 12:22:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=Fnk/MDZLV6N7GYUr7hoHNK4Sf0FfWR0xUfa4LDRwZcc=; b=MQT54BhudJ9GCg+UClHvV5YHgNFojiNSuu8WF831R0iTRRwJERZOpHrvHn2IXyb741 8Xo6jKFdMX+EnTJS/VT48asOvf0ckuW6q2IoOebB9wh7/9E1oH45ZgwpEe2x8EwwaWpm Fyng1SNRtYKHcaLoOcpk2wgobZ7pN0ItA343hS3Xh+N28bjYBslLzAu5wNfF6VVcxCOA arndZSjg1PPYDRY3PCF+ZNPTepRRWAAqzNQBZTxtvrkKOD96J/wcTLb7oRswYlWA0gDG +eAHe0vicF2Lxi4iBKmundMfcTvfJbKhSnz6oQ2MUQLOZaLeDunwuy3KrVUHFfXPhJ56 4Mcg== X-Gm-Message-State: ALoCoQnrG28eBeQN+7+u5+1NTCTqW6XPUnixhCqmoGDyMPds81DAcplDUycq4UMbu1hpsPts92im X-Received: by 10.58.199.170 with SMTP id jl10mr9228498vec.1.1397157762186; Thu, 10 Apr 2014 12:22:42 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.17.3 with SMTP id 3ls1302971qgc.83.gmail; Thu, 10 Apr 2014 12:22:42 -0700 (PDT) X-Received: by 10.52.108.164 with SMTP id hl4mr2736272vdb.25.1397157762017; Thu, 10 Apr 2014 12:22:42 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id ui2si861278vdc.82.2014.04.10.12.22.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Apr 2014 12:22:42 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id jw12so3961847veb.27 for ; Thu, 10 Apr 2014 12:22:41 -0700 (PDT) X-Received: by 10.220.190.197 with SMTP id dj5mr4705391vcb.19.1397157761931; Thu, 10 Apr 2014 12:22:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp85292vcb; Thu, 10 Apr 2014 12:22:41 -0700 (PDT) X-Received: by 10.68.135.42 with SMTP id pp10mr21970227pbb.58.1397157761192; Thu, 10 Apr 2014 12:22:41 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tx1si2739824pbc.322.2014.04.10.12.22.36; Thu, 10 Apr 2014 12:22:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758953AbaDJTW0 (ORCPT + 27 others); Thu, 10 Apr 2014 15:22:26 -0400 Received: from mail-ie0-f170.google.com ([209.85.223.170]:39820 "EHLO mail-ie0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753327AbaDJTWY (ORCPT ); Thu, 10 Apr 2014 15:22:24 -0400 Received: by mail-ie0-f170.google.com with SMTP id rd18so4414453iec.15 for ; Thu, 10 Apr 2014 12:22:23 -0700 (PDT) X-Received: by 10.42.27.136 with SMTP id j8mr3415066icc.69.1397157743727; Thu, 10 Apr 2014 12:22:23 -0700 (PDT) Received: from beef.ohporter.com (cpe-98-27-254-98.neo.res.rr.com. [98.27.254.98]) by mx.google.com with ESMTPSA id j2sm21672614igx.13.2014.04.10.12.22.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Apr 2014 12:22:22 -0700 (PDT) From: Matt Porter To: Lubomir Rintel Cc: Arnd Bergmann , Herbert Xu , Matt Mackall , Paul Gortmaker , Greg Kroah-Hartman , Linux Kernel Mailing List Subject: [PATCH] hwrng: bcm2835: fix oops when rng h/w is accessed during registration Date: Thu, 10 Apr 2014 15:22:10 -0400 Message-Id: <1397157730-31161-1-git-send-email-mporter@linaro.org> X-Mailer: git-send-email 1.8.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mporter@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Commit "d9e7972 hwrng: add randomness to system from rng sources" exposed a bug in the bcm2835-rng driver resulting in boot failure on Raspberry Pi due to the following oops: [ 28.261523] BUG: soft lockup - CPU#0 stuck for 23s! [swapper:1] [ 28.271058] [ 28.275958] CPU: 0 PID: 1 Comm: swapper Not tainted 3.14.0+ #11 [ 28.285374] task: db480000 ti: db484000 task.ti: db484000 [ 28.294279] PC is at bcm2835_rng_read+0x28/0x48 [ 28.302276] LR is at hwrng_register+0x1a8/0x238 . . . The RNG h/w is not completely initialized and enabled before hwrng_register() is called and so the bcm2835_rng_read() fails. Fix this by making the warmup/enable writes before registering the RNG source with the hwrng core. Signed-off-by: Matt Porter --- drivers/char/hw_random/bcm2835-rng.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c index 8c3b255..e900961 100644 --- a/drivers/char/hw_random/bcm2835-rng.c +++ b/drivers/char/hw_random/bcm2835-rng.c @@ -61,18 +61,18 @@ static int bcm2835_rng_probe(struct platform_device *pdev) } bcm2835_rng_ops.priv = (unsigned long)rng_base; + /* set warm-up count & enable */ + __raw_writel(RNG_WARMUP_COUNT, rng_base + RNG_STATUS); + __raw_writel(RNG_RBGEN, rng_base + RNG_CTRL); + /* register driver */ err = hwrng_register(&bcm2835_rng_ops); if (err) { dev_err(dev, "hwrng registration failed\n"); iounmap(rng_base); - } else { + } else dev_info(dev, "hwrng registered\n"); - /* set warm-up count & enable */ - __raw_writel(RNG_WARMUP_COUNT, rng_base + RNG_STATUS); - __raw_writel(RNG_RBGEN, rng_base + RNG_CTRL); - } return err; }