From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755484AbbCFXWf (ORCPT ); Fri, 6 Mar 2015 18:22:35 -0500 Received: from mx-guillaumet.finsecur.com ([91.217.234.131]:41003 "EHLO guillaumet.finsecur.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754159AbbCFXWe (ORCPT ); Fri, 6 Mar 2015 18:22:34 -0500 Date: Sat, 7 Mar 2015 00:22:24 +0100 From: Sylvain Rochet To: Wenyou Yang Cc: nicolas.ferre@atmel.com, linux@maxim.org.za, linux@arm.linux.org.uk, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, alexandre.belloni@free-electrons.com, patrice.vilchez@atmel.com, sergei.shtylyov@cogentembedded.com, mark.rutland@arm.com, lorenzo.pieralisi@arm.com 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-Type: text/plain; charset=utf-8 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 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) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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<----------------------------------- 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) -------------------------8<----------------------------------- It works and fixes the hard fault, but I have no clue why :( Sylvain