Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3865615pxj; Mon, 21 Jun 2021 08:15:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4m8PCOWT+4HsknMe2CcGhhC/y5KVvIBTGDCHwiCs8qp7S2zd2i28L/kHArAW5TWyUjlAv X-Received: by 2002:a92:7312:: with SMTP id o18mr17752976ilc.289.1624288537296; Mon, 21 Jun 2021 08:15:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624288537; cv=none; d=google.com; s=arc-20160816; b=tZG6pxB88XVBPsGUg/5PFt/2gGpKgIcdzkGjGQjDUjM95e6Asw1SrKyalD0MUNJbra Vejov33dDvtPsJ86EGCv4z4+Iz2qElrb++E80yzkPaMRjbGWJ1dn1d/FGT98JQNdRjCN 9be7lmMsYG/ZjCEmAtlKZsJcYvE9C+ePUEKMClkXUroLG8t1zwFlGFgjanmk84NOuCYG fmxCkAaneTXkQSGPv4JHt7ruXk/uGjPwmA/rXUdn9IsUdL6cOLd1ifarCDerN/Si/Wz9 NVC2D3jY7Lv5WihytTGAFfJvSL/MGqvnZlegd2ILnv3p9F2blpIJKNSgqusEo+zYm9v2 /Shw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=lQ2UnEJg2XoLbnWEh9PAk9wcST3unahPRiH5iIxUMy4=; b=Z+/VeIgbx89pWcoBCb5oWBU8+rQN0R1Tx2OoCLPxuDmePwtZCCtfji8OojWGTsN4IB /IwkkH9TT6HcIkNHaHz8BEhMpOFq5NUyGeYNUeXpJ4rrSdMTS9xQTQ8eoZ3+BtT/m3pZ +FyQlmNPA1nPn/mIIVnVPB2IVCtgUXA4htoBldgsVT3ro4ENmS1xfRKYSGqW92a9kG1W eEOP1dOxYMhcJHbrDnM7iBmV3nvA1E75gZjU88l6cTo/um7CLyZ19llWxTHSPvCdBzsa IpiqF2XlWxA0AhCcsNXyyVbwdxpnfw3hV9klukqQbyjHI6LO3LPbVvPzxfQrYQLrgwmx EPfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q3si14364980ilu.88.2021.06.21.08.15.23; Mon, 21 Jun 2021 08:15:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230286AbhFUPPi (ORCPT + 99 others); Mon, 21 Jun 2021 11:15:38 -0400 Received: from mga04.intel.com ([192.55.52.120]:18882 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230205AbhFUPPd (ORCPT ); Mon, 21 Jun 2021 11:15:33 -0400 IronPort-SDR: vJJoj2OLbE3l9DdVVO7UjSQ36TwgeQboC4B/txZ96ToIApvtmLFzXGwF86wqWAdEwWwD22vD8m OdbphIvZUqxA== X-IronPort-AV: E=McAfee;i="6200,9189,10022"; a="205039530" X-IronPort-AV: E=Sophos;i="5.83,289,1616482800"; d="scan'208";a="205039530" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jun 2021 08:13:19 -0700 IronPort-SDR: L7o9korl2VAy9v1eakqZnTdNU8P+zOjLo7xbURphAr/LWUeB1gaysFYNVptf5ZvWEvcTM8Bl6l WhzVBC+iDiMQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,289,1616482800"; d="scan'208";a="486522888" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 21 Jun 2021 08:13:18 -0700 From: Alexander Shishkin To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Alexander Shishkin , Andy Shevchenko Subject: [PATCH 4/4] intel_th: Wait until port is in reset before programming it Date: Mon, 21 Jun 2021 18:12:46 +0300 Message-Id: <20210621151246.31891-5-alexander.shishkin@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210621151246.31891-1-alexander.shishkin@linux.intel.com> References: <20210621151246.31891-1-alexander.shishkin@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some devices don't drain their pipelines if we don't make sure that the corresponding output port is in reset before programming it for a new trace capture, resulting in bits of old trace appearing in the new trace capture. Fix that by explicitly making sure the reset is asserted before programming new trace capture. Signed-off-by: Alexander Shishkin Reviewed-by: Andy Shevchenko --- drivers/hwtracing/intel_th/core.c | 17 +++++++++++++++++ drivers/hwtracing/intel_th/gth.c | 16 ++++++++++++++++ drivers/hwtracing/intel_th/intel_th.h | 3 +++ 3 files changed, 36 insertions(+) diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c index 4bf025ef2031..66eed2dff818 100644 --- a/drivers/hwtracing/intel_th/core.c +++ b/drivers/hwtracing/intel_th/core.c @@ -217,6 +217,22 @@ static ssize_t port_show(struct device *dev, struct device_attribute *attr, static DEVICE_ATTR_RO(port); +static void intel_th_trace_prepare(struct intel_th_device *thdev) +{ + struct intel_th_device *hub = to_intel_th_hub(thdev); + struct intel_th_driver *hubdrv = to_intel_th_driver(hub->dev.driver); + + if (hub->type != INTEL_TH_SWITCH) + return; + + if (thdev->type != INTEL_TH_OUTPUT) + return; + + pm_runtime_get_sync(&thdev->dev); + hubdrv->prepare(hub, &thdev->output); + pm_runtime_put(&thdev->dev); +} + static int intel_th_output_activate(struct intel_th_device *thdev) { struct intel_th_driver *thdrv = @@ -237,6 +253,7 @@ static int intel_th_output_activate(struct intel_th_device *thdev) if (ret) goto fail_put; + intel_th_trace_prepare(thdev); if (thdrv->activate) ret = thdrv->activate(thdev); else diff --git a/drivers/hwtracing/intel_th/gth.c b/drivers/hwtracing/intel_th/gth.c index 28509b02a0b5..b3308934a687 100644 --- a/drivers/hwtracing/intel_th/gth.c +++ b/drivers/hwtracing/intel_th/gth.c @@ -564,6 +564,21 @@ static void gth_tscu_resync(struct gth_device *gth) iowrite32(reg, gth->base + REG_TSCU_TSUCTRL); } +static void intel_th_gth_prepare(struct intel_th_device *thdev, + struct intel_th_output *output) +{ + struct gth_device *gth = dev_get_drvdata(&thdev->dev); + int count; + + /* + * Wait until the output port is in reset before we start + * programming it. + */ + for (count = GTH_PLE_WAITLOOP_DEPTH; + count && !(gth_output_get(gth, output->port) & BIT(5)); count--) + cpu_relax(); +} + /** * intel_th_gth_enable() - enable tracing to an output device * @thdev: GTH device @@ -815,6 +830,7 @@ static struct intel_th_driver intel_th_gth_driver = { .assign = intel_th_gth_assign, .unassign = intel_th_gth_unassign, .set_output = intel_th_gth_set_output, + .prepare = intel_th_gth_prepare, .enable = intel_th_gth_enable, .trig_switch = intel_th_gth_switch, .disable = intel_th_gth_disable, diff --git a/drivers/hwtracing/intel_th/intel_th.h b/drivers/hwtracing/intel_th/intel_th.h index 89c67e0e1d34..0ffb42990175 100644 --- a/drivers/hwtracing/intel_th/intel_th.h +++ b/drivers/hwtracing/intel_th/intel_th.h @@ -143,6 +143,7 @@ intel_th_output_assigned(struct intel_th_device *thdev) * @remove: remove method * @assign: match a given output type device against available outputs * @unassign: deassociate an output type device from an output port + * @prepare: prepare output port for tracing * @enable: enable tracing for a given output device * @disable: disable tracing for a given output device * @irq: interrupt callback @@ -164,6 +165,8 @@ struct intel_th_driver { struct intel_th_device *othdev); void (*unassign)(struct intel_th_device *thdev, struct intel_th_device *othdev); + void (*prepare)(struct intel_th_device *thdev, + struct intel_th_output *output); void (*enable)(struct intel_th_device *thdev, struct intel_th_output *output); void (*trig_switch)(struct intel_th_device *thdev, -- 2.30.2