From patchwork Mon Mar 25 21:56:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 10870097 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 0EF411708 for ; Mon, 25 Mar 2019 21:58:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAA7F28B59 for ; Mon, 25 Mar 2019 21:58:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF37629131; Mon, 25 Mar 2019 21:58:14 +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 8080B28B59 for ; Mon, 25 Mar 2019 21:58:14 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=Xd8z+1w8+J/M7x2NqYiQ8ANmMvdXd/V3EMUsasWvBDw=; b=W1TAd86gCeIg1WQ8jdOyKtZmxo AReoKN3FFvizaXGlJATn3ZOg96gu2esXrbEwAyuss9huMxqVLlNHyOjAUo3fWyA3J9QINA9gunSCG PCHoFpWy06lvlYYXcjHqYMoXTEflQu6g5sJoRtZ2zXcbHj11JuTlTDM3Qi7U22g/LofZlfM8BR6ju 8WyhkHNpX1X7NGTIESArz4e55RaugwV9ONXhK6EMp3TEiJaYwhgqiAAe2AGu0PNG1CvhEQOCCTnlC Qm12jlUBVYvmHyy2FXwc9atD5ORhRPIpfR9sCUKhkvZKbpFKj/M5H0FmBDx2Ixc3WjrPvoByHfF+b TcHyu2oQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8XbZ-0005V7-OD; Mon, 25 Mar 2019 21:58:05 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8XaK-0003qz-EG for linux-arm-kernel@lists.infradead.org; Mon, 25 Mar 2019 21:56:54 +0000 Received: by mail-pg1-x542.google.com with SMTP id r124so7224982pgr.3 for ; Mon, 25 Mar 2019 14:56:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Rs0Mz9KrYOZgcBXADVGIV6b2w07we0qLU/jBgiUTV9k=; b=Ackc5N/WiULsAIVnlswx5k+iQLXQJFeHsNGEF37EMv6qjWA5Me3ogeHQvs9rndkKlh I5Yly06s0HPAkAgptxJgg2tAnG7sd9flK0SuJCP1wTkObDduPW7o7FM18NojhyIdKd/n 9uhqIa6He6EST8ZJ26jYGSuuTqyrNGnzLtzf2B+75HPHhBZPwTbjaI3qW+se34yF9z6y H2qtKThWfw2qAm2iWWjwpGqkOyYjenPBUxnhqqzLxf1l/FAjMPGpPaIdFUYvastyMz5A 1zxnlP5tB2BcdcdQnbtfqwmZUvqe2uelBML/umt8tklM1IF2cthz5GhZ8U6wxrWeQzcQ pmJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Rs0Mz9KrYOZgcBXADVGIV6b2w07we0qLU/jBgiUTV9k=; b=XKVSxPPrZ49P+Xx6iyuJltxXDB2IaR7e9R18ISUnK9uj9HOoabUD3P7oPHyD7a8ygO KrUMuTf3ONntBEhCbNvHv1NCn53Pc9VNyILyGEIT9IXCnlrve4rR95ohsvI2+XSlTrzi 0OXzNr06iTJQfnKenMbRkabm8DBYUlkTWxzR59m+m4hyl9oZru2xfYKu1wI7Z/gEKDpF jQHGAxFg5Ot+7yNCOIXh0lN2u0icTzABbcYNeJO60NUw3eqRPw3LUIfbbt9vFPJrHR2k ea5lV7n8ifwcUJyIq4/IfJAmelHEbmijiA64i0cLZxk9v2uyehVcxsKSPKTjOwBV2zbj jewg== X-Gm-Message-State: APjAAAVhcdoBYjqEImPElL3uqU78d4Udt4PkTYm/c8VPYwfSELt4uVxL FEz9xISVts94omqtrAcOKAZTejuCxEo= X-Google-Smtp-Source: APXvYqz3t+LLQ/yvW/eTzhXETYxGsQIY8WnRmmToLKFI5XMr82T+C+8ny7tAHDb8nKwhwfGQK+qEtQ== X-Received: by 2002:a63:ed4f:: with SMTP id m15mr3505951pgk.387.1553551004774; Mon, 25 Mar 2019 14:56:44 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id j20sm30645631pfi.27.2019.03.25.14.56.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Mar 2019 14:56:44 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 08/16] coresight: perf: Clean up function etm_setup_aux() Date: Mon, 25 Mar 2019 15:56:24 -0600 Message-Id: <20190325215632.17013-9-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190325215632.17013-1-mathieu.poirier@linaro.org> References: <20190325215632.17013-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190325_145648_668512_722C6785 X-CRM114-Status: GOOD ( 13.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: suzuki.poulose@arm.com, alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, peterz@infradead.org, mike.leach@arm.com, leo.yan@linaro.org MIME-Version: 1.0 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 There is no point in allocating sink memory for a trace session if there is not a way to free it once it is no longer needed. As such make sure the sink API function to allocate and free memory have been implemented before moving ahead with the establishment of a trace session. Signed-off-by: Mathieu Poirier Reviewed-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-etm-perf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index bbfed70b3402..b8ca3800b56b 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -134,8 +134,7 @@ static void free_event_data(struct work_struct *work) if (event_data->snk_config && !WARN_ON(cpumask_empty(mask))) { cpu = cpumask_first(mask); sink = coresight_get_sink(etm_event_cpu_path(event_data, cpu)); - if (sink_ops(sink)->free_buffer) - sink_ops(sink)->free_buffer(event_data->snk_config); + sink_ops(sink)->free_buffer(event_data->snk_config); } for_each_cpu(cpu, mask) { @@ -215,7 +214,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, sink = coresight_get_enabled_sink(true); } - if (!sink || !sink_ops(sink)->alloc_buffer) + if (!sink) goto err; mask = &event_data->mask; @@ -261,6 +260,9 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, if (cpu >= nr_cpu_ids) goto err; + if (!sink_ops(sink)->alloc_buffer || !sink_ops(sink)->free_buffer) + goto err; + /* Allocate the sink buffer for this session */ event_data->snk_config = sink_ops(sink)->alloc_buffer(sink, cpu, pages,