diff options
Diffstat (limited to 'drivers/infiniband/hw/ipath/ipath_file_ops.c')
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_file_ops.c | 61 |
1 files changed, 35 insertions, 26 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c index e89d3a17acd9..51a609d47087 100644 --- a/drivers/infiniband/hw/ipath/ipath_file_ops.c +++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c | |||
@@ -1486,42 +1486,51 @@ static int ipath_close(struct inode *in, struct file *fp) | |||
1486 | } | 1486 | } |
1487 | 1487 | ||
1488 | if (dd->ipath_kregbase) { | 1488 | if (dd->ipath_kregbase) { |
1489 | ipath_write_kreg_port( | 1489 | int i; |
1490 | dd, dd->ipath_kregs->kr_rcvhdrtailaddr, | 1490 | /* atomically clear receive enable port. */ |
1491 | port, 0ULL); | 1491 | clear_bit(INFINIPATH_R_PORTENABLE_SHIFT + port, |
1492 | ipath_write_kreg_port( | 1492 | &dd->ipath_rcvctrl); |
1493 | dd, dd->ipath_kregs->kr_rcvhdraddr, | 1493 | ipath_write_kreg( dd, dd->ipath_kregs->kr_rcvctrl, |
1494 | pd->port_port, 0); | 1494 | dd->ipath_rcvctrl); |
1495 | /* and read back from chip to be sure that nothing | ||
1496 | * else is in flight when we do the rest */ | ||
1497 | (void)ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch); | ||
1495 | 1498 | ||
1496 | /* clean up the pkeys for this port user */ | 1499 | /* clean up the pkeys for this port user */ |
1497 | ipath_clean_part_key(pd, dd); | 1500 | ipath_clean_part_key(pd, dd); |
1498 | 1501 | ||
1499 | if (port < dd->ipath_cfgports) { | ||
1500 | int i = dd->ipath_pbufsport * (port - 1); | ||
1501 | ipath_disarm_piobufs(dd, i, dd->ipath_pbufsport); | ||
1502 | 1502 | ||
1503 | /* atomically clear receive enable port. */ | 1503 | /* |
1504 | clear_bit(INFINIPATH_R_PORTENABLE_SHIFT + port, | 1504 | * be paranoid, and never write 0's to these, just use an |
1505 | &dd->ipath_rcvctrl); | 1505 | * unused part of the port 0 tail page. Of course, |
1506 | ipath_write_kreg( | 1506 | * rcvhdraddr points to a large chunk of memory, so this |
1507 | dd, | 1507 | * could still trash things, but at least it won't trash |
1508 | dd->ipath_kregs->kr_rcvctrl, | 1508 | * page 0, and by disabling the port, it should stop "soon", |
1509 | dd->ipath_rcvctrl); | 1509 | * even if a packet or two is in already in flight after we |
1510 | 1510 | * disabled the port. | |
1511 | if (dd->ipath_pageshadow) | 1511 | */ |
1512 | unlock_expected_tids(pd); | 1512 | ipath_write_kreg_port(dd, |
1513 | ipath_stats.sps_ports--; | 1513 | dd->ipath_kregs->kr_rcvhdrtailaddr, port, |
1514 | ipath_cdbg(PROC, "%s[%u] closed port %u:%u\n", | 1514 | dd->ipath_dummy_hdrq_phys); |
1515 | pd->port_comm, pd->port_pid, | 1515 | ipath_write_kreg_port(dd, dd->ipath_kregs->kr_rcvhdraddr, |
1516 | dd->ipath_unit, port); | 1516 | pd->port_port, dd->ipath_dummy_hdrq_phys); |
1517 | } | 1517 | |
1518 | i = dd->ipath_pbufsport * (port - 1); | ||
1519 | ipath_disarm_piobufs(dd, i, dd->ipath_pbufsport); | ||
1520 | |||
1521 | if (dd->ipath_pageshadow) | ||
1522 | unlock_expected_tids(pd); | ||
1523 | ipath_stats.sps_ports--; | ||
1524 | ipath_cdbg(PROC, "%s[%u] closed port %u:%u\n", | ||
1525 | pd->port_comm, pd->port_pid, | ||
1526 | dd->ipath_unit, port); | ||
1527 | |||
1528 | dd->ipath_f_clear_tids(dd, pd->port_port); | ||
1518 | } | 1529 | } |
1519 | 1530 | ||
1520 | pd->port_cnt = 0; | 1531 | pd->port_cnt = 0; |
1521 | pd->port_pid = 0; | 1532 | pd->port_pid = 0; |
1522 | 1533 | ||
1523 | dd->ipath_f_clear_tids(dd, pd->port_port); | ||
1524 | |||
1525 | dd->ipath_pd[pd->port_port] = NULL; /* before releasing mutex */ | 1534 | dd->ipath_pd[pd->port_port] = NULL; /* before releasing mutex */ |
1526 | mutex_unlock(&ipath_mutex); | 1535 | mutex_unlock(&ipath_mutex); |
1527 | ipath_free_pddata(dd, pd); /* after releasing the mutex */ | 1536 | ipath_free_pddata(dd, pd); /* after releasing the mutex */ |