From patchwork Thu Apr 4 03:35:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 10884815 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 1410817E1 for ; Thu, 4 Apr 2019 03:37:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED00828A1D for ; Thu, 4 Apr 2019 03:37:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E10142847D; Thu, 4 Apr 2019 03:37:29 +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 8364F28A1D for ; Thu, 4 Apr 2019 03:37:29 +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=tN3yWdXhMcjmgC0S/9XSnVdLIa hREqrGb/OjZj8W/l+YqNsJsAo9zqfzvr5nCUp3ovQ+RSy4N0HqpVR0x+Di+LKVbggb8dW2/LyyGIk 0lp7NyKDd/wa6BfxEgsZyWDqbLWg3x+40U4nZvPNDfRY91inxSCq5tduWoTUMaRBEI1p0ZpMiPg0d 69F1VXytfl9ufE6nWjOUPguNKxIVTOda+yf2XkJm2j3F+zqpT1sbOagaRjxnJA5SWU2OajgAO5zrc WZCLhAOohSEf7tLII024i4fcxvErovp1khvHU+i3/PlxegtvtTYBC9bqnRkhk0CA+PRyN7y7vzGVD aKwwF0+w==; 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 1hBtBo-0004b1-S1; Thu, 04 Apr 2019 03:37:20 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hBtAs-0003Ng-Du for linux-arm-kernel@lists.infradead.org; Thu, 04 Apr 2019 03:36:59 +0000 Received: by mail-pl1-x643.google.com with SMTP id g37so438569plb.5 for ; Wed, 03 Apr 2019 20:36:22 -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=gdec1QIXZeSLFtCBGpLGPuiGmrxIPSimppb5U9XDlVghC5LgWVcBP9Mfa1xbFdUOOa l1phJ6Y5zBrTHa1fsbSTWLx0aEUcvu+5wuDUvJsKjAQpPDubxp7PS5AckgUnZoy8ZdFr b9akJJhz8tIkZZYpFAKr/D1chofAiyvy2oQrMZzAJ/LLLPYi/6Q229+vkpgY55rW/qbg hFRkQ38/Y9VIQHBOanauk/GszRrMZEkZqKroxY37IkekTpk/BuKy2/ypZ5RjlVgtT74e XW2uePefexh0xccalxM9sn8/l2Qyjwidmxlq1V6meE53dP6Y5ghM3LNtY/7HVREco18R g0Fw== 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=eRP2qgmfmVttAcc4JiO4pSJjduw7bM4WehPdUU5ehdyb4O3J1t8+jd3f4F7h6vkkmC 7oiHjyLVXDdJkzvx8/F6iyr1MpCYt0WzordHCcRpSZcOSYJ0is4NHYzLeECM5+enFTy+ jsT24U4w7Lc3EyrKTIaOSJtLvT2WkF2LUsRz3cUNsQDNWVwOrMoX8Fvoj6mx1AZ0LgX/ cc1+f31r5WTonlwDHghXf4x5Ri5/PyI58M4KtUXA5tngzQxfzfl1YZIxRBAc+f5nOX66 m1nKTyH7xm8A58ycgifmvNl1atxqTDKKrVhCyH+Xe005FvnNR6Re+ufLDZDKKaBCA2cz CMpQ== X-Gm-Message-State: APjAAAUo2SxtM6mOd7Trk5d3csx5vWOCyJgJbFV3OZn+x37mJ2oKibAa TpYMRmUBBGvnRdVP71Jd//VVnVNTf74= X-Google-Smtp-Source: APXvYqxO8ppGN6tZd2HsirjKkIj0LBnPgYXjxD+xI+d/d1vo7t+3KzwBxUeYsaMXrG6VS3UeDb09Qg== X-Received: by 2002:a17:902:f01:: with SMTP id 1mr3828458ply.41.1554348981813; Wed, 03 Apr 2019 20:36:21 -0700 (PDT) Received: from xps15.imgcgcw.net ([147.50.13.10]) by smtp.gmail.com with ESMTPSA id u5sm12212780pfm.121.2019.04.03.20.36.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 20:36:21 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 09/20] coresight: perf: Clean up function etm_setup_aux() Date: Wed, 3 Apr 2019 21:35:30 -0600 Message-Id: <20190404033541.14072-10-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190404033541.14072-1-mathieu.poirier@linaro.org> References: <20190404033541.14072-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190403_203622_773308_A62F9ACC X-CRM114-Status: GOOD ( 13.47 ) 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, linux-kernel@vger.kernel.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,