From patchwork Thu Aug 8 19:19:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Daudt X-Patchwork-Id: 2841350 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CF9CC9F295 for ; Thu, 8 Aug 2013 19:20:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 01D6B20290 for ; Thu, 8 Aug 2013 19:20:54 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 26CF020276 for ; Thu, 8 Aug 2013 19:20:49 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7Vl7-0000W9-IX; Thu, 08 Aug 2013 19:20:29 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7Vl5-0007L1-8H; Thu, 08 Aug 2013 19:20:27 +0000 Received: from mms1.broadcom.com ([216.31.210.17]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7Vl2-0007K0-Lp for linux-arm-kernel@lists.infradead.org; Thu, 08 Aug 2013 19:20:25 +0000 Received: from [10.9.208.57] by mms1.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Thu, 08 Aug 2013 12:16:05 -0700 X-Server-Uuid: 06151B78-6688-425E-9DE2-57CB27892261 Received: from IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.1.438.0; Thu, 8 Aug 2013 12:19:56 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) with Microsoft SMTP Server id 14.1.438.0; Thu, 8 Aug 2013 12:19:56 -0700 Received: from mothra.ric.broadcom.com (test-csd10.ric.broadcom.com [10.136.18.149]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 7F4C6F2D78; Thu, 8 Aug 2013 12:19:55 -0700 (PDT) From: "Christian Daudt" To: "Christian Daudt" Subject: [PATCH] ARM: bcm: Make secure API call optional Date: Thu, 8 Aug 2013 12:19:54 -0700 Message-ID: <1375989594-12193-1-git-send-email-csd@broadcom.com> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 X-WSS-ID: 7E1D31FF31W82352161-01-01 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130808_152024_916706_593BF0D1 X-CRM114-Status: GOOD ( 15.18 ) X-Spam-Score: -4.2 (----) Cc: Russell King , Arnd Bergmann , linux-kernel@vger.kernel.org, Markus Mayer , Olof Johansson , Stephen Warren , Shawn Guo , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The current bcm_kona_smc_init function throws a BUG_ON if there's no SMC device node defined in the device tree. Since secure API access is optional depending the chip configuration, fix this by allowing the rest of the code to run even if there's no SMC device node defined Reviewed-by: Markus Mayer Signed-off-by: Christian Daudt diff --git a/arch/arm/mach-bcm/bcm_kona_smc.c b/arch/arm/mach-bcm/bcm_kona_smc.c index 56d9d19..e32c1b3 100644 --- a/arch/arm/mach-bcm/bcm_kona_smc.c +++ b/arch/arm/mach-bcm/bcm_kona_smc.c @@ -41,13 +41,14 @@ static const struct of_device_id bcm_kona_smc_ids[] __initconst = { }; /* Map in the bounce area */ -void __init bcm_kona_smc_init(void) +int __init bcm_kona_smc_init(void) { struct device_node *node; /* Read buffer addr and size from the device tree node */ node = of_find_matching_node(NULL, bcm_kona_smc_ids); - BUG_ON(!node); + if (!node) + return -ENODEV; /* Don't care about size or flags of the DT node */ bridge_data.buffer_addr = @@ -59,7 +60,9 @@ void __init bcm_kona_smc_init(void) bridge_data.initialized = 1; - pr_info("Secure API initialized!\n"); + pr_info("Kona Secure API initialized\n"); + + return 0; } /* __bcm_kona_smc() should only run on CPU 0, with pre-emption disabled */ diff --git a/arch/arm/mach-bcm/bcm_kona_smc.h b/arch/arm/mach-bcm/bcm_kona_smc.h index 3bedbed1..d098a7e 100644 --- a/arch/arm/mach-bcm/bcm_kona_smc.h +++ b/arch/arm/mach-bcm/bcm_kona_smc.h @@ -64,7 +64,7 @@ #define SSAPI_BRCM_START_VC_CORE 0x0E000008 #ifndef __ASSEMBLY__ -extern void bcm_kona_smc_init(void); +extern int __init bcm_kona_smc_init(void); extern unsigned bcm_kona_smc(unsigned service_id, unsigned arg0, diff --git a/arch/arm/mach-bcm/board_bcm.c b/arch/arm/mach-bcm/board_bcm.c index 2859932..70cc44f 100644 --- a/arch/arm/mach-bcm/board_bcm.c +++ b/arch/arm/mach-bcm/board_bcm.c @@ -29,15 +29,18 @@ static int __init kona_l2_cache_init(void) if (!IS_ENABLED(CONFIG_CACHE_L2X0)) return 0; + if (bcm_kona_smc_init() < 0) { + pr_info("Kona secure API not available. Skipping L2 init\n"); + return 0; + } + bcm_kona_smc(SSAPI_ENABLE_L2_CACHE, 0, 0, 0, 0); /* * The aux_val and aux_mask have no effect since L2 cache is already * enabled. Pass 0s for aux_val and 1s for aux_mask for default value. */ - l2x0_of_init(0, ~0); - - return 0; + return l2x0_of_init(0, ~0); } static void __init board_init(void) @@ -45,8 +48,6 @@ static void __init board_init(void) of_platform_populate(NULL, of_default_bus_match_table, NULL, &platform_bus); - bcm_kona_smc_init(); - kona_l2_cache_init(); }