From patchwork Wed Apr 12 15:55:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 9677681 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 B0D2760383 for ; Wed, 12 Apr 2017 15:56:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A400F28592 for ; Wed, 12 Apr 2017 15:56:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98B4728627; Wed, 12 Apr 2017 15:56:31 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 1936A28592 for ; Wed, 12 Apr 2017 15:56:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E6DB89811; Wed, 12 Apr 2017 15:56:30 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 30E55897EF for ; Wed, 12 Apr 2017 15:56:29 +0000 (UTC) Received: by mail-pg0-x242.google.com with SMTP id 34so3293920pgx.3 for ; Wed, 12 Apr 2017 08:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=t9MfVNK11u2kosIOGkSa0OiVGYZw5Gtnf5YqqCoJvog=; b=NZwVeon2xjGJDoLOZmwNP5H0P3XglJkVKYdSDpK1ur6a4cDVQoxj7JujNIvwF75o42 SkVoeRhqClrI4vXk0sYvI9CX3IVNAzdRWscoxaG85fOigtk/CPUAZJjwKIoSNyEpxJu8 vkgN5Yt8UKaZowl/81Lh8luHkvtARusbuyWHKzy6cjvHfZkwPSD6vMUXZmh8ISJoS0wZ 3WEiJkTzf5+lUjjTs2QhWC66yleOkp65RPbJ7p/kwuZguWHrOHdCHnXif1l8KJBqeFG6 dQhO2TZbfZ/TCEs1v4oipo0pKVkiQHN/V0hJgMhL1/4N3B+PLD4T4cIS3AN3wjtm65uV /QnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=t9MfVNK11u2kosIOGkSa0OiVGYZw5Gtnf5YqqCoJvog=; b=WEgJ80C/Xj50vtZY+UjO0eSQaBT1G0v3Nijk4Z69On5xhcuEShrRoZEgXUGp9bhEQH p8VTFszu7jmnIxQZcwjHwKlWGCgFHOnAX9AIPNAdffN8tXnjiH1xizXIsjEFKrgy8ueu Bf8C3OnatuH2FBDp6KzmEywwxsNREg56NA5lvNXBgCgvkCVolYPApIUCcze/wG6uehjo YAjLPt8/HVNVPiFbXOS1gFTmEm+e/4Tizf6XooSgt/MvRnJmyBwC68i2SdSgDlv0Vf1h 28AGrdByIC8//8+TtnjoZGbhXMj/+svbx/9/P8xspqvpMEOmAcnHmL2qa8y/2wE9hNl7 ZTsw== X-Gm-Message-State: AFeK/H0jYg4LR425kmKPNz5w13DxwTXox/RZprkz5GkrBp16yzaeXAK/VO1DPS5qBVUPcQ== X-Received: by 10.98.105.134 with SMTP id e128mr66231556pfc.19.1492012588825; Wed, 12 Apr 2017 08:56:28 -0700 (PDT) Received: from sixbynine.org (host-78-151-16-127.as13285.net. [78.151.16.127]) by smtp.gmail.com with ESMTPSA id k2sm37505946pga.47.2017.04.12.08.56.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Apr 2017 08:56:28 -0700 (PDT) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Date: Wed, 12 Apr 2017 16:55:48 +0100 Message-Id: <20170412155556.6602-8-robert@sixbynine.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170412155556.6602-1-robert@sixbynine.org> References: <20170412155556.6602-1-robert@sixbynine.org> Subject: [Intel-gfx] [PATCH v4 07/15] drm/i915/perf: better pipeline aged/aging tail updates X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This updates the tail pointer race workaround handling to updating the 'aged' pointer before looking to start aging a new one. There's the possibility that there is already new data available and so we can immediately start aging a new pointer without having to first wait for a later hrtimer callback (and then another to age). Signed-off-by: Robert Bragg Reviewed-by: Matthew Auld --- drivers/gpu/drm/i915/i915_perf.c | 41 ++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index 08cc2b0dd734..5738b99caa5b 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -391,6 +391,29 @@ static bool gen7_oa_buffer_check_unlocked(struct drm_i915_private *dev_priv) now = ktime_get_mono_fast_ns(); + /* Update the aged tail + * + * Flip the tail pointer available for read()s once the aging tail is + * old enough to trust that the corresponding data will be visible to + * the CPU... + * + * Do this before updating the aging pointer in case we may be able to + * immediately start aging a new pointer too (if new data has become + * available) without needing to wait for a later hrtimer callback. + */ + if (aging_tail != INVALID_TAIL_PTR && + ((now - dev_priv->perf.oa.oa_buffer.aging_timestamp) > + OA_TAIL_MARGIN_NSEC)) { + aged_idx ^= 1; + dev_priv->perf.oa.oa_buffer.aged_tail_idx = aged_idx; + + aged_tail = aging_tail; + + /* Mark that we need a new pointer to start aging... */ + dev_priv->perf.oa.oa_buffer.tails[!aged_idx].offset = INVALID_TAIL_PTR; + aging_tail = INVALID_TAIL_PTR; + } + /* Update the aging tail * * We throttle aging tail updates until we have a new tail that @@ -420,24 +443,6 @@ static bool gen7_oa_buffer_check_unlocked(struct drm_i915_private *dev_priv) } } - /* Update the aged tail - * - * Flip the tail pointer available for read()s once the aging tail is - * old enough to trust that the corresponding data will be visible to - * the CPU... - */ - if (aging_tail != INVALID_TAIL_PTR && - ((now - dev_priv->perf.oa.oa_buffer.aging_timestamp) > - OA_TAIL_MARGIN_NSEC)) { - aged_idx ^= 1; - dev_priv->perf.oa.oa_buffer.aged_tail_idx = aged_idx; - - aged_tail = aging_tail; - - /* Mark that we need a new pointer to start aging... */ - dev_priv->perf.oa.oa_buffer.tails[!aged_idx].offset = INVALID_TAIL_PTR; - } - spin_unlock_irqrestore(&dev_priv->perf.oa.oa_buffer.ptr_lock, flags); return aged_tail == INVALID_TAIL_PTR ?