Received: by 10.192.165.148 with SMTP id m20csp150050imm; Wed, 9 May 2018 10:13:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrp7gnhi6Ox1rxLYzCGnQiqpsYpI5aNdT8R5wFuIgBHZX916BucAV4bdTMP714TLQCTDNCt X-Received: by 2002:a17:902:7896:: with SMTP id q22-v6mr46995603pll.243.1525886030977; Wed, 09 May 2018 10:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525886030; cv=none; d=google.com; s=arc-20160816; b=TagBi5kNHZm+n7cd1euxZGKYe1nLuYisWEUjNSWEdEbT0he3x0rMmzN741iLAdbMSO vNEqc4JY4yHG6FEic8AvhH8PkwuFtASVGCspbLpWccuNPM2Hma0TikRAXKOA/LM+ZD5f 8JfBTbHB+h/ORpCABhOh/kWIvcYUGhr2nQkH+NdxpW7V1I/kHppUXObSP3vdM2MApCY3 sLJLyYnLRvGEj05+Nl789eDREI6JsPTGAy7gtGWQgxLR3D3un96abC1AC79gHMRRKUYp kISD0+LyuWKhmAIG03h+7wvqPJcbo9Fkg0bbr1Jinb45Aug/yZhZMS0PlnatS1sRPbk5 qCmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=XGigL53J8+kS8APleE0up28EsFdxiBHXtILEa4il73c=; b=M4bJCFf5ko6Me+AU8FVpMttMLe04Wi09swa7WqDP/MUuKGQuF0zpbGMgb+Drj9Jfch vywGoGSLj7RHus4bYfXv9Q6XS2yOQd1Cu3sJNjpFgX9DSt634jg3uBETr9utf0L2GNt1 2jEIBhKkhZzsPMIe91/0cvJGNozbeLE5Y+fR9v6e/cvGt+yHOx0OwAw9KBLc7IvRJJTv PIVHtSBjkqifInAzX7GzPrl+ung1QbNu6MU6pOb9E7KG2EABlvCvc+4ehAHUCMaXkaWQ mjL5SyEvpXqy79/EpU+65vCROvq+DmxL+ngWaX68SlZm/fMvA7XmWEQb9Y+nLjsLGhVD rkFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E1D/SA68; 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 q3si28246379pfg.298.2018.05.09.10.13.35; Wed, 09 May 2018 10:13:50 -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=E1D/SA68; 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 S965728AbeEIRNC (ORCPT + 99 others); Wed, 9 May 2018 13:13:02 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:55858 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965594AbeEIRNB (ORCPT ); Wed, 9 May 2018 13:13:01 -0400 Received: by mail-wm0-f65.google.com with SMTP id a8so26114818wmg.5 for ; Wed, 09 May 2018 10:13:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=XGigL53J8+kS8APleE0up28EsFdxiBHXtILEa4il73c=; b=E1D/SA68gV2TS8n7orL2Gzi5QUHeaQyxJcYVqeD3a0qxRlqxYaaFFcg7U4panxKG4S ROeYTKuTBOrWedTA/AXKgOzVpf0Wnkh7z4VbtbPjPDP7XQl0S+Z8eYC2qrDpxLl4PgHD ZXv+CNatfDYEf1XauuPYcv/WxB1E/M7z0j72A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=XGigL53J8+kS8APleE0up28EsFdxiBHXtILEa4il73c=; b=VIXPoIOCNcRSwqjB3MTQcBSNt0YY8Sbv8X296H1oz4J55yfKeSZIewvSRP5I24Z3L8 Bwsyvx2Qqs3asRvHzDVhgGFcqyyYihGlSHpG9XZflvuTI7EabtmFhJGNoV8daOs5K/Jq 8g6r4U0nonv5XWQRPsdhCfaVp59+oOKRyElZsdPwMa+HbN1aa5DRtV9MOmipSMuoIBUV 8oG8HoZDHpOELvfueKD5TpOpB4kN7sWNHxx4cHTACA25gveWvMxpQ1J+ZHPMn6VVa2Sy siEv7NLy7o9kkiE5H8XpwoPuKo2QdYvd97jAdEy1OmJqa0NIEPGL4RPqJH4I+nio91t7 wfLA== X-Gm-Message-State: ALKqPwcFXBg87p6DV51zQDRlsiKskDooVMA/HZjqSlbSKfTRibIlWugc d8KtSy2b70kLmSi0rgu8Hpa3NxsqIjBkPQHQlvT/SA== X-Received: by 2002:a50:ec16:: with SMTP id g22-v6mr6861442edr.242.1525885979823; Wed, 09 May 2018 10:12:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.80.164.161 with HTTP; Wed, 9 May 2018 10:12:59 -0700 (PDT) In-Reply-To: References: <1525165857-11096-1-git-send-email-suzuki.poulose@arm.com> <1525165857-11096-24-git-send-email-suzuki.poulose@arm.com> <20180508171800.GA3389@xps15> From: Mathieu Poirier Date: Wed, 9 May 2018 11:12:59 -0600 Message-ID: Subject: Re: [PATCH v2 23/27] coresight: tmc-etr: Handle driver mode specific ETR buffers To: Suzuki K Poulose Cc: linux-arm-kernel , linux-kernel@vger.kernel.org, Mike Leach , Robert Walker , Mark Rutland , Will Deacon , Robin Murphy , Sudeep Holla , Frank Rowand , Rob Herring , John Horley Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8 May 2018 at 15:51, Suzuki K Poulose wrote: > On 05/08/2018 06:18 PM, Mathieu Poirier wrote: >> >> On Tue, May 01, 2018 at 10:10:53AM +0100, Suzuki K Poulose wrote: >>> >>> Since the ETR could be driven either by SYSFS or by perf, it >>> becomes complicated how we deal with the buffers used for each >>> of these modes. The ETR driver cannot simply free the current >>> attached buffer without knowing the provider (i.e, sysfs vs perf). >>> >>> To solve this issue, we provide: >>> 1) the driver-mode specific etr buffer to be retained in the drvdata >>> 2) the etr_buf for a session should be passed on when enabling the >>> hardware, which will be stored in drvdata->etr_buf. This will be >>> replaced (not free'd) as soon as the hardware is disabled, after >>> necessary sync operation. >>> >>> The advantages of this are : >>> >>> 1) The common code path doesn't need to worry about how to dispose >>> an existing buffer, if it is about to start a new session with a >>> different buffer, possibly in a different mode. >>> 2) The driver mode can control its buffers and can get access to the >>> saved session even when the hardware is operating in a different >>> mode. (e.g, we can still access a trace buffer from a sysfs mode >>> even if the etr is now used in perf mode, without disrupting the >>> current session.) >>> >>> Towards this, we introduce a sysfs specific data which will hold the >>> etr_buf used for sysfs mode of operation, controlled solely by the >>> sysfs mode handling code. >> >> >> Thinking further on this... I toyed with the idea of doing the same thing >> when >> working on the original driver and decided against it. Do we really have >> a case >> where users would want to use sysFS and perf alternatively? To me this >> looks >> overdesigned. >> >> If we are going to go that way we need to enact the same behavior for >> ETB10 and >> ETF... And take it out of this set as it is already substantial enough. > > > The difference between ETB10/ETF and ETR is the usage of the buffer. The > former uses an internal buffer and we always have to copy it out to an > external buffer for consumption. Now this external buffer is actually > separate for each mode, i.e sysfs and perf. Also the data is copied > out right after we disable the HW. This ensures that the interleaved > mode doesn't corrupt each others data. Hi Suzuki, When I wrote my original comment I was under the impression that ETB10/ETF's drvdata->buf was used for both sysFS and perf, but after going back to the code find it isn't the case. As such a user can call sysFS and perf session alternately without destroying the results acquired from the previous trace scenario. This is also what your patch is providing, enacting the same (desired) behaviour we currently have. I'm good with this one. Mathieu > > However, the ETR doesn't have an internal buffer and uses the System RAM. > That brings in the problem of one mode using the "buffer" as > described by the drvdata. So, eventually either mode could write to > the buffer allocated by the other mode before it is consumed by the > end user (via syfs read or perf). That brings in the challenge of > managing the buffer safely, switching back and forth the buffer > (with the right size and pages) for each mode without any interferences. > That also implies, one mode must be able to free the left-over buffer > from the previous mode safely (which could be potentially linked to > other data structures maintained by the mode). And that makes it more > complex. e.g, we must leave the sysfs trace data for collection and > meanwhile the perf could grab the ETR for its usage. The perf mode > might not know the mode of the existing buffer and thus wouldn't know > how to free it properly. > > This is why we need buffers per mode which can be managed by > each mode. i.e, both allocated, used and more importantly free'd > appropriately. > > Cheers > Suzuki