public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: mark gross <mgross@linux.intel.com>
To: Andrew Morton <akpm@linux-foundation.org>, Greg KH <greg@kroah.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Make intel iommu_wait_op work with jiffies arn't running
Date: Thu, 8 May 2008 11:40:54 -0700	[thread overview]
Message-ID: <20080508184054.GA20557@linux.intel.com> (raw)

I've noticed that a few times when the bios is buggy the code for
detecting failing DMAR hardware can get stuck in an infinite loop in
early boot waiting for jiffies to time out.  Which are not running at
the time we get stuck in this macro.

This patch replaces the use of the jiffies to detect the failing
hardware with the tsc counter.  Not a big change, instead of getting a
black screen forever, you get a panic...

I also changed the time out from an arbitrary 60 seconds to an arbitrary
10 seconds.

--mgross

Signed-Off-by: mark gross <mgross@linux.intel.com>


Index: linux-next/drivers/pci/intel-iommu.c
===================================================================
--- linux-next.orig/drivers/pci/intel-iommu.c	2008-05-08 11:02:21.000000000 -0700
+++ linux-next/drivers/pci/intel-iommu.c	2008-05-08 11:13:02.000000000 -0700
@@ -49,7 +49,7 @@
 
 #define DEFAULT_DOMAIN_ADDRESS_WIDTH 48
 
-#define DMAR_OPERATION_TIMEOUT (HZ*60) /* 1m */
+#define DMAR_OPERATION_TIMEOUT ((cycles_t) tsc_khz*10*1000) /* 10sec */
 
 #define DOMAIN_MAX_ADDR(gaw) ((((u64)1) << gaw) - 1)
 
@@ -490,13 +490,13 @@
 
 #define IOMMU_WAIT_OP(iommu, offset, op, cond, sts) \
 {\
-	unsigned long start_time = jiffies;\
+	cycles_t start_time = get_cycles();\
 	while (1) {\
 		sts = op (iommu->reg + offset);\
 		if (cond)\
 			break;\
-		if (time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT))\
-			panic("DMAR hardware is malfunctioning\n");\
+		if (DMAR_OPERATION_TIMEOUT < (get_cycles() - start_time))\
+			panic(KERN_ERR "DMAR hardware is malfunctioning\n");\
 		cpu_relax();\
 	}\
 }

                 reply	other threads:[~2008-05-08 18:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080508184054.GA20557@linux.intel.com \
    --to=mgross@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox