From patchwork Thu Apr 4 03:35:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 161734 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1087557jan; Wed, 3 Apr 2019 20:36:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyW7Y7Vb6MzEwpPsCicHwcRYlhIgnnqxxiavAqnVsKxoQhp5HjEv8uZjJQzxLLWG2/zq2du X-Received: by 2002:aa7:914d:: with SMTP id 13mr3318283pfi.149.1554349008732; Wed, 03 Apr 2019 20:36:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554349008; cv=none; d=google.com; s=arc-20160816; b=Hoa5TLKgogvE7o7rnO+0as25aaVrwyyVt3xHxBaIb+MRaJxdT+JQh1ogplg6ntC3yI 8F5sIuti6HTEauTeMaVwnTL9Pheb0JbnMemsacroJOyuhy4I3dPv3B7rfT5AQOrZCVr1 qPbBfU2wfMNLoEdKDuEZU2Ng9NREsGqjIt8oRdvqx+p9UC2xPTfPkCTdy1miDnblR/Nh RJxfKlx3sz/Lkr86ySkYH96cq9+TxbucZ8afY/p+lNfOIRCvg6xiV64BzsNOCKjdelKQ DZ2213lP+J1b0axW2wKopxtdXFHwDHJBvpBratxFvbZeS32N/WSnzuFzGl3Cgcp1oUZ0 wJ2g== 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=H9+OTr1OpfrOYtthYPTeqD/UZckEAYj6DoPWjl6ycEY=; b=Dp1wcS7BSvcDgzosSclk+Ot0aGbG/OsP2uVNL1iDGlb1cv/NJQew/NzKyw7rRcZJox RwNQxHmjEXhd0SdHJCq/ei/cW2Syc+RzLFlFxTuYebXtiaThYnsQ2/wRUvhloUO5tZSl 1Hkma79NaRikqbeixaQjLUHI+HoyvtyWJS4D9nAbSSgfLc91Ti1fJiRk/ixNWQmakYzi OwaOzboXs17cQn5lrWa2LEHzZ4T0J7oZufkYJVCfq3Five1jqYwqGxihMovKjw+uTtxb ba9TG4O/8AFHAdk+NhseE9G10Vpj/k8mn1pLf8xdNGo3p2BOO4wRGrFJv0buQkt1fAyn RTpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K68wBhJE; 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 z31si15750482plb.333.2019.04.03.20.36.48; Wed, 03 Apr 2019 20:36:48 -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=K68wBhJE; 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 S1728688AbfDDDgr (ORCPT + 31 others); Wed, 3 Apr 2019 23:36:47 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:36615 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728671AbfDDDgo (ORCPT ); Wed, 3 Apr 2019 23:36:44 -0400 Received: by mail-pl1-f196.google.com with SMTP id ck15so445031plb.3 for ; Wed, 03 Apr 2019 20:36:44 -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=H9+OTr1OpfrOYtthYPTeqD/UZckEAYj6DoPWjl6ycEY=; b=K68wBhJEME7fnO0jZ2eonmNB3GuHTmOF7iCsl8xEsvaPBFjiqFF+5Nx8BZrytnDPl4 3ozNLTYUVmxGm8C7sKWtJhEIGbZhe66ILZqt6EtA7ZjECx29SvjbtRXGGqJ442bA5G1w BwhJWUbLlnX6r0ICNZfbFN2SPI2NnE78gkpzd1kUmAMVCzEynsjygMDbu3t32CV0Yl2H bTtaXq5um59sufHwsYirJ5SP4nC6Nsmgm5IgRzCjRTgVy3dQiF1qWGETfMRMC27MqUmr 2Xfz3DXGVArX2qERcU4h3xJCG9AmO1yGqUOAqw+rkQLkVf7xlMbf2lP2pMlBrUIjk2tK izsQ== 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=H9+OTr1OpfrOYtthYPTeqD/UZckEAYj6DoPWjl6ycEY=; b=I3pxA0U7Cf2jlbfN9ykQUiwxZvLDJS9JFJMeebHzSgRvG0NzSeNy4c+/41KwTiCsiH Ll08ihj6h8kY+mROnKzm9iQFJtMlrII0WhnTXWef9xqNAlGiWiXdCQ8q8jI+2xiXnKhP QR+6p+wOWx0Dh8QN4FRTeVa4Z36RKysOmNtbfOoffvoWvwJg+sHNouOytS0+DhgntRkS MlqvxLKImj9vq5uRz7TqB52M6pZ7YGbBfFfxofo6Y10nYFTg4KWOtEOFjzrATpoXs80d Yv1v6qNM3+mlR1wNj+e8pbfJJNvgJVzTDRI7ywRrb4f4nJw7wWb6v8B66yoaeuUGzMgt gdDQ== X-Gm-Message-State: APjAAAX54eWntwVQy7xBykH0aMyJlz81g7VoDAdiFtZpk0B6nVYnhHUX SgWFQPrggfsD0/T3weNGdxqToA== X-Received: by 2002:a17:902:3283:: with SMTP id z3mr3762736plb.236.1554349003815; Wed, 03 Apr 2019 20:36:43 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 20:36:43 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Cc: alexander.shishkin@linux.intel.com, peterz@infradead.org, suzuki.poulose@arm.com, mike.leach@arm.com, leo.yan@linaro.org, coresight@lists.linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 15/20] coresight: tmc-etr: Introduce the notion of reference counting to ETR devices Date: Wed, 3 Apr 2019 21:35:36 -0600 Message-Id: <20190404033541.14072-16-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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds reference counting to struct etr_buf so that, in CPU-wide trace scenarios, shared buffers can be disposed of when no longer used. Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-tmc-etr.c | 5 +++++ drivers/hwtracing/coresight/coresight-tmc.h | 3 +++ 2 files changed, 8 insertions(+) -- 2.17.1 diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index e1774d4bb5f3..1346474ac019 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -1221,7 +1222,11 @@ get_perf_etr_buf_per_thread(struct tmc_drvdata *drvdata, * with memory allocation. */ etr_buf = alloc_etr_buf(drvdata, event, nr_pages, pages, snapshot); + if (IS_ERR(etr_buf)) + goto out; + refcount_set(&etr_buf->refcount, 1); +out: return etr_buf; } diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracing/coresight/coresight-tmc.h index 487c53701e9c..ee44906dffe8 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.h +++ b/drivers/hwtracing/coresight/coresight-tmc.h @@ -9,6 +9,7 @@ #include #include +#include #define TMC_RSZ 0x004 #define TMC_STS 0x00c @@ -133,6 +134,7 @@ struct etr_buf_operations; /** * struct etr_buf - Details of the buffer used by ETR + * refcount ; Number of sources currently using this etr_buf. * @mode : Mode of the ETR buffer, contiguous, Scatter Gather etc. * @full : Trace data overflow * @size : Size of the buffer. @@ -143,6 +145,7 @@ struct etr_buf_operations; * @private : Backend specific information for the buf */ struct etr_buf { + refcount_t refcount; enum etr_mode mode; bool full; ssize_t size;