From patchwork Thu Jul 10 21:54:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oded Gabbay X-Patchwork-Id: 4528851 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EDD2A9F37C for ; Thu, 10 Jul 2014 23:34:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2C73B201DE for ; Thu, 10 Jul 2014 23:34:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6B9D6201B4 for ; Thu, 10 Jul 2014 23:34:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2FAF56E7D1; Thu, 10 Jul 2014 16:33:30 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-we0-f175.google.com (mail-we0-f175.google.com [74.125.82.175]) by gabe.freedesktop.org (Postfix) with ESMTP id A1BC76E163 for ; Thu, 10 Jul 2014 14:56:51 -0700 (PDT) Received: by mail-we0-f175.google.com with SMTP id k48so204985wev.34 for ; Thu, 10 Jul 2014 14:56:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Mzw612zPFPjRpeKVcU+6DVPJxaeKpQO/iQSLHb8WBjg=; b=DUbjJDmm8aW6WfKp20BZJ+7HGDHJ1Y6dnMKzjRGnwrdX/PivXFpY5ZNkk9z3+SChz+ t4jSPfyC2qoAiJQyYMuWxuzHrQNEEhG9LeWwEYCpnaen2hDNqEDqG6/TAJ0u/224c5XL aIG1xPh9GPWgAlW1LejmfYffdUNpBEfFPbwKsztyPOJct+PuFj6HLwEK34xyISPF1QQ4 88LI+l/VmBWnHvz2Zf9OF7YT691ljQDTsiaVtQSOy04SoCfA/8Em3Aso14Xgsg8u1CQG RMv3qz45ZMvJ6ZyKPo93ywh5E0e48DjNb79qFiW5UPRP8ib2+2NKIH8bRquWFQ78bVOg ALgw== X-Received: by 10.180.88.194 with SMTP id bi2mr140611wib.71.1405029410713; Thu, 10 Jul 2014 14:56:50 -0700 (PDT) Received: from localhost.localdomain ([77.127.59.49]) by mx.google.com with ESMTPSA id pq9sm831097wjc.35.2014.07.10.14.56.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Jul 2014 14:56:50 -0700 (PDT) From: Oded Gabbay X-Google-Original-From: Oded Gabbay To: David Airlie , Alex Deucher , Jerome Glisse Subject: [PATCH 62/83] hsa/radeon: Fix timeout calculation in sync_with_hw Date: Fri, 11 Jul 2014 00:54:18 +0300 Message-Id: <1405029279-6894-34-git-send-email-oded.gabbay@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1405029279-6894-1-git-send-email-oded.gabbay@amd.com> References: <1405029279-6894-1-git-send-email-oded.gabbay@amd.com> X-Mailman-Approved-At: Thu, 10 Jul 2014 16:33:12 -0700 Cc: Andrew Lewycky , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes a bug in the timeout calculation done in sync_with_hw functions. The original code assumed that jiffies is incremented in ms. Signed-off-by: Oded Gabbay --- drivers/gpu/hsa/radeon/kfd_kernel_queue.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/hsa/radeon/kfd_kernel_queue.c b/drivers/gpu/hsa/radeon/kfd_kernel_queue.c index 25528b3..ce3261b 100644 --- a/drivers/gpu/hsa/radeon/kfd_kernel_queue.c +++ b/drivers/gpu/hsa/radeon/kfd_kernel_queue.c @@ -222,12 +222,18 @@ static void submit_packet(struct kernel_queue *kq) static int sync_with_hw(struct kernel_queue *kq, unsigned long timeout_ms) { + unsigned long org_timeout_ms; + BUG_ON(!kq); - timeout_ms += jiffies; + + org_timeout_ms = timeout_ms; + timeout_ms += jiffies * 1000 / HZ; while (*kq->wptr_kernel != *kq->rptr_kernel) { - if (time_after(jiffies, timeout_ms)) { - pr_err("kfd: kernel_queue %s timeout expired %lu\n", __func__, timeout_ms); - pr_err("kfd: wptr: %d rptr: %d\n", *kq->wptr_kernel, *kq->rptr_kernel); + if (time_after(jiffies * 1000 / HZ, timeout_ms)) { + pr_err("kfd: kernel_queue %s timeout expired %lu\n", + __func__, org_timeout_ms); + pr_err("kfd: wptr: %d rptr: %d\n", + *kq->wptr_kernel, *kq->rptr_kernel); return -ETIME; } cpu_relax();