Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1151251pxv; Fri, 9 Jul 2021 19:39:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgc8DsbakdvilvqpwRW2g9/VbpDIrmL2FnSepNtZ1KxeGfjCzDUcIlQ/8rozJ9rGPlNW+5 X-Received: by 2002:a05:6638:372c:: with SMTP id k44mr34349247jav.94.1625884773964; Fri, 09 Jul 2021 19:39:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884773; cv=none; d=google.com; s=arc-20160816; b=CqoPytvBFzrdOOQ7NLfd1Unvwt1Y5d9hSnYGX8zF9Jq5zN6X12L8W9L4u5lpKkiWwv fZuC1ndpFnElqITyDTE9jOXUoOHpUAqOiPjdjx+gjQztnrv/cvInbohD9DuEiHVVAJlI ZMaz+IeoInOE7+xUTC6ONg0LIAus+bX59ch2L10VEKqMsREnggVXqjl+BR7cSRAEm28K X3iqo2rVSxQP66dJOc/TFObxDf01cCeG6+PS3ofDd8pGTFem48CYxn/D9MQWPhkDcDVb ABmmIPiapd9n6p7tWyAUggOQs+g4eIANGL4vgyxXqAec2Cty88usaRrS3fRxJP3Usrbl uGCA== 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 :dkim-signature; bh=tb67vRoxI1H4ffGdTRvEKZCTHxVAAJfkGeUWYSWhQJk=; b=I7wuQmr7KYd1rM1s6oszwL+YzN9+BXh4KFqcZ2jV5iZ89yxitxYjO+EU0T4CINKgjk JElBSqx87xBF1WR9/MByh56iplZFsB+Xi4uTWGSDdqvRcNfOl6r/DhkQDlw0jwTKO73O grprH7FEZFs1CUMAt/B7StWMgB5/bq45IouulIAGj0L+cXDtLRfvt3vwkgfZcUK5DxP2 k5kca+WDQqm3UQV3khZbQTdVICRPx7H46pE8IKR5DphF577+xzietyBGKDvQsf4LJotv 7vs64EgCwAObK0b1BgIuluKepFMnJlT4XN3jmmnJXSZgbSCf6wifcbROU3PhbgKTgbXl Hf4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eM4QbE5b; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i13si9442631ilm.45.2021.07.09.19.39.21; Fri, 09 Jul 2021 19:39:33 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eM4QbE5b; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235134AbhGJClk (ORCPT + 99 others); Fri, 9 Jul 2021 22:41:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:58376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234939AbhGJCjS (ORCPT ); Fri, 9 Jul 2021 22:39:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1CF21613F0; Sat, 10 Jul 2021 02:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625884511; bh=2QCULv9p+xhuZlMgmpNdPAxorT09YE+Tc2bsB/nS4qw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eM4QbE5bDi7IQ4qmFXnurxU8zQFp9ISXUppBqX/q/rqAkQyqSEGxEjE/+ETGVIXAM 1kSwiu38heWWnocJv06BiOvqwbgJ5Tm7nyvgRTyCUQ4b+vALe0Ha1nB/bRsuKg64pf 0mRrZPphTneyPMB9ymreDUjatpIadkhDSOGt0Ae2MpwdUjlp/JQpslt3XhwsPslGS9 QLou4Y6Z3bed9oK6BNJKiASRduQa1fD5VcDL2pnBAQKNN3QNPSoYjCMbN9IcuJ0yGJ tJI1dWgfKbr9EU4RmM2f54VHMbdCW2mE6ahPjF4RJYSr0TUms95KmCDst1N9/J6dci 8pqewbmM6Lkng== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alexander Shishkin , Andy Shevchenko , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 4.19 37/39] intel_th: Wait until port is in reset before programming it Date: Fri, 9 Jul 2021 22:32:02 -0400 Message-Id: <20210710023204.3171428-37-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710023204.3171428-1-sashal@kernel.org> References: <20210710023204.3171428-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Shishkin [ Upstream commit ab1afed701d2db7eb35c1a2526a29067a38e93d1 ] 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. Reviewed-by: Andy Shevchenko Signed-off-by: Alexander Shishkin Link: https://lore.kernel.org/r/20210621151246.31891-5-alexander.shishkin@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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 6c723b57dfc0..be2f02e35067 100644 --- a/drivers/hwtracing/intel_th/core.c +++ b/drivers/hwtracing/intel_th/core.c @@ -215,6 +215,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 = @@ -235,6 +251,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 5041fe7fee9e..ef2751556fd7 100644 --- a/drivers/hwtracing/intel_th/gth.c +++ b/drivers/hwtracing/intel_th/gth.c @@ -513,6 +513,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 @@ -734,6 +749,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, .disable = intel_th_gth_disable, .driver = { diff --git a/drivers/hwtracing/intel_th/intel_th.h b/drivers/hwtracing/intel_th/intel_th.h index 780206dc9012..6b5473f3c16f 100644 --- a/drivers/hwtracing/intel_th/intel_th.h +++ b/drivers/hwtracing/intel_th/intel_th.h @@ -134,6 +134,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 @@ -155,6 +156,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 (*disable)(struct intel_th_device *thdev, -- 2.30.2