ia64/xen-unstable

changeset 7129:8c23b56f3954

Define new notify_remote_via_irq() interface which is a
safe version for drivers to use that is aware of
save/restore. Post-restore notifications are silently
dropped, in the expectation that xenbus will eventually
get round to telling the driver it needs to reconnect.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Sep 29 15:49:54 2005 +0100 (2005-09-29)
parents 559ad1abb3d5
children f633c3d0315b
files linux-2.6-xen-sparse/arch/xen/i386/kernel/smp.c linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/genapic_xen.c linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c linux-2.6-xen-sparse/drivers/xen/netback/netback.c linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c linux-2.6-xen-sparse/include/asm-xen/evtchn.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/smp.c	Thu Sep 29 15:14:03 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/smp.c	Thu Sep 29 15:49:54 2005 +0100
     1.3 @@ -133,7 +133,7 @@ static inline void __send_IPI_one(unsign
     1.4  {
     1.5  	int evtchn = per_cpu(ipi_to_evtchn, cpu)[vector];
     1.6  	BUG_ON(evtchn < 0);
     1.7 -	notify_via_evtchn(evtchn);
     1.8 +	notify_remote_via_evtchn(evtchn);
     1.9  }
    1.10  
    1.11  void __send_IPI_shortcut(unsigned int shortcut, int vector)
     2.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c	Thu Sep 29 15:14:03 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c	Thu Sep 29 15:49:54 2005 +0100
     2.3 @@ -622,6 +622,14 @@ void hw_resend_irq(struct hw_interrupt_t
     2.4  	synch_set_bit(evtchn, &s->evtchn_pending[0]);
     2.5  }
     2.6  
     2.7 +void notify_remote_via_irq(int irq)
     2.8 +{
     2.9 +	int evtchn = irq_to_evtchn[irq];
    2.10 +
    2.11 +	if (VALID_EVTCHN(evtchn))
    2.12 +		notify_remote_via_evtchn(evtchn);
    2.13 +}
    2.14 +
    2.15  void irq_resume(void)
    2.16  {
    2.17  	evtchn_op_t op;
     3.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/genapic_xen.c	Thu Sep 29 15:14:03 2005 +0100
     3.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/genapic_xen.c	Thu Sep 29 15:49:54 2005 +0100
     3.3 @@ -33,7 +33,7 @@ static inline void __send_IPI_one(unsign
     3.4  {
     3.5  	int evtchn = per_cpu(ipi_to_evtchn, cpu)[vector];
     3.6  	BUG_ON(evtchn < 0);
     3.7 -	notify_via_evtchn(evtchn);
     3.8 +	notify_remote_via_evtchn(evtchn);
     3.9  }
    3.10  
    3.11  void xen_send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest)
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Thu Sep 29 15:14:03 2005 +0100
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Thu Sep 29 15:49:54 2005 +0100
     4.3 @@ -481,7 +481,7 @@ static void make_response(blkif_t *blkif
     4.4  	spin_unlock_irqrestore(&blkif->blk_ring_lock, flags);
     4.5  
     4.6  	/* Kick the relevant domain. */
     4.7 -	notify_via_evtchn(blkif->evtchn);
     4.8 +	notify_remote_via_irq(blkif->irq);
     4.9  }
    4.10  
    4.11  void blkif_deschedule(blkif_t *blkif)
     5.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Sep 29 15:14:03 2005 +0100
     5.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Sep 29 15:49:54 2005 +0100
     5.3 @@ -84,7 +84,7 @@ static inline void ADD_ID_TO_FREELIST(
     5.4  static inline void flush_requests(struct blkfront_info *info)
     5.5  {
     5.6  	RING_PUSH_REQUESTS(&info->ring);
     5.7 -	notify_via_evtchn(info->evtchn);
     5.8 +	notify_remote_via_irq(info->irq);
     5.9  }
    5.10  
    5.11  static void kick_pending_request_queues(struct blkfront_info *info)
     6.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Thu Sep 29 15:14:03 2005 +0100
     6.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Thu Sep 29 15:49:54 2005 +0100
     6.3 @@ -842,7 +842,7 @@ static void make_response(blkif_t *blkif
     6.4  	spin_unlock_irqrestore(&blkif->blk_ring_lock, flags);
     6.5  
     6.6  	/* Kick the relevant domain. */
     6.7 -	notify_via_evtchn(blkif->evtchn);
     6.8 +	notify_remote_via_irq(blkif->irq);
     6.9  }
    6.10  
    6.11  static struct miscdevice blktap_miscdev = {
     7.1 --- a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c	Thu Sep 29 15:14:03 2005 +0100
     7.2 +++ b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c	Thu Sep 29 15:49:54 2005 +0100
     7.3 @@ -46,7 +46,8 @@ static inline struct ring_head *inring(v
     7.4  
     7.5  
     7.6  /* don't block -  write as much as possible and return */
     7.7 -static int __xencons_ring_send(struct ring_head *ring, const char *data, unsigned len)
     7.8 +static int __xencons_ring_send(
     7.9 +	struct ring_head *ring, const char *data, unsigned len)
    7.10  {
    7.11  	int copied = 0;
    7.12  
    7.13 @@ -63,13 +64,9 @@ static int __xencons_ring_send(struct ri
    7.14  
    7.15  int xencons_ring_send(const char *data, unsigned len)
    7.16  {
    7.17 -	struct ring_head *out = outring();
    7.18 -	int sent = 0;
    7.19 -	
    7.20 -	sent = __xencons_ring_send(out, data, len);
    7.21 -	notify_via_evtchn(xen_start_info->console_evtchn);
    7.22 +	int sent = __xencons_ring_send(outring(), data, len);
    7.23 +	notify_remote_via_irq(xencons_irq);
    7.24  	return sent;
    7.25 -
    7.26  }	
    7.27  
    7.28  
     8.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Thu Sep 29 15:14:03 2005 +0100
     8.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Thu Sep 29 15:49:54 2005 +0100
     8.3 @@ -42,7 +42,7 @@ static multicall_entry_t rx_mcl[NETIF_RX
     8.4  static mmu_update_t rx_mmu[NETIF_RX_RING_SIZE];
     8.5  
     8.6  static gnttab_transfer_t grant_rx_op[MAX_PENDING_REQS];
     8.7 -static unsigned char rx_notify[NR_EVENT_CHANNELS];
     8.8 +static unsigned char rx_notify[NR_IRQS];
     8.9  
    8.10  /* Don't currently gate addition of an interface to the tx scheduling list. */
    8.11  #define tx_work_exists(_if) (1)
    8.12 @@ -209,7 +209,7 @@ static void net_rx_action(unsigned long 
    8.13  {
    8.14  	netif_t *netif = NULL; 
    8.15  	s8 status;
    8.16 -	u16 size, id, evtchn;
    8.17 +	u16 size, id, irq;
    8.18  	multicall_entry_t *mcl;
    8.19  	mmu_update_t *mmu;
    8.20  	gnttab_transfer_t *gop;
    8.21 @@ -320,16 +320,16 @@ static void net_rx_action(unsigned long 
    8.22  				gop->status, netif->domid);
    8.23  			/* XXX SMH: should free 'old_mfn' here */
    8.24  			status = NETIF_RSP_ERROR; 
    8.25 -		} 
    8.26 -		evtchn = netif->evtchn;
    8.27 +		}
    8.28 +		irq = netif->irq;
    8.29  		id = netif->rx->ring[
    8.30  			MASK_NETIF_RX_IDX(netif->rx_resp_prod)].req.id;
    8.31  		if (make_rx_response(netif, id, status,
    8.32  				     (unsigned long)skb->data & ~PAGE_MASK,
    8.33  				     size, skb->proto_csum_valid) &&
    8.34 -		    (rx_notify[evtchn] == 0)) {
    8.35 -			rx_notify[evtchn] = 1;
    8.36 -			notify_list[notify_nr++] = evtchn;
    8.37 +		    (rx_notify[irq] == 0)) {
    8.38 +			rx_notify[irq] = 1;
    8.39 +			notify_list[notify_nr++] = irq;
    8.40  		}
    8.41  
    8.42  		netif_put(netif);
    8.43 @@ -339,9 +339,9 @@ static void net_rx_action(unsigned long 
    8.44  	}
    8.45  
    8.46  	while (notify_nr != 0) {
    8.47 -		evtchn = notify_list[--notify_nr];
    8.48 -		rx_notify[evtchn] = 0;
    8.49 -		notify_via_evtchn(evtchn);
    8.50 +		irq = notify_list[--notify_nr];
    8.51 +		rx_notify[irq] = 0;
    8.52 +		notify_remote_via_irq(irq);
    8.53  	}
    8.54  
    8.55  	/* More work to do? */
    8.56 @@ -717,7 +717,7 @@ static void make_tx_response(netif_t *ne
    8.57  
    8.58  	mb(); /* Update producer before checking event threshold. */
    8.59  	if (i == netif->tx->event)
    8.60 -		notify_via_evtchn(netif->evtchn);
    8.61 +		notify_remote_via_irq(netif->irq);
    8.62  }
    8.63  
    8.64  static int make_rx_response(netif_t *netif, 
     9.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Sep 29 15:14:03 2005 +0100
     9.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Sep 29 15:49:54 2005 +0100
     9.3 @@ -457,7 +457,7 @@ static int network_start_xmit(struct sk_
     9.4  	/* Only notify Xen if we really have to. */
     9.5  	mb();
     9.6  	if (np->tx->TX_TEST_IDX == i)
     9.7 -		notify_via_evtchn(np->evtchn);
     9.8 +		notify_remote_via_irq(np->irq);
     9.9  
    9.10  	return 0;
    9.11  
    9.12 @@ -776,7 +776,7 @@ static void network_connect(struct net_d
    9.13  	 */
    9.14  	np->backend_state = BEST_CONNECTED;
    9.15  	wmb();
    9.16 -	notify_via_evtchn(np->evtchn);  
    9.17 +	notify_remote_via_irq(np->irq);
    9.18  	network_tx_buf_gc(dev);
    9.19  
    9.20  	if (np->user_state == UST_OPEN)
    10.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Thu Sep 29 15:14:03 2005 +0100
    10.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Thu Sep 29 15:49:54 2005 +0100
    10.3 @@ -308,7 +308,7 @@ static int
    10.4  	rc = offset;
    10.5  	DPRINTK("Notifying frontend via event channel %d\n",
    10.6  	        tpmif->evtchn);
    10.7 -	notify_via_evtchn(tpmif->evtchn);
    10.8 +	notify_remote_via_irq(tpmif->irq);
    10.9  
   10.10  	return rc;
   10.11  }
    11.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Thu Sep 29 15:14:03 2005 +0100
    11.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Thu Sep 29 15:49:54 2005 +0100
    11.3 @@ -682,7 +682,7 @@ tpm_xmit(struct tpm_private *tp,
    11.4  	DPRINTK("Notifying backend via event channel %d\n",
    11.5  	        tp->evtchn);
    11.6  
    11.7 -	notify_via_evtchn(tp->evtchn);
    11.8 +	notify_remote_via_irq(tp->irq);
    11.9  
   11.10  	spin_unlock_irq(&tp->tx_lock);
   11.11  	return offset;
    12.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Thu Sep 29 15:14:03 2005 +0100
    12.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Thu Sep 29 15:49:54 2005 +0100
    12.3 @@ -147,7 +147,7 @@ int xb_write(const void *data, unsigned 
    12.4  		data += avail;
    12.5  		len -= avail;
    12.6  		update_output_chunk(out, avail);
    12.7 -		notify_via_evtchn(xen_start_info->store_evtchn);
    12.8 +		notify_remote_via_irq(xenbus_irq);
    12.9  	} while (len != 0);
   12.10  
   12.11  	return 0;
   12.12 @@ -192,7 +192,7 @@ int xb_read(void *data, unsigned len)
   12.13  		pr_debug("Finished read of %i bytes (%i to go)\n", avail, len);
   12.14  		/* If it was full, tell them we've taken some. */
   12.15  		if (was_full)
   12.16 -			notify_via_evtchn(xen_start_info->store_evtchn);
   12.17 +			notify_remote_via_irq(xenbus_irq);
   12.18  	}
   12.19  
   12.20  	/* If we left something, wake watch thread to deal with it. */
    13.1 --- a/linux-2.6-xen-sparse/include/asm-xen/evtchn.h	Thu Sep 29 15:14:03 2005 +0100
    13.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/evtchn.h	Thu Sep 29 15:49:54 2005 +0100
    13.3 @@ -75,6 +75,12 @@ extern int  bind_evtchn_to_irqhandler(
    13.4  	void *dev_id);
    13.5  extern void unbind_evtchn_from_irqhandler(unsigned int irq, void *dev_id);
    13.6  
    13.7 +/*
    13.8 + * Unlike notify_remote_via_evtchn(), this is safe to use across
    13.9 + * save/restore. Notifications on a broken connection are silently dropped.
   13.10 + */
   13.11 +void notify_remote_via_irq(int irq);
   13.12 +
   13.13  extern void irq_resume(void);
   13.14  
   13.15  /* Entry point for notifications into Linux subsystems. */
   13.16 @@ -115,12 +121,12 @@ static inline void clear_evtchn(int port
   13.17  	synch_clear_bit(port, &s->evtchn_pending[0]);
   13.18  }
   13.19  
   13.20 -static inline int notify_via_evtchn(int port)
   13.21 +static inline void notify_remote_via_evtchn(int port)
   13.22  {
   13.23  	evtchn_op_t op;
   13.24  	op.cmd = EVTCHNOP_send;
   13.25  	op.u.send.local_port = port;
   13.26 -	return HYPERVISOR_event_channel_op(&op);
   13.27 +	(void)HYPERVISOR_event_channel_op(&op);
   13.28  }
   13.29  
   13.30  /*