From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44195C7618E for ; Tue, 23 Jul 2019 09:06:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 18839227B6 for ; Tue, 23 Jul 2019 09:06:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="eYIcYKEH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 18839227B6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=DILl7WQ2mprOnaqcmIKeZ/sKi2hdnUsM7rHOWYpXURM=; b=eYIcYKEHZyGrdzIWvGapFbMze rCalqIAk0/zIC2A1tRP2pwrmDUJAJfE/bB+P/tPGLBaQfXBpS6Kw4bFS+zEd/yB+b+5WkQGkw+vGg ZlrMEI1HHYWavWpgEf376bZnxe4wEC0HG8O+hbeZRZDC/l0rYcmrQ9fsVepnztfDq0AShPiWnBxyi vHy3d0IQHIDrKoij6Ud28rczvcILo9gbY+iv6cyi/m4EBt7mR8SgHJjehonYtclPEOERdmeXo95VU 8PqsmSzGnD3GreTe8Zt5NdXuduKO021qAzcRZFrpOxLNuTevnh8mPKxbr0yb7zh6gc7z0wKNzZLI6 Qmcu5IENA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hpqjz-0001YU-MA; Tue, 23 Jul 2019 09:05:47 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hpqjv-0001Xx-1n for linux-arm-kernel@lists.infradead.org; Tue, 23 Jul 2019 09:05:44 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9ADA9344; Tue, 23 Jul 2019 02:05:39 -0700 (PDT) Received: from dawn-kernel.cambridge.arm.com (unknown [10.1.197.116]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8220D3F71F; Tue, 23 Jul 2019 02:05:38 -0700 (PDT) Subject: Re: [PATCH] coresight: etm4x: lazily allocate memory for save_state To: mathieu.poirier@linaro.org, andrew.murray@arm.com References: <20190711160114.634-6-andrew.murray@arm.com> <20190712150056.15775-1-andrew.murray@arm.com> From: Suzuki K Poulose Message-ID: <88f1e83b-8f16-a5bf-d68e-b840a4302f90@arm.com> Date: Tue, 23 Jul 2019 10:05:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190723_020543_180432_13988D16 X-CRM114-Status: GOOD ( 20.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, leo.yan@linaro.org, Sudeep.Holla@arm.com, linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 22/07/2019 21:32, Mathieu Poirier wrote: > Hi Andrew, > > Sorry for the late reply - you patch got lost under the pile. > > On Fri, 12 Jul 2019 at 09:01, Andrew Murray wrote: >> >> I had intended to lazily allocate memory for the save_state structure when >> it is first used. Following is a patch that I will squash into "[PATCH v3 5/6] >> coresight: etm4x: save/restore state across CPU low power states" on my >> next respin. I thought I'd share it here to get some feedback along with >> the rest of v3. >> >> Thanks, >> >> Andrew Murray >> >> --- >> drivers/hwtracing/coresight/coresight-etm4x.c | 14 +++++++++++--- >> drivers/hwtracing/coresight/coresight-etm4x.h | 2 +- >> 2 files changed, 12 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c >> index b0bd8158bf13..cd02372194bc 100644 >> --- a/drivers/hwtracing/coresight/coresight-etm4x.c >> +++ b/drivers/hwtracing/coresight/coresight-etm4x.c >> @@ -1112,6 +1112,13 @@ static int etm4_cpu_save(struct etmv4_drvdata *drvdata) >> struct etmv4_save_state *state; >> struct device *etm_dev = &drvdata->csdev->dev; >> >> + if (!drvdata->save_state) { >> + drvdata->save_state = devm_kmalloc(etm_dev, >> + sizeof(struct etmv4_save_state), GFP_KERNEL); > > GFP_KERNEL may sleep and will not work in the context where > etm4_cpu_save() is called. Thats right and it is not worth making this GFP_ATOMIC either. We could simply decide this at probe time or when the save_restore is modified dynamically via callbacks. Suzuki > > Thanks, > Mathieu > >> + if (!drvdata->save_state) >> + return -ENOMEM; >> + } >> + >> /* >> * As recommended by 3.4.1 ("The procedure when powering down the PE") >> * of ARM IHI 0064D >> @@ -1134,7 +1141,7 @@ static int etm4_cpu_save(struct etmv4_drvdata *drvdata) >> goto out; >> } >> >> - state = &drvdata->save_state; >> + state = drvdata->save_state; >> >> state->trcprgctlr = readl(drvdata->base + TRCPRGCTLR); >> state->trcprocselr = readl(drvdata->base + TRCPROCSELR); >> @@ -1234,9 +1241,10 @@ static int etm4_cpu_save(struct etmv4_drvdata *drvdata) >> static void etm4_cpu_restore(struct etmv4_drvdata *drvdata) >> { >> int i; >> - struct etmv4_save_state *state; >> + struct etmv4_save_state *state = drvdata->save_state; >> >> - state = &drvdata->save_state; >> + if (WARN_ON_ONCE(!state)) >> + return; >> >> CS_UNLOCK(drvdata->base); >> >> diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h >> index c31634c64f87..a70cafbbb8cf 100644 >> --- a/drivers/hwtracing/coresight/coresight-etm4x.h >> +++ b/drivers/hwtracing/coresight/coresight-etm4x.h >> @@ -441,7 +441,7 @@ struct etmv4_drvdata { >> bool atbtrig; >> bool lpoverride; >> struct etmv4_config config; >> - struct etmv4_save_state save_state; >> + struct etmv4_save_state *save_state; >> bool state_needs_restore; >> }; >> >> -- >> 2.21.0 >> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel