From patchwork Thu Oct 19 18:27:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umesh Nerlige Ramappa X-Patchwork-Id: 13429641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 82063CDB465 for ; Thu, 19 Oct 2023 18:27:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C7A5A10E533; Thu, 19 Oct 2023 18:27:23 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id AC35910E533 for ; Thu, 19 Oct 2023 18:27:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697740041; x=1729276041; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=vsjFJqoY/w2pzqPl92Ce8/HrMNxJZAA/vzsllBqoONM=; b=fuMBAhoJ/vcN6pBp2OO3tLfhnjgl9qimmdp1I6M1+4oJLRuhIgpreg9T RffCbFJTkvZ7iLb4Wx3fokJc/Eg7UmaGqsn/jnmShHTb9TliLwDvJNHLo dSM8ioSdR9SBI7ajS4b/wzWhyN4FbhbmqLEHJpG1UF2/ihJc/FJOuTvJ6 KAuWpo6r31FDCyZBeS6rEeOPW2zxBKGg/Cx6xhDmD1Mtey2zsWGdB7AQV 8c/Kcxd7WDu3bnYGpMQ7JVcDfLuUTYojQDkiG+eAFazyV95+Yacm+b1dI dRUoLkoKMkNmO9d0Jv10nA/mwTT80jFrez1ssVX1hpxFDNosao+3T6pQi w==; X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="450556252" X-IronPort-AV: E=Sophos;i="6.03,238,1694761200"; d="scan'208";a="450556252" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 11:27:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="880784114" X-IronPort-AV: E=Sophos;i="6.03,238,1694761200"; d="scan'208";a="880784114" Received: from unerlige-desk.jf.intel.com ([10.165.21.199]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 11:27:21 -0700 From: Umesh Nerlige Ramappa To: intel-gfx@lists.freedesktop.org Date: Thu, 19 Oct 2023 11:27:20 -0700 Message-Id: <20231019182720.3742536-1-umesh.nerlige.ramappa@intel.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH] drm/i915/pmu: Check is pmu is closed before stopping event X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" When the driver unbinds, pmu is unregistered and i915->uabi_engines is set to RB_ROOT. Due to this, when i915 PMU tries to stop the engine events, it issues a warn_on because engine lookup fails. All perf hooks are taking care of this using a pmu->closed flag that is set when PMU unregisters. The stop event seems to have been left out. Check for pmu->closed in pmu_event_stop as well. Based on discussion here - https://patchwork.freedesktop.org/patch/492079/?series=105790&rev=2 Signed-off-by: Umesh Nerlige Ramappa --- drivers/gpu/drm/i915/i915_pmu.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c index 108b675088ba..f861863eb7c1 100644 --- a/drivers/gpu/drm/i915/i915_pmu.c +++ b/drivers/gpu/drm/i915/i915_pmu.c @@ -831,9 +831,18 @@ static void i915_pmu_event_start(struct perf_event *event, int flags) static void i915_pmu_event_stop(struct perf_event *event, int flags) { + struct drm_i915_private *i915 = + container_of(event->pmu, typeof(*i915), pmu.base); + struct i915_pmu *pmu = &i915->pmu; + + if (pmu->closed) + goto out; + if (flags & PERF_EF_UPDATE) i915_pmu_event_read(event); i915_pmu_disable(event); + +out: event->hw.state = PERF_HES_STOPPED; }