[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] pcifront poll loop now checks gettimeofday rather than jiffies,



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 00aba64e034e70a262cbe3b729b3601ce8142eda
# Parent  1569bc48b0b8cbe7504c225752f7d36b8df2e537
pcifront poll loop now checks gettimeofday rather than jiffies,
as the latter does not increase while interrupts are disabled.

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r 1569bc48b0b8 -r 00aba64e034e 
linux-2.6-xen-sparse/drivers/xen/pcifront/pci_op.c
--- a/linux-2.6-xen-sparse/drivers/xen/pcifront/pci_op.c        Wed Mar 15 
19:25:50 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/pcifront/pci_op.c        Thu Mar 16 
11:31:16 2006
@@ -40,8 +40,10 @@
 {
        int err = 0;
        struct xen_pci_op *active_op = &pdev->sh_info->op;
-       unsigned long irq_flags, poll_end;
+       unsigned long irq_flags;
        evtchn_port_t port = pdev->evtchn;
+       nsec_t ns, ns_timeout;
+       struct timeval tv;
 
        spin_lock_irqsave(&pdev->sh_info_lock, irq_flags);
 
@@ -52,15 +54,25 @@
        set_bit(_XEN_PCIF_active, (unsigned long *)&pdev->sh_info->flags);
        notify_remote_via_evtchn(port);
 
-       poll_end = jiffies + 5*HZ;
+       /*
+        * We set a poll timeout of 5 seconds but give up on return after
+        * 4 seconds. It is better to time out too late rather than too early
+        * (in the latter case we end up continually re-executing poll() with a
+        * timeout in the past). 1s difference gives plenty of slack for error.
+        */
+       do_gettimeofday(&tv);
+       ns_timeout = timeval_to_ns(&tv) + 4 * (nsec_t)NSEC_PER_SEC;
+
        clear_evtchn(port);
 
        while (test_bit(_XEN_PCIF_active,
                        (unsigned long *)&pdev->sh_info->flags)) {
-               if (HYPERVISOR_poll(&port, 1, poll_end))
+               if (HYPERVISOR_poll(&port, 1, jiffies + 5*HZ))
                        BUG();
                clear_evtchn(port);
-               if (time_after(jiffies, poll_end)) {
+               do_gettimeofday(&tv);
+               ns = timeval_to_ns(&tv);
+               if (ns > ns_timeout) {
                        dev_err(&pdev->xdev->dev,
                                "pciback not responding!!!\n");
                        clear_bit(_XEN_PCIF_active,

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.