From patchwork Mon Jun 25 17:32:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10487079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ED9C46038C for ; Mon, 25 Jun 2018 17:32:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7CD92841D for ; Mon, 25 Jun 2018 17:32:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAE8A28592; Mon, 25 Jun 2018 17:32:51 +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 42B4E2841D for ; Mon, 25 Jun 2018 17:32:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6D6996E35A; Mon, 25 Jun 2018 17:32:50 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id EB4746E35A for ; Mon, 25 Jun 2018 17:32:45 +0000 (UTC) Received: by mail-wr0-x241.google.com with SMTP id p12-v6so12875166wrn.11 for ; Mon, 25 Jun 2018 10:32:45 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=XcJFCZqa35avLNJ9ZzbiOn63GHVE+FTQKl2VWVZut7g=; b=dx2kgrOSCYLcL5OhlEx+PReGFi2A+sH4nkfwAwPLFSAlbmCfxNEHcqwcyLy7KCPiEY DMy0/jPiy5v/NcpPFfBgtKEcP7VQtV29h9C/8h3Xq+h9eXK2PHoujVK7BDV1RJ61kxnd exlCV0PPZVyi2YYp+9IEAklgaiTRynRrj8RILjKQrzHV+w0wf9ENLQ1Kh5eo7urv7Qk1 8treYbemlAuQtn9XukdA5zdE10931Lk+kKzUAFHKLntwYBCSwHTU5wzm1y27XjRs4Mby S0LInyRv2MypMCalSK23RIlbqMV2z0RG0UXPhTuNld5Z24s3wx13n6WzbhmIE7evlb71 ClLg== X-Gm-Message-State: APt69E35wefU8ehaRKho5HAtgRxXUL9GRwGNIQd9uiK+otUAb9nmjJ1a 8Ev3RiaPXJaDh1YUFHScd7XsdP4p X-Google-Smtp-Source: AAOMgpfcaRW1XIJGc6dl5VJTb/PC4CYFF1nKW2YnJvhNkn21dlbfA+x2Sox9QoX6nYFpHo61C+v17w== X-Received: by 2002:adf:fc47:: with SMTP id e7-v6mr4151489wrs.157.1529947964358; Mon, 25 Jun 2018 10:32:44 -0700 (PDT) Received: from localhost.localdomain ([95.146.151.144]) by smtp.gmail.com with ESMTPSA id u16-v6sm3762148wrp.44.2018.06.25.10.32.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 10:32:43 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Mon, 25 Jun 2018 18:32:37 +0100 Message-Id: <20180625173237.7930-2-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180625173237.7930-1-tvrtko.ursulin@linux.intel.com> References: <20180625173237.7930-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC 2/2] 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 while intel_engine_notify tracepoint is enabled. We use tracepoint (de)registration callbacks to enable user interrupts on all devices (future proofing and avoiding ugly global pointers) and all engines. Premise is that if someone is listening, they want to see interrupts logged. Commit to be improved... Signed-off-by: Tvrtko Ursulin Cc: Chris Wilson --- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_drv.c | 2 + drivers/gpu/drm/i915/i915_drv.h | 2 + drivers/gpu/drm/i915/i915_trace.h | 50 ++++++++------- drivers/gpu/drm/i915/i915_tracing.c | 96 +++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_tracing.h | 13 ++++ 6 files changed, 141 insertions(+), 23 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 4c6adae23e18..ee082addd328 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -77,6 +77,7 @@ i915-y += i915_cmd_parser.o \ i915_request.o \ i915_timeline.o \ i915_trace_points.o \ + i915_tracing.o \ i915_vma.o \ intel_breadcrumbs.o \ intel_engine_cs.o \ diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 8a3ea18d8416..c634583baf57 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -1271,6 +1271,7 @@ static void i915_driver_register(struct drm_i915_private *dev_priv) INIT_LIST_HEAD(&dev_priv->driver_list_link); mutex_lock(&i915_driver_list_lock); list_add_tail(&dev_priv->driver_list_link, &i915_driver_list); + i915_tracing_register(dev_priv); mutex_unlock(&i915_driver_list_lock); } @@ -1285,6 +1286,7 @@ static void i915_driver_unregister(struct drm_i915_private *dev_priv) mutex_lock(&i915_driver_list_lock); list_del(&dev_priv->driver_list_link); + i915_tracing_unregister(dev_priv); mutex_unlock(&i915_driver_list_lock); /* diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 685bfdca3a72..4e3230713491 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2144,6 +2144,8 @@ struct drm_i915_private { struct list_head driver_list_link; + bool engine_notify_tracepoint; + /* * 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_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..a9f486278109 --- /dev/null +++ b/drivers/gpu/drm/i915/i915_tracing.c @@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright © 2018 Intel Corporation + * + */ + +#include "i915_tracing.h" + +#include "i915_drv.h" +#include "intel_ringbuffer.h" + +void i915_tracing_register(struct drm_i915_private *i915) +{ + struct intel_engine_cs *engine; + struct drm_i915_private *p; + enum intel_engine_id id; + bool enable = false; + + lockdep_assert_held(&i915_driver_list_lock); + + list_for_each_entry(p, &i915_driver_list, driver_list_link) { + enable = p->engine_notify_tracepoint; + if (enable) + break; + } + + if (!enable) + return; + + for_each_engine(engine, i915, id) + intel_engine_pin_breadcrumbs_irq(engine); + + i915->engine_notify_tracepoint = true; +} + +void i915_tracing_unregister(struct drm_i915_private *i915) +{ + struct intel_engine_cs *engine; + enum intel_engine_id id; + + lockdep_assert_held(&i915_driver_list_lock); + + if (!i915->engine_notify_tracepoint) + return; + + for_each_engine(engine, i915, id) + intel_engine_unpin_breadcrumbs_irq(engine); + + i915->engine_notify_tracepoint = false; +} + +int intel_engine_notify_tracepoint_register(void) +{ + struct drm_i915_private *i915; + + mutex_lock(&i915_driver_list_lock); + list_for_each_entry(i915, &i915_driver_list, driver_list_link) { + struct intel_engine_cs *engine; + enum intel_engine_id id; + + intel_runtime_pm_get(i915); + + for_each_engine(engine, i915, id) + intel_engine_pin_breadcrumbs_irq(engine); + + intel_runtime_pm_put(i915); + + GEM_BUG_ON(i915->engine_notify_tracepoint); + i915->engine_notify_tracepoint = true; + } + mutex_unlock(&i915_driver_list_lock); + + return 0; +} + +void intel_engine_notify_tracepoint_unregister(void) +{ + struct drm_i915_private *i915; + + mutex_lock(&i915_driver_list_lock); + list_for_each_entry(i915, &i915_driver_list, driver_list_link) { + struct intel_engine_cs *engine; + enum intel_engine_id id; + + intel_runtime_pm_get(i915); + + for_each_engine(engine, i915, id) + intel_engine_unpin_breadcrumbs_irq(engine); + + intel_runtime_pm_put(i915); + + GEM_BUG_ON(!i915->engine_notify_tracepoint); + i915->engine_notify_tracepoint = false; + } + mutex_unlock(&i915_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);