From patchwork Fri Jul 12 15:00:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Murray X-Patchwork-Id: 11042447 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7BEB9138B for ; Fri, 12 Jul 2019 15:02:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AA10285EC for ; Fri, 12 Jul 2019 15:02:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EA1A28C40; Fri, 12 Jul 2019 15:02:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 01365285EC for ; Fri, 12 Jul 2019 15:02:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qBUIjSGVRetjTuUyJK0ed9QI9kQsWO4S59Tnd05FAXw=; b=n722bhZ0l1PwLh V8H1swTPNzsTn+vl0OzZIXQ3HKqyelRab4x+6xCQqzZWbAzV9PJ4MGo3QOgBXXHG7PafjYe1t15js PiLeHaIeMwLbs3kjQL6jDVxpO4mKRZWjHe8G4A+iU4ABgFQEKmpPaapUuuBn4OD+laVdpzWr3QVdK uvnfS+U6iC92jjonPt2SXqkV3mQEUUwF/MG4Rvnubsid3d1o4ut/tYmf7LI3Rgr83x8gqznRz4n67 wNj22+3FlpBLbWnuEgSSi5GRIsoMcc88uPdEzao11cjJrhC1dMPbWXWn1la8rXds9oYE+pkJcLJoA 3pQc2B/IEoxJ+hFIdc0g==; 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 1hlx4C-0003Jj-Kd; Fri, 12 Jul 2019 15:02:32 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hlx2n-0002m2-5W for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2019 15:01:06 +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 792CD2B; Fri, 12 Jul 2019 08:01:04 -0700 (PDT) Received: from e119886-lin.cambridge.arm.com (unknown [10.37.6.20]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E76A33F59C; Fri, 12 Jul 2019 08:01:02 -0700 (PDT) From: Andrew Murray To: Mathieu Poirier , Suzuki K Poulose , Alexander Shishkin Subject: [PATCH] coresight: etm4x: lazily allocate memory for save_state Date: Fri, 12 Jul 2019 16:00:56 +0100 Message-Id: <20190712150056.15775-1-andrew.murray@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190711160114.634-6-andrew.murray@arm.com> References: <20190711160114.634-6-andrew.murray@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190712_080105_280069_19F2D73E X-CRM114-Status: GOOD ( 12.60 ) 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: coresight@lists.linaro.org, Sudeep Holla , Leo Yan , linux-arm-kernel@lists.infradead.org, Mike Leach 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 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); + 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; };