From patchwork Tue Jun 28 16:56:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Gordon X-Patchwork-Id: 9203643 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 F21BC6074E for ; Tue, 28 Jun 2016 16:56:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCC09285DF for ; Tue, 28 Jun 2016 16:56:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0AC62860E; Tue, 28 Jun 2016 16:56:33 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66C4B285DF for ; Tue, 28 Jun 2016 16:56:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B064C6E043; Tue, 28 Jun 2016 16:56:30 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id B11B06E043 for ; Tue, 28 Jun 2016 16:56:28 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 28 Jun 2016 09:56:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,542,1459839600"; d="scan'208";a="726345057" Received: from dsgordon-linux2.isw.intel.com ([10.102.226.88]) by FMSMGA003.fm.intel.com with ESMTP; 28 Jun 2016 09:56:27 -0700 From: Dave Gordon To: intel-gfx@lists.freedesktop.org Date: Tue, 28 Jun 2016 17:56:07 +0100 Message-Id: <1467132967-19751-1-git-send-email-david.s.gordon@intel.com> X-Mailer: git-send-email 1.9.1 Organization: Intel Corporation (UK) Ltd. - Co. Reg. #1134945 - Pipers Way, Swindon SN3 1RJ In-Reply-To: 5772A02B.9010604@linux.intel.com Subject: [Intel-gfx] [RFC] drm/i915: hybrid wait-for macro 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 Part spin-wait, part sleep-wait. Plus one example of where it might be used. Signed-off-by: Dave Gordon --- drivers/gpu/drm/i915/i915_guc_submission.c | 2 +- drivers/gpu/drm/i915/intel_drv.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c index 355b647..ff99910 100644 --- a/drivers/gpu/drm/i915/i915_guc_submission.c +++ b/drivers/gpu/drm/i915/i915_guc_submission.c @@ -98,7 +98,7 @@ static int host2guc_action(struct intel_guc *guc, u32 *data, u32 len) I915_WRITE(HOST2GUC_INTERRUPT, HOST2GUC_TRIGGER); /* No HOST2GUC command should take longer than 10ms */ - ret = wait_for_atomic(host2guc_action_response(dev_priv, &status), 10); + ret = wait_for_hybrid(host2guc_action_response(dev_priv, &status), 10, 10); if (status != GUC2HOST_STATUS_SUCCESS) { /* * Either the GuC explicitly returned an error (which diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 3156d8d..096e07c 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -103,6 +103,16 @@ #define wait_for_atomic(COND, MS) _wait_for_atomic((COND), (MS) * 1000) #define wait_for_atomic_us(COND, US) _wait_for_atomic((COND), (US)) +/* Hybrid wait: + * first spin-wait for up to microseconds, + * if still not true, sleep-wait for MS milliseconds + */ +#define wait_for_hybrid(COND, US, MS) ({ \ + int ret__ = wait_for_atomic_us(COND, US); \ + if (ret__) ret__ = wait_for(COND, MS); \ + ret__; \ + }) + #define KHz(x) (1000 * (x)) #define MHz(x) KHz(1000 * (x))