From patchwork Thu Apr 25 19:52:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 162879 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2363543jan; Thu, 25 Apr 2019 12:54:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfb5u0TYOcUuLm3+MjqQOq0lSgrEQh2MQ2ROJWHSs8Q/HRkcsFEUvbwF9kXof2yt8MIp9h X-Received: by 2002:aa7:8458:: with SMTP id r24mr23408773pfn.231.1556222095645; Thu, 25 Apr 2019 12:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556222095; cv=none; d=google.com; s=arc-20160816; b=dpLR4Rv0kvd8BW0iyapk/xSxHCj67ssMyFOkTk5IplZcKjY/4o6HVjbp9B2Eh4fk6R 8PwQZ7zRr6N4Q0SRAHDx+QYZ5e7Um5l16QPlqjIBX7t+AilFTjqxxvMqokHqtQ/UtdbG NUwvBTa3qO+yl2tA4IWb314M8NK50OGiEHakboofJlybfvMCVjUfV4oU/GHuaSVrTvSU b7TWnpiAV6HWmPo8UzxSt04llieEPyVxRegYhMef3LT38k5pDv7UIZGUoAtKdIfi62DB UFfDAVHHED114fMhdBI4tnjRPUdl4P81ygWZdMRUjtu/ebAc8ar6Nnu+9vUOaA1No4gw 8vZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=uoxZQ+Jw0MNrOb10y+jglav9yUL3Ht92euc8TGFiAfY=; b=V0cHZteckdDpW9kBHgiT9VE7SSMsbq7HgMfAXZbC8MIMslwcEJ6gNtyBOdAXMlIi8o IBkXhk7fxabO/z4zVgQ0covIfXjdRO4q9BMccJ4f8mxCUCSxCjXE7rW99ZqiZ5gJsmT7 Sp+CmBhSnGHsOqCyNKk0RJyao83BjJVDPbzQG98o0ILtOYu7/Z6WkH+0flWsbthFwDrH UtcgiWyW+4StQSYQWBEYMOyNQFwuxHM31xJx5q7yDB+uMylQ+mKQ1nKBwu5CHL+Vs4la ebUjhTO76fyKEopS8WEgDzFQ+omHGzQJUaWObD6dOUIwe5eyLsw+4M3zDyawtzPehWBJ aZJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c+R6u6VD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z8si21320639pgp.185.2019.04.25.12.54.55; Thu, 25 Apr 2019 12:54:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c+R6u6VD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730881AbfDYTyy (ORCPT + 30 others); Thu, 25 Apr 2019 15:54:54 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:38723 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730585AbfDYTxk (ORCPT ); Thu, 25 Apr 2019 15:53:40 -0400 Received: by mail-pl1-f194.google.com with SMTP id f36so312023plb.5 for ; Thu, 25 Apr 2019 12:53:40 -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=uoxZQ+Jw0MNrOb10y+jglav9yUL3Ht92euc8TGFiAfY=; b=c+R6u6VDZOax4bq1uwh/NLDMM6m8tM8xqP8r64W8X1lp3bNVvCoo3j784NsFMYuRK8 wQiISQfhGH+zQAYIu5bx5DDmkzIfCHMgvSt1hjXZKikIOUQ27Oylh9CiA3lqGBL05Eun nymJF+ihWa3/lUaXGLQoe/jkC26Jc8wBc9Hbsf39ztAu54e51BXz37ZfmbIw3ra25kTn r2I6GM9zkM9shPk7xQB/+AjTSzr+KMSOc6vq6YwnBry5JL9l4L7z9chblP0o79x1zznN 0Ir3X9fQuT3JLCP4w6EVkjv8wznm1URh+6wAZknmv0agRc4MwnXUHYfDKCUbfWKrPph6 xpxQ== 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=uoxZQ+Jw0MNrOb10y+jglav9yUL3Ht92euc8TGFiAfY=; b=RARNtULNeNIGpsKhAVQGrFmx0waxEabszC6tSgN0e0xCMngUljxoUQtRD6HA8b3xKp VN1MTAdFbSWSlOZJ05TrLwBv3OFb2y7UiUKZKTooBoTN9yVTvgp4rf894frhmKDn5O3h JnN5cDgyaxkfj583+fSTQuOYA6xtKBwpx3LH/kcOF8z1DvaTttmvbIyiPzVE++oKlWCo QdSaESZW00lPZskJF02GK4AVfzYUyKn0qxoZk7VQ6de+t+qvSX1cjRjuRNgErAbHM0Ie GlUXW465uQi8ZkDhcsA0tcARzTKPK2St964Se+w4FeqW/Zcr1AlLEN0/xRtW2C7UKOdX UJQQ== X-Gm-Message-State: APjAAAWRcTXP60ykk4HJ/Rh4yDtGL1bkltQLX4MMTQRz2KNTIKvwyW88 wY7fdGbGrM8nmwGAlBUBE877yg== X-Received: by 2002:a17:902:56e:: with SMTP id 101mr40689884plf.142.1556222019835; Thu, 25 Apr 2019 12:53:39 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id t64sm47261961pfa.86.2019.04.25.12.53.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Apr 2019 12:53:39 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 21/32] coresight: perf: Clean up function etm_setup_aux() Date: Thu, 25 Apr 2019 13:52:59 -0600 Message-Id: <20190425195310.31562-22-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190425195310.31562-1-mathieu.poirier@linaro.org> References: <20190425195310.31562-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Tested-by: Leo Yan Tested-by: Robert Walker --- drivers/hwtracing/coresight/coresight-etm-perf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.17.1 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,