From patchwork Wed Aug 8 15:14:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10560163 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8DBC013BB for ; Wed, 8 Aug 2018 15:14:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B4AB2B07C for ; Wed, 8 Aug 2018 15:14:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F8F02B09D; Wed, 8 Aug 2018 15:14:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C7EAB2B07C for ; Wed, 8 Aug 2018 15:14:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5EB1A6E58D; Wed, 8 Aug 2018 15:14:34 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 43C8F6E58D for ; Wed, 8 Aug 2018 15:14:32 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id h15-v6so2341720wrs.7 for ; Wed, 08 Aug 2018 08:14:32 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=S7cF+YJTiWQOzgiirFi7UF7xiEhiJbf6+SwQKwtu9/E=; b=gEPo5OvJ2lAlBx4TEWOmUYVSwY8qs4KNgs1fms+1Dxk8D4huz3WAngKqCjsXm0dliE C/hRp0XNmgU1ybhli0BMMaNKngbO8kPC6IrIpzW2cb2DrSAI2SxjZZmSLqRrubaOKh48 pyPyCquZ99HH4czoXqoklUgArAyRoRmEppN1NmMqV5somcVde1zzI3n2MTselnuut6j6 l2bnXV4Ka/pQq8iwoQk7Q4HyLxWCdDUa0RaazXGqxeyakZXiycyBVP864pflUo/lNwCh eSjnl+Z/kxot+M/ExpADpjKVReUshZzG0PyJnZFdbgQMmGBqmJruUx5LNHKJsOxj1LCL QAxQ== X-Gm-Message-State: AOUpUlFN8Mb2u6OeD4wLsioxEMAd6whuP7MAg9LDGADJubQGCOjz5MYx Dxo5lGanDOuYxCBDFetb6e6TPlPFriI= X-Google-Smtp-Source: AA+uWPzvNpxGDEvdKX0iTuZJue7WiAjVDbU0Y7l7zdHmPpmwzyeubRQ5njLTS5LeMKzTTZ62R/WCBw== X-Received: by 2002:adf:d207:: with SMTP id g7-v6mr2220639wri.91.1533741270644; Wed, 08 Aug 2018 08:14:30 -0700 (PDT) Received: from localhost.localdomain ([95.146.151.245]) by smtp.gmail.com with ESMTPSA id z5-v6sm3121317wrv.2.2018.08.08.08.14.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Aug 2018 08:14:29 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Wed, 8 Aug 2018 16:14:24 +0100 Message-Id: <20180808151424.5183-1-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2] drm/i915/tracing: Enable user interrupts while intel_engine_notify is active X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 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" X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin Keep the user interrupt enabled and emit intel_engine_notify tracepoint every time as long as it is enabled. Premise is that if someone is listening, they want to see interrupts logged. We use tracepoint (de)registration callbacks to enable user interrupts on all devices (future proofing and avoiding ugly global pointers) and all engines. For this to work we also have to add another call site of trace_intel_engine_notify, notably to the early return from notify_ring otherwise we still depend on waiters being present. v2: * Improve makefile. (Chris Wilson) * Simplify by dropping the pointeless global driver list. (Chris Wilson) * Emit tracepoint when there are no waiters, not just the user interrupt. * Commit message tidy. Signed-off-by: Tvrtko Ursulin Cc: Chris Wilson Cc: Dmitry Rogozhkin Cc: John Harrison Cc: svetlana.kukanova@intel.com Reviewed-by: Chris Wilson --- drivers/gpu/drm/i915/Makefile | 3 + drivers/gpu/drm/i915/i915_drv.c | 5 ++ drivers/gpu/drm/i915/i915_drv.h | 2 + drivers/gpu/drm/i915/i915_irq.c | 4 +- drivers/gpu/drm/i915/i915_trace.h | 50 ++++++++------- drivers/gpu/drm/i915/i915_tracing.c | 98 +++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_tracing.h | 13 ++++ 7 files changed, 151 insertions(+), 24 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_tracing.c create mode 100644 drivers/gpu/drm/i915/i915_tracing.h diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 5794f102f9b8..dfc940b32078 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -182,6 +182,9 @@ i915-y += i915_perf.o \ i915_oa_cnl.o \ i915_oa_icl.o +# tracing +i915-$(CONFIG_TRACEPOINTS) += i915_tracing.o + ifeq ($(CONFIG_DRM_I915_GVT),y) i915-y += intel_gvt.o include $(src)/gvt/Makefile diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 9dce55182c3a..03e224ebc28c 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -1281,6 +1281,9 @@ static void i915_driver_register(struct drm_i915_private *dev_priv) */ if (INTEL_INFO(dev_priv)->num_pipes) drm_kms_helper_poll_init(dev); + + /* Notify our tracepoints driver has been registered. */ + i915_tracing_register(dev_priv); } /** @@ -1292,6 +1295,8 @@ static void i915_driver_unregister(struct drm_i915_private *dev_priv) intel_fbdev_unregister(dev_priv); intel_audio_deinit(dev_priv); + i915_tracing_unregister(dev_priv); + /* * After flushing the fbdev (incl. a late async config which will * have delayed queuing of a hotplug event), then flush the hotplug diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 0b10a30b7d96..a15f8be0ece0 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2141,6 +2141,8 @@ struct drm_i915_private { struct i915_pmu pmu; + struct list_head driver_list_link; + /* * NOTE: This is the dri1/ums dungeon, don't add stuff here. Your patch * will be rejected. Instead look for a better place. diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index 8084e35b25c5..8cba798b666d 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c @@ -1159,8 +1159,10 @@ static void notify_ring(struct intel_engine_cs *engine) struct task_struct *tsk = NULL; struct intel_wait *wait; - if (unlikely(!engine->breadcrumbs.irq_armed)) + if (unlikely(!engine->breadcrumbs.irq_armed)) { + trace_intel_engine_notify(engine, false); return; + } rcu_read_lock(); diff --git a/drivers/gpu/drm/i915/i915_trace.h b/drivers/gpu/drm/i915/i915_trace.h index c0352a1b036c..12555d2388fd 100644 --- a/drivers/gpu/drm/i915/i915_trace.h +++ b/drivers/gpu/drm/i915/i915_trace.h @@ -8,6 +8,7 @@ #include #include "i915_drv.h" +#include "i915_tracing.h" #include "intel_drv.h" #include "intel_ringbuffer.h" @@ -750,29 +751,32 @@ TRACE_EVENT(i915_request_out, __entry->global_seqno, __entry->completed) ); -TRACE_EVENT(intel_engine_notify, - TP_PROTO(struct intel_engine_cs *engine, bool waiters), - TP_ARGS(engine, waiters), - - TP_STRUCT__entry( - __field(u32, dev) - __field(u16, class) - __field(u16, instance) - __field(u32, seqno) - __field(bool, waiters) - ), - - TP_fast_assign( - __entry->dev = engine->i915->drm.primary->index; - __entry->class = engine->uabi_class; - __entry->instance = engine->instance; - __entry->seqno = intel_engine_get_seqno(engine); - __entry->waiters = waiters; - ), - - TP_printk("dev=%u, engine=%u:%u, seqno=%u, waiters=%u", - __entry->dev, __entry->class, __entry->instance, - __entry->seqno, __entry->waiters) +TRACE_EVENT_FN(intel_engine_notify, + TP_PROTO(struct intel_engine_cs *engine, bool waiters), + TP_ARGS(engine, waiters), + + TP_STRUCT__entry( + __field(u32, dev) + __field(u16, class) + __field(u16, instance) + __field(u32, seqno) + __field(bool, waiters) + ), + + TP_fast_assign( + __entry->dev = engine->i915->drm.primary->index; + __entry->class = engine->uabi_class; + __entry->instance = engine->instance; + __entry->seqno = intel_engine_get_seqno(engine); + __entry->waiters = waiters; + ), + + TP_printk("dev=%u, engine=%u:%u, seqno=%u, waiters=%u", + __entry->dev, __entry->class, __entry->instance, + __entry->seqno, __entry->waiters), + + intel_engine_notify_tracepoint_register, + intel_engine_notify_tracepoint_unregister ); DEFINE_EVENT(i915_request, i915_request_retire, diff --git a/drivers/gpu/drm/i915/i915_tracing.c b/drivers/gpu/drm/i915/i915_tracing.c new file mode 100644 index 000000000000..b7ca89fb61ce --- /dev/null +++ b/drivers/gpu/drm/i915/i915_tracing.c @@ -0,0 +1,98 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright © 2018 Intel Corporation + * + */ + +#include "i915_tracing.h" + +#include "i915_drv.h" +#include "intel_ringbuffer.h" + +static DEFINE_MUTEX(driver_list_lock); +static LIST_HEAD(driver_list); +static bool notify_enabled; + +static void __i915_enable_notify(struct drm_i915_private *i915) +{ + struct intel_engine_cs *engine; + enum intel_engine_id id; + + for_each_engine(engine, i915, id) + intel_engine_pin_breadcrumbs_irq(engine); +} + +static void __i915_disable_notify(struct drm_i915_private *i915) +{ + struct intel_engine_cs *engine; + enum intel_engine_id id; + + for_each_engine(engine, i915, id) + intel_engine_unpin_breadcrumbs_irq(engine); +} + +void i915_tracing_register(struct drm_i915_private *i915) +{ + INIT_LIST_HEAD(&i915->driver_list_link); + + mutex_lock(&driver_list_lock); + + list_add_tail(&i915->driver_list_link, &driver_list); + + if (notify_enabled) + __i915_enable_notify(i915); + + mutex_unlock(&driver_list_lock); +} + +void i915_tracing_unregister(struct drm_i915_private *i915) +{ + mutex_lock(&driver_list_lock); + + if (notify_enabled) + __i915_disable_notify(i915); + + list_del(&i915->driver_list_link); + + mutex_unlock(&driver_list_lock); +} + +int intel_engine_notify_tracepoint_register(void) +{ + struct drm_i915_private *i915; + + mutex_lock(&driver_list_lock); + + GEM_BUG_ON(notify_enabled); + + list_for_each_entry(i915, &driver_list, driver_list_link) { + intel_runtime_pm_get(i915); + __i915_enable_notify(i915); + intel_runtime_pm_put(i915); + } + + notify_enabled = true; + + mutex_unlock(&driver_list_lock); + + return 0; +} + +void intel_engine_notify_tracepoint_unregister(void) +{ + struct drm_i915_private *i915; + + mutex_lock(&driver_list_lock); + + GEM_BUG_ON(!notify_enabled); + + list_for_each_entry(i915, &driver_list, driver_list_link) { + intel_runtime_pm_get(i915); + __i915_disable_notify(i915); + intel_runtime_pm_put(i915); + } + + notify_enabled = false; + + mutex_unlock(&driver_list_lock); +} diff --git a/drivers/gpu/drm/i915/i915_tracing.h b/drivers/gpu/drm/i915/i915_tracing.h new file mode 100644 index 000000000000..f5ed92428ff1 --- /dev/null +++ b/drivers/gpu/drm/i915/i915_tracing.h @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright © 2018 Intel Corporation + * + */ + +#include "i915_drv.h" + +void i915_tracing_register(struct drm_i915_private *i915); +void i915_tracing_unregister(struct drm_i915_private *i915); + +int intel_engine_notify_tracepoint_register(void); +void intel_engine_notify_tracepoint_unregister(void);