ia64/xen-unstable

changeset 9299:00aba64e034e

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@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Mar 16 12:31:16 2006 +0100 (2006-03-16)
parents 1569bc48b0b8
children a7b6eed7b0a6
files linux-2.6-xen-sparse/drivers/xen/pcifront/pci_op.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/pcifront/pci_op.c	Wed Mar 15 20:25:50 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pcifront/pci_op.c	Thu Mar 16 12:31:16 2006 +0100
     1.3 @@ -40,8 +40,10 @@ static int do_pci_op(struct pcifront_dev
     1.4  {
     1.5  	int err = 0;
     1.6  	struct xen_pci_op *active_op = &pdev->sh_info->op;
     1.7 -	unsigned long irq_flags, poll_end;
     1.8 +	unsigned long irq_flags;
     1.9  	evtchn_port_t port = pdev->evtchn;
    1.10 +	nsec_t ns, ns_timeout;
    1.11 +	struct timeval tv;
    1.12  
    1.13  	spin_lock_irqsave(&pdev->sh_info_lock, irq_flags);
    1.14  
    1.15 @@ -52,15 +54,25 @@ static int do_pci_op(struct pcifront_dev
    1.16  	set_bit(_XEN_PCIF_active, (unsigned long *)&pdev->sh_info->flags);
    1.17  	notify_remote_via_evtchn(port);
    1.18  
    1.19 -	poll_end = jiffies + 5*HZ;
    1.20 +	/*
    1.21 +	 * We set a poll timeout of 5 seconds but give up on return after
    1.22 +	 * 4 seconds. It is better to time out too late rather than too early
    1.23 +	 * (in the latter case we end up continually re-executing poll() with a
    1.24 +	 * timeout in the past). 1s difference gives plenty of slack for error.
    1.25 +	 */
    1.26 +	do_gettimeofday(&tv);
    1.27 +	ns_timeout = timeval_to_ns(&tv) + 4 * (nsec_t)NSEC_PER_SEC;
    1.28 +
    1.29  	clear_evtchn(port);
    1.30  
    1.31  	while (test_bit(_XEN_PCIF_active,
    1.32  			(unsigned long *)&pdev->sh_info->flags)) {
    1.33 -		if (HYPERVISOR_poll(&port, 1, poll_end))
    1.34 +		if (HYPERVISOR_poll(&port, 1, jiffies + 5*HZ))
    1.35  			BUG();
    1.36  		clear_evtchn(port);
    1.37 -		if (time_after(jiffies, poll_end)) {
    1.38 +		do_gettimeofday(&tv);
    1.39 +		ns = timeval_to_ns(&tv);
    1.40 +		if (ns > ns_timeout) {
    1.41  			dev_err(&pdev->xdev->dev,
    1.42  				"pciback not responding!!!\n");
    1.43  			clear_bit(_XEN_PCIF_active,