ia64/xen-unstable

annotate xen/common/event_channel.c @ 1253:34aaad33c28d

bitkeeper revision 1.825.3.14 (40683680NZjB1f8PmpgffnMdcNdBjQ)

Many files:
Final IRQ and PCI-access virtualisation fixes.
author kaf24@scramble.cl.cam.ac.uk
date Mon Mar 29 14:45:20 2004 +0000 (2004-03-29)
parents 76ba37dc1b89
children bab99b03bc2b
rev   line source
kaf24@954 1 /******************************************************************************
kaf24@954 2 * event_channel.c
kaf24@954 3 *
kaf24@954 4 * Event channels between domains.
kaf24@954 5 *
kaf24@1127 6 * Copyright (c) 2003-2004, K A Fraser.
kaf24@954 7 *
kaf24@954 8 * This program is distributed in the hope that it will be useful,
kaf24@954 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
kaf24@954 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kaf24@954 11 * GNU General Public License for more details.
kaf24@954 12 *
kaf24@954 13 * You should have received a copy of the GNU General Public License
kaf24@954 14 * along with this program; if not, write to the Free Software
kaf24@954 15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
kaf24@954 16 */
kaf24@954 17
kaf24@1210 18 #include <xen/config.h>
kaf24@1210 19 #include <xen/init.h>
kaf24@1210 20 #include <xen/lib.h>
kaf24@1210 21 #include <xen/errno.h>
kaf24@1210 22 #include <xen/sched.h>
kaf24@1210 23 #include <xen/event.h>
kaf24@1239 24 #include <xen/irq.h>
kaf24@954 25
kaf24@1127 26 #include <hypervisor-ifs/hypervisor-if.h>
kaf24@1127 27 #include <hypervisor-ifs/event_channel.h>
kaf24@1127 28
kaf24@1218 29 #define INIT_EVENT_CHANNELS 16
kaf24@1218 30 #define MAX_EVENT_CHANNELS 1024
kaf24@954 31
kaf24@1127 32 static int get_free_port(struct task_struct *p)
kaf24@954 33 {
kaf24@1127 34 int max, port;
kaf24@1127 35 event_channel_t *chn;
kaf24@1127 36
kaf24@1127 37 max = p->max_event_channel;
kaf24@1127 38 chn = p->event_channel;
kaf24@1127 39
kaf24@1127 40 for ( port = 0; port < max; port++ )
kaf24@1127 41 if ( chn[port].state == ECS_FREE )
kaf24@1127 42 break;
kaf24@1127 43
kaf24@1127 44 if ( port == max )
kaf24@1127 45 {
kaf24@1127 46 if ( max == MAX_EVENT_CHANNELS )
kaf24@1127 47 return -ENOSPC;
kaf24@1127 48
kaf24@1127 49 max = (max == 0) ? 4 : (max * 2);
kaf24@1127 50
kaf24@1127 51 chn = kmalloc(max * sizeof(event_channel_t), GFP_KERNEL);
kaf24@1127 52 if ( unlikely(chn == NULL) )
kaf24@1127 53 return -ENOMEM;
kaf24@1127 54
kaf24@1127 55 memset(chn, 0, max * sizeof(event_channel_t));
kaf24@1127 56
kaf24@1127 57 if ( p->event_channel != NULL )
kaf24@1127 58 {
kaf24@1127 59 memcpy(chn, p->event_channel, (max/2) * sizeof(event_channel_t));
kaf24@1127 60 kfree(p->event_channel);
kaf24@1127 61 }
kaf24@1127 62
kaf24@1127 63 p->event_channel = chn;
kaf24@1127 64 p->max_event_channel = max;
kaf24@1127 65 }
kaf24@1127 66
kaf24@1127 67 return port;
kaf24@1127 68 }
kaf24@1127 69
kaf24@1218 70 static long evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind)
kaf24@1127 71 {
kaf24@1129 72 struct task_struct *p1, *p2;
kaf24@1129 73 int port1 = 0, port2 = 0;
kaf24@1218 74 domid_t dom1 = bind->dom1, dom2 = bind->dom2;
kaf24@954 75 long rc = 0;
kaf24@954 76
kaf24@1127 77 if ( !IS_PRIV(current) )
kaf24@1127 78 return -EPERM;
kaf24@954 79
kaf24@1129 80 if ( dom1 == DOMID_SELF )
kaf24@1129 81 dom1 = current->domain;
kaf24@1129 82 if ( dom2 == DOMID_SELF )
kaf24@1135 83 dom2 = current->domain;
kaf24@1127 84
kaf24@1129 85 if ( ((p1 = find_domain_by_id(dom1)) == NULL) ||
kaf24@1129 86 ((p2 = find_domain_by_id(dom2)) == NULL) )
kaf24@1127 87 {
kaf24@1129 88 if ( p1 != NULL )
kaf24@1129 89 put_task_struct(p1);
kaf24@1127 90 return -ESRCH;
kaf24@1127 91 }
kaf24@1127 92
kaf24@1127 93 /* Avoid deadlock by first acquiring lock of domain with smaller id. */
kaf24@1129 94 if ( dom1 < dom2 )
kaf24@954 95 {
kaf24@1129 96 spin_lock(&p1->event_channel_lock);
kaf24@1129 97 spin_lock(&p2->event_channel_lock);
kaf24@954 98 }
kaf24@954 99 else
kaf24@954 100 {
kaf24@1135 101 if ( p1 != p2 )
kaf24@1135 102 spin_lock(&p2->event_channel_lock);
kaf24@1129 103 spin_lock(&p1->event_channel_lock);
kaf24@954 104 }
kaf24@954 105
kaf24@1129 106 if ( (port1 = get_free_port(p1)) < 0 )
kaf24@954 107 {
kaf24@1129 108 rc = port1;
kaf24@1127 109 goto out;
kaf24@954 110 }
kaf24@954 111
kaf24@1129 112 if ( (port2 = get_free_port(p2)) < 0 )
kaf24@954 113 {
kaf24@1129 114 rc = port2;
kaf24@1127 115 goto out;
kaf24@1127 116 }
kaf24@954 117
kaf24@1218 118 p1->event_channel[port1].u.remote.dom = p2;
kaf24@1218 119 p1->event_channel[port1].u.remote.port = (u16)port2;
kaf24@1218 120 p1->event_channel[port1].state = ECS_INTERDOMAIN;
kaf24@954 121
kaf24@1218 122 p2->event_channel[port2].u.remote.dom = p1;
kaf24@1218 123 p2->event_channel[port2].u.remote.port = (u16)port1;
kaf24@1218 124 p2->event_channel[port2].state = ECS_INTERDOMAIN;
kaf24@1127 125
kaf24@1218 126 evtchn_set_pending(p1, port1);
kaf24@1218 127 evtchn_set_pending(p2, port2);
kaf24@954 128
kaf24@954 129 out:
kaf24@1129 130 spin_unlock(&p1->event_channel_lock);
kaf24@1135 131 if ( p1 != p2 )
kaf24@1135 132 spin_unlock(&p2->event_channel_lock);
kaf24@1127 133
kaf24@1129 134 put_task_struct(p1);
kaf24@1129 135 put_task_struct(p2);
kaf24@1127 136
kaf24@1218 137 bind->port1 = port1;
kaf24@1218 138 bind->port2 = port2;
kaf24@954 139
kaf24@954 140 return rc;
kaf24@954 141 }
kaf24@954 142
kaf24@954 143
kaf24@1218 144 static long evtchn_bind_virq(evtchn_bind_virq_t *bind)
kaf24@1218 145 {
kaf24@1218 146 struct task_struct *p = current;
kaf24@1218 147 int virq = bind->virq;
kaf24@1218 148 int port;
kaf24@1218 149
kaf24@1235 150 if ( virq >= ARRAY_SIZE(p->virq_to_evtchn) )
kaf24@1218 151 return -EINVAL;
kaf24@1218 152
kaf24@1218 153 spin_lock(&p->event_channel_lock);
kaf24@1218 154
kaf24@1218 155 /*
kaf24@1218 156 * Port 0 is the fallback port for VIRQs that haven't been explicitly
kaf24@1249 157 * bound yet. The exception is the 'misdirect VIRQ', which is permanently
kaf24@1218 158 * bound to port 0.
kaf24@1218 159 */
kaf24@1218 160 if ( ((port = p->virq_to_evtchn[virq]) != 0) ||
kaf24@1249 161 (virq == VIRQ_MISDIRECT) ||
kaf24@1218 162 ((port = get_free_port(p)) < 0) )
kaf24@1218 163 goto out;
kaf24@1218 164
kaf24@1218 165 p->event_channel[port].state = ECS_VIRQ;
kaf24@1218 166 p->event_channel[port].u.virq = virq;
kaf24@1218 167
kaf24@1218 168 p->virq_to_evtchn[virq] = port;
kaf24@1218 169
kaf24@1218 170 out:
kaf24@1218 171 spin_unlock(&p->event_channel_lock);
kaf24@1218 172
kaf24@1218 173 if ( port < 0 )
kaf24@1218 174 return port;
kaf24@1218 175
kaf24@1218 176 bind->port = port;
kaf24@1218 177 return 0;
kaf24@1218 178 }
kaf24@1218 179
kaf24@1218 180
kaf24@1235 181 static long evtchn_bind_pirq(evtchn_bind_pirq_t *bind)
kaf24@1235 182 {
kaf24@1235 183 struct task_struct *p = current;
kaf24@1235 184 int pirq = bind->pirq;
kaf24@1239 185 int port, rc;
kaf24@1235 186
kaf24@1235 187 if ( pirq >= ARRAY_SIZE(p->pirq_to_evtchn) )
kaf24@1235 188 return -EINVAL;
kaf24@1235 189
kaf24@1235 190 spin_lock(&p->event_channel_lock);
kaf24@1235 191
kaf24@1239 192 if ( ((rc = port = p->pirq_to_evtchn[pirq]) != 0) ||
kaf24@1239 193 ((rc = port = get_free_port(p)) < 0) )
kaf24@1235 194 goto out;
kaf24@1235 195
kaf24@1239 196 p->pirq_to_evtchn[pirq] = port;
kaf24@1253 197 rc = pirq_guest_bind(p, pirq,
kaf24@1253 198 !!(bind->flags & BIND_PIRQ__WILL_SHARE));
kaf24@1253 199 if ( rc != 0 )
kaf24@1239 200 {
kaf24@1239 201 p->pirq_to_evtchn[pirq] = 0;
kaf24@1251 202 DPRINTK("Couldn't bind to PIRQ %d (error=%d)\n", pirq, rc);
kaf24@1239 203 goto out;
kaf24@1239 204 }
kaf24@1239 205
kaf24@1235 206 p->event_channel[port].state = ECS_PIRQ;
kaf24@1235 207 p->event_channel[port].u.pirq = pirq;
kaf24@1235 208
kaf24@1235 209 out:
kaf24@1235 210 spin_unlock(&p->event_channel_lock);
kaf24@1235 211
kaf24@1239 212 if ( rc < 0 )
kaf24@1239 213 return rc;
kaf24@1235 214
kaf24@1235 215 bind->port = port;
kaf24@1235 216 return 0;
kaf24@1235 217 }
kaf24@1235 218
kaf24@1235 219
kaf24@1218 220 static long __evtchn_close(struct task_struct *p1, int port1)
kaf24@954 221 {
kaf24@1129 222 struct task_struct *p2 = NULL;
kaf24@1129 223 event_channel_t *chn1, *chn2;
kaf24@1129 224 int port2;
kaf24@954 225 long rc = 0;
kaf24@954 226
kaf24@954 227 again:
kaf24@1129 228 spin_lock(&p1->event_channel_lock);
kaf24@954 229
kaf24@1129 230 chn1 = p1->event_channel;
kaf24@954 231
kaf24@1249 232 /* NB. Port 0 is special (VIRQ_MISDIRECT). Never let it be closed. */
kaf24@1218 233 if ( (port1 <= 0) || (port1 >= p1->max_event_channel) )
kaf24@954 234 {
kaf24@954 235 rc = -EINVAL;
kaf24@954 236 goto out;
kaf24@954 237 }
kaf24@954 238
kaf24@1218 239 switch ( chn1[port1].state )
kaf24@954 240 {
kaf24@1218 241 case ECS_FREE:
kaf24@1218 242 rc = -EINVAL;
kaf24@1218 243 goto out;
kaf24@1218 244
kaf24@1218 245 case ECS_UNBOUND:
kaf24@1218 246 break;
kaf24@1218 247
kaf24@1218 248 case ECS_PIRQ:
kaf24@1239 249 if ( (rc = pirq_guest_unbind(p1, chn1[port1].u.pirq)) == 0 )
kaf24@1239 250 p1->pirq_to_evtchn[chn1[port1].u.pirq] = 0;
kaf24@1218 251 break;
kaf24@1218 252
kaf24@1218 253 case ECS_VIRQ:
kaf24@1218 254 p1->virq_to_evtchn[chn1[port1].u.virq] = 0;
kaf24@1218 255 break;
kaf24@1218 256
kaf24@1218 257 case ECS_INTERDOMAIN:
kaf24@1129 258 if ( p2 == NULL )
kaf24@954 259 {
kaf24@1218 260 p2 = chn1[port1].u.remote.dom;
kaf24@1129 261 get_task_struct(p2);
kaf24@1127 262
kaf24@1129 263 if ( p1->domain < p2->domain )
kaf24@954 264 {
kaf24@1129 265 spin_lock(&p2->event_channel_lock);
kaf24@954 266 }
kaf24@1135 267 else if ( p1 != p2 )
kaf24@954 268 {
kaf24@1129 269 spin_unlock(&p1->event_channel_lock);
kaf24@1129 270 spin_lock(&p2->event_channel_lock);
kaf24@954 271 goto again;
kaf24@954 272 }
kaf24@954 273 }
kaf24@1218 274 else if ( p2 != chn1[port1].u.remote.dom )
kaf24@954 275 {
kaf24@954 276 rc = -EINVAL;
kaf24@954 277 goto out;
kaf24@954 278 }
kaf24@954 279
kaf24@1129 280 chn2 = p2->event_channel;
kaf24@1218 281 port2 = chn1[port1].u.remote.port;
kaf24@954 282
kaf24@1129 283 if ( port2 >= p2->max_event_channel )
kaf24@1127 284 BUG();
kaf24@1218 285 if ( chn2[port2].state != ECS_INTERDOMAIN )
kaf24@1127 286 BUG();
kaf24@1218 287 if ( chn2[port2].u.remote.dom != p1 )
kaf24@1127 288 BUG();
kaf24@954 289
kaf24@1218 290 chn2[port2].state = ECS_UNBOUND;
kaf24@1218 291 chn2[port2].u.remote.dom = NULL;
kaf24@1218 292 chn2[port2].u.remote.port = 0xFFFF;
kaf24@1127 293
kaf24@1218 294 evtchn_set_exception(p2, port2);
kaf24@1218 295
kaf24@1218 296 break;
kaf24@1218 297
kaf24@1218 298 default:
kaf24@1218 299 BUG();
kaf24@954 300 }
kaf24@954 301
kaf24@1218 302 chn1[port1].state = ECS_FREE;
kaf24@1218 303 chn1[port1].u.remote.dom = NULL;
kaf24@1218 304 chn1[port1].u.remote.port = 0xFFFF;
kaf24@954 305
kaf24@1218 306 evtchn_set_exception(p1, port1);
kaf24@1133 307
kaf24@954 308 out:
kaf24@1129 309 if ( p2 != NULL )
kaf24@954 310 {
kaf24@1135 311 if ( p1 != p2 )
kaf24@1135 312 spin_unlock(&p2->event_channel_lock);
kaf24@1129 313 put_task_struct(p2);
kaf24@954 314 }
kaf24@954 315
kaf24@1145 316 spin_unlock(&p1->event_channel_lock);
kaf24@1145 317
kaf24@954 318 return rc;
kaf24@954 319 }
kaf24@954 320
kaf24@954 321
kaf24@1218 322 static long evtchn_close(evtchn_close_t *close)
kaf24@1127 323 {
kaf24@1129 324 struct task_struct *p;
kaf24@1127 325 long rc;
kaf24@1129 326 domid_t dom = close->dom;
kaf24@1127 327
kaf24@1129 328 if ( dom == DOMID_SELF )
kaf24@1129 329 dom = current->domain;
kaf24@1127 330 else if ( !IS_PRIV(current) )
kaf24@1127 331 return -EPERM;
kaf24@1127 332
kaf24@1129 333 if ( (p = find_domain_by_id(dom)) == NULL )
kaf24@1127 334 return -ESRCH;
kaf24@1127 335
kaf24@1218 336 rc = __evtchn_close(p, close->port);
kaf24@1127 337
kaf24@1129 338 put_task_struct(p);
kaf24@1127 339 return rc;
kaf24@1127 340 }
kaf24@1127 341
kaf24@1127 342
kaf24@1218 343 static long evtchn_send(int lport)
kaf24@954 344 {
kaf24@954 345 struct task_struct *lp = current, *rp;
kaf24@1127 346 int rport;
kaf24@954 347
kaf24@954 348 spin_lock(&lp->event_channel_lock);
kaf24@954 349
kaf24@1127 350 if ( unlikely(lport < 0) ||
kaf24@1127 351 unlikely(lport >= lp->max_event_channel) ||
kaf24@1218 352 unlikely(lp->event_channel[lport].state != ECS_INTERDOMAIN) )
kaf24@954 353 {
kaf24@954 354 spin_unlock(&lp->event_channel_lock);
kaf24@954 355 return -EINVAL;
kaf24@954 356 }
kaf24@954 357
kaf24@1218 358 rp = lp->event_channel[lport].u.remote.dom;
kaf24@1218 359 rport = lp->event_channel[lport].u.remote.port;
kaf24@1127 360
kaf24@1127 361 get_task_struct(rp);
kaf24@954 362
kaf24@954 363 spin_unlock(&lp->event_channel_lock);
kaf24@954 364
kaf24@1218 365 evtchn_set_pending(rp, rport);
kaf24@954 366
kaf24@954 367 put_task_struct(rp);
kaf24@1127 368
kaf24@954 369 return 0;
kaf24@954 370 }
kaf24@954 371
kaf24@954 372
kaf24@1218 373 static long evtchn_status(evtchn_status_t *status)
kaf24@954 374 {
kaf24@1129 375 struct task_struct *p;
kaf24@1218 376 domid_t dom = status->dom;
kaf24@1218 377 int port = status->port;
kaf24@1129 378 event_channel_t *chn;
kaf24@1127 379
kaf24@1129 380 if ( dom == DOMID_SELF )
kaf24@1129 381 dom = current->domain;
kaf24@1127 382 else if ( !IS_PRIV(current) )
kaf24@1127 383 return -EPERM;
kaf24@1127 384
kaf24@1129 385 if ( (p = find_domain_by_id(dom)) == NULL )
kaf24@1127 386 return -ESRCH;
kaf24@954 387
kaf24@1129 388 spin_lock(&p->event_channel_lock);
kaf24@954 389
kaf24@1129 390 chn = p->event_channel;
kaf24@954 391
kaf24@1129 392 if ( (port < 0) || (port >= p->max_event_channel) )
kaf24@954 393 {
kaf24@1129 394 spin_unlock(&p->event_channel_lock);
kaf24@1127 395 return -EINVAL;
kaf24@1127 396 }
kaf24@1127 397
kaf24@1129 398 switch ( chn[port].state )
kaf24@1127 399 {
kaf24@1127 400 case ECS_FREE:
kaf24@1127 401 status->status = EVTCHNSTAT_closed;
kaf24@1127 402 break;
kaf24@1218 403 case ECS_UNBOUND:
kaf24@1218 404 status->status = EVTCHNSTAT_unbound;
kaf24@1127 405 break;
kaf24@1218 406 case ECS_INTERDOMAIN:
kaf24@1218 407 status->status = EVTCHNSTAT_interdomain;
kaf24@1218 408 status->u.interdomain.dom = chn[port].u.remote.dom->domain;
kaf24@1218 409 status->u.interdomain.port = chn[port].u.remote.port;
kaf24@1218 410 break;
kaf24@1218 411 case ECS_PIRQ:
kaf24@1218 412 status->status = EVTCHNSTAT_pirq;
kaf24@1218 413 status->u.pirq = chn[port].u.pirq;
kaf24@1218 414 break;
kaf24@1218 415 case ECS_VIRQ:
kaf24@1218 416 status->status = EVTCHNSTAT_virq;
kaf24@1218 417 status->u.virq = chn[port].u.virq;
kaf24@1127 418 break;
kaf24@1127 419 default:
kaf24@1127 420 BUG();
kaf24@954 421 }
kaf24@954 422
kaf24@1129 423 spin_unlock(&p->event_channel_lock);
kaf24@1127 424 return 0;
kaf24@954 425 }
kaf24@954 426
kaf24@954 427
kaf24@1127 428 long do_event_channel_op(evtchn_op_t *uop)
kaf24@954 429 {
kaf24@954 430 long rc;
kaf24@1127 431 evtchn_op_t op;
kaf24@954 432
kaf24@1127 433 if ( copy_from_user(&op, uop, sizeof(op)) != 0 )
kaf24@1127 434 return -EFAULT;
kaf24@1127 435
kaf24@1127 436 switch ( op.cmd )
kaf24@954 437 {
kaf24@1218 438 case EVTCHNOP_bind_interdomain:
kaf24@1218 439 rc = evtchn_bind_interdomain(&op.u.bind_interdomain);
kaf24@1235 440 if ( (rc == 0) && (copy_to_user(uop, &op, sizeof(op)) != 0) )
kaf24@1218 441 rc = -EFAULT; /* Cleaning up here would be a mess! */
kaf24@1218 442 break;
kaf24@1218 443
kaf24@1218 444 case EVTCHNOP_bind_virq:
kaf24@1218 445 rc = evtchn_bind_virq(&op.u.bind_virq);
kaf24@1235 446 if ( (rc == 0) && (copy_to_user(uop, &op, sizeof(op)) != 0) )
kaf24@1235 447 rc = -EFAULT; /* Cleaning up here would be a mess! */
kaf24@1235 448 break;
kaf24@1235 449
kaf24@1235 450 case EVTCHNOP_bind_pirq:
kaf24@1235 451 rc = evtchn_bind_pirq(&op.u.bind_pirq);
kaf24@1235 452 if ( (rc == 0) && (copy_to_user(uop, &op, sizeof(op)) != 0) )
kaf24@1127 453 rc = -EFAULT; /* Cleaning up here would be a mess! */
kaf24@954 454 break;
kaf24@954 455
kaf24@954 456 case EVTCHNOP_close:
kaf24@1218 457 rc = evtchn_close(&op.u.close);
kaf24@954 458 break;
kaf24@954 459
kaf24@954 460 case EVTCHNOP_send:
kaf24@1218 461 rc = evtchn_send(op.u.send.local_port);
kaf24@954 462 break;
kaf24@954 463
kaf24@954 464 case EVTCHNOP_status:
kaf24@1218 465 rc = evtchn_status(&op.u.status);
kaf24@1235 466 if ( (rc == 0) && (copy_to_user(uop, &op, sizeof(op)) != 0) )
kaf24@1127 467 rc = -EFAULT;
kaf24@954 468 break;
kaf24@954 469
kaf24@954 470 default:
kaf24@954 471 rc = -ENOSYS;
kaf24@954 472 break;
kaf24@954 473 }
kaf24@954 474
kaf24@954 475 return rc;
kaf24@954 476 }
kaf24@954 477
kaf24@954 478
kaf24@1218 479 int init_event_channels(struct task_struct *p)
kaf24@1218 480 {
kaf24@1218 481 spin_lock_init(&p->event_channel_lock);
kaf24@1218 482 p->event_channel = kmalloc(INIT_EVENT_CHANNELS * sizeof(event_channel_t),
kaf24@1218 483 GFP_KERNEL);
kaf24@1218 484 if ( unlikely(p->event_channel == NULL) )
kaf24@1218 485 return -ENOMEM;
kaf24@1218 486 p->max_event_channel = INIT_EVENT_CHANNELS;
kaf24@1218 487 memset(p->event_channel, 0, INIT_EVENT_CHANNELS * sizeof(event_channel_t));
kaf24@1218 488 p->event_channel[0].state = ECS_VIRQ;
kaf24@1249 489 p->event_channel[0].u.virq = VIRQ_MISDIRECT;
kaf24@1218 490 return 0;
kaf24@1218 491 }
kaf24@1218 492
kaf24@1218 493
kaf24@954 494 void destroy_event_channels(struct task_struct *p)
kaf24@954 495 {
kaf24@954 496 int i;
kaf24@954 497 if ( p->event_channel != NULL )
kaf24@954 498 {
kaf24@954 499 for ( i = 0; i < p->max_event_channel; i++ )
kaf24@1218 500 (void)__evtchn_close(p, i);
kaf24@954 501 kfree(p->event_channel);
kaf24@954 502 }
kaf24@954 503 }