From patchwork Fri Mar 6 23:22:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sylvain Rochet X-Patchwork-Id: 5958031 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 60F919F380 for ; Fri, 6 Mar 2015 23:26:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8E2742038D for ; Fri, 6 Mar 2015 23:26:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AEC1D20374 for ; Fri, 6 Mar 2015 23:26:18 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YU1a9-00073u-F6; Fri, 06 Mar 2015 23:23:01 +0000 Received: from mx-guillaumet.finsecur.com ([91.217.234.131] helo=guillaumet.finsecur.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YU1a3-0006yO-9Z for linux-arm-kernel@lists.infradead.org; Fri, 06 Mar 2015 23:22:56 +0000 Received: from [172.16.8.13] (helo=spice.lan) by guillaumet.finsecur.com with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1YU1ZY-000CGT-Hr; Sat, 07 Mar 2015 00:22:25 +0100 Received: from gradator by spice.lan with local (Exim 4.84) (envelope-from ) id 1YU1ZY-0002rJ-7s; Sat, 07 Mar 2015 00:22:24 +0100 Date: Sat, 7 Mar 2015 00:22:24 +0100 From: Sylvain Rochet To: Wenyou Yang Message-ID: <20150306232224.GA7475@gradator.net> References: <1423709123-8033-1-git-send-email-wenyou.yang@atmel.com> <1423709209-8108-1-git-send-email-wenyou.yang@atmel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1423709209-8108-1-git-send-email-wenyou.yang@atmel.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: 172.16.8.13 X-SA-Exim-Mail-From: sylvain.rochet@finsecur.com X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Subject: Re: [PATCH 2/6] pm: at91: move the copying the sram function to the sram initializationi phase X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on guillaumet.finsecur.com) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150306_152255_591091_00480C43 X-CRM114-Status: GOOD ( 13.17 ) X-Spam-Score: -0.7 (/) Cc: mark.rutland@arm.com, lorenzo.pieralisi@arm.com, linux@arm.linux.org.uk, sergei.shtylyov@cogentembedded.com, patrice.vilchez@atmel.com, nicolas.ferre@atmel.com, linux-kernel@vger.kernel.org, alexandre.belloni@free-electrons.com, linux@maxim.org.za, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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-Virus-Scanned: ClamAV using ClamSMTP Hello Wenyou, On Thu, Feb 12, 2015 at 10:46:49AM +0800, Wenyou Yang wrote: > To decrease the suspend time, move copying the sram function to the sram > initialization phase, instead of every time go to suspend. > > In the meanwhile, substitute fncpy() for memcpy(). > > If there is no sram allocated for PM, the PM is not supported. My board doesn't boot anymore with this change, I am not equipped enough to debug more, looks like fncpy() is writing the function on top of existing kernel code. You said you had issues with fncpy(), I guess I am having the issue you had. Moving the function copy from at91_pm_sram_init() to at91_pm_suspend() fixes the problem: -------------------------8<----------------------------------- -------------------------8<----------------------------------- It works and fixes the hard fault, but I have no clue why :( Sylvain diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 9d74c85..31339b0 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -155,6 +155,10 @@ static void at91_pm_suspend(suspend_state_t state) flush_cache_all(); outer_disable(); + /* Copy the pm suspend handler to SRAM */ + at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn, + &at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz); + at91_suspend_sram_fn(at91_pmc_base, at91_ramc_base[0], at91_ramc_base[1], pm_data); @@ -305,10 +309,6 @@ static void __init at91_pm_sram_init(void) pr_warn("SRAM: Could not map\n"); return; } - - /* Copy the pm suspend handler to SRAM */ - at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn, - &at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz); } static void __init at91_pm_init(void) -------------------------8<----------------------------------- Or using memcpy() instead of fncpy() also fixes the problem: -------------------------8<----------------------------------- diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 9d74c85..feab89a 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -307,8 +307,8 @@ static void __init at91_pm_sram_init(void) } /* Copy the pm suspend handler to SRAM */ - at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn, - &at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz); + memcpy(at91_suspend_sram_fn, at91_pm_suspend_in_sram, + at91_pm_suspend_in_sram_sz); } static void __init at91_pm_init(void)