Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'ntb-4.3' of git://github.com/jonmason/ntb

Pull NTB fixes from Jon Mason:
"NTB bug and documentation fixes, new device IDs, performance
improvements, and adding a mailing list to MAINTAINERS for NTB"

* tag 'ntb-4.3' of git://github.com/jonmason/ntb:
NTB: Fix range check on memory window index
NTB: Improve index handling in B2B MW workaround
NTB: Fix documentation for ntb_peer_db_clear.
NTB: Fix documentation for ntb_link_is_up
NTB: Use unique DMA channels for TX and RX
NTB: Remove dma_sync_wait from ntb_async_rx
NTB: Clean up QP stats info
NTB: Make the transport list in order of discovery
NTB: Add PCI Device IDs for Broadwell Xeon
NTB: Add flow control to the ntb_netdev
NTB: Add list to MAINTAINERS

+210 -47
+2
MAINTAINERS
··· 7396 7396 M: Jon Mason <jdmason@kudzu.us> 7397 7397 M: Dave Jiang <dave.jiang@intel.com> 7398 7398 M: Allen Hubbe <Allen.Hubbe@emc.com> 7399 + L: linux-ntb@googlegroups.com 7399 7400 S: Supported 7400 7401 W: https://github.com/jonmason/ntb/wiki 7401 7402 T: git git://github.com/jonmason/ntb.git ··· 7408 7407 NTB INTEL DRIVER 7409 7408 M: Jon Mason <jdmason@kudzu.us> 7410 7409 M: Dave Jiang <dave.jiang@intel.com> 7410 + L: linux-ntb@googlegroups.com 7411 7411 S: Supported 7412 7412 W: https://github.com/jonmason/ntb/wiki 7413 7413 T: git git://github.com/jonmason/ntb.git
+77
drivers/net/ntb_netdev.c
··· 61 61 MODULE_LICENSE("Dual BSD/GPL"); 62 62 MODULE_AUTHOR("Intel Corporation"); 63 63 64 + /* Time in usecs for tx resource reaper */ 65 + static unsigned int tx_time = 1; 66 + 67 + /* Number of descriptors to free before resuming tx */ 68 + static unsigned int tx_start = 10; 69 + 70 + /* Number of descriptors still available before stop upper layer tx */ 71 + static unsigned int tx_stop = 5; 72 + 64 73 struct ntb_netdev { 65 74 struct list_head list; 66 75 struct pci_dev *pdev; 67 76 struct net_device *ndev; 68 77 struct ntb_transport_qp *qp; 78 + struct timer_list tx_timer; 69 79 }; 70 80 71 81 #define NTB_TX_TIMEOUT_MS 1000 ··· 146 136 } 147 137 } 148 138 139 + static int __ntb_netdev_maybe_stop_tx(struct net_device *netdev, 140 + struct ntb_transport_qp *qp, int size) 141 + { 142 + struct ntb_netdev *dev = netdev_priv(netdev); 143 + 144 + netif_stop_queue(netdev); 145 + /* Make sure to see the latest value of ntb_transport_tx_free_entry() 146 + * since the queue was last started. 147 + */ 148 + smp_mb(); 149 + 150 + if (likely(ntb_transport_tx_free_entry(qp) < size)) { 151 + mod_timer(&dev->tx_timer, jiffies + usecs_to_jiffies(tx_time)); 152 + return -EBUSY; 153 + } 154 + 155 + netif_start_queue(netdev); 156 + return 0; 157 + } 158 + 159 + static int ntb_netdev_maybe_stop_tx(struct net_device *ndev, 160 + struct ntb_transport_qp *qp, int size) 161 + { 162 + if (netif_queue_stopped(ndev) || 163 + (ntb_transport_tx_free_entry(qp) >= size)) 164 + return 0; 165 + 166 + return __ntb_netdev_maybe_stop_tx(ndev, qp, size); 167 + } 168 + 149 169 static void ntb_netdev_tx_handler(struct ntb_transport_qp *qp, void *qp_data, 150 170 void *data, int len) 151 171 { 152 172 struct net_device *ndev = qp_data; 153 173 struct sk_buff *skb; 174 + struct ntb_netdev *dev = netdev_priv(ndev); 154 175 155 176 skb = data; 156 177 if (!skb || !ndev) ··· 196 155 } 197 156 198 157 dev_kfree_skb(skb); 158 + 159 + if (ntb_transport_tx_free_entry(dev->qp) >= tx_start) { 160 + /* Make sure anybody stopping the queue after this sees the new 161 + * value of ntb_transport_tx_free_entry() 162 + */ 163 + smp_mb(); 164 + if (netif_queue_stopped(ndev)) 165 + netif_wake_queue(ndev); 166 + } 199 167 } 200 168 201 169 static netdev_tx_t ntb_netdev_start_xmit(struct sk_buff *skb, ··· 213 163 struct ntb_netdev *dev = netdev_priv(ndev); 214 164 int rc; 215 165 166 + ntb_netdev_maybe_stop_tx(ndev, dev->qp, tx_stop); 167 + 216 168 rc = ntb_transport_tx_enqueue(dev->qp, skb, skb->data, skb->len); 217 169 if (rc) 218 170 goto err; 171 + 172 + /* check for next submit */ 173 + ntb_netdev_maybe_stop_tx(ndev, dev->qp, tx_stop); 219 174 220 175 return NETDEV_TX_OK; 221 176 ··· 228 173 ndev->stats.tx_dropped++; 229 174 ndev->stats.tx_errors++; 230 175 return NETDEV_TX_BUSY; 176 + } 177 + 178 + static void ntb_netdev_tx_timer(unsigned long data) 179 + { 180 + struct net_device *ndev = (struct net_device *)data; 181 + struct ntb_netdev *dev = netdev_priv(ndev); 182 + 183 + if (ntb_transport_tx_free_entry(dev->qp) < tx_stop) { 184 + mod_timer(&dev->tx_timer, jiffies + msecs_to_jiffies(tx_time)); 185 + } else { 186 + /* Make sure anybody stopping the queue after this sees the new 187 + * value of ntb_transport_tx_free_entry() 188 + */ 189 + smp_mb(); 190 + if (netif_queue_stopped(ndev)) 191 + netif_wake_queue(ndev); 192 + } 231 193 } 232 194 233 195 static int ntb_netdev_open(struct net_device *ndev) ··· 269 197 } 270 198 } 271 199 200 + setup_timer(&dev->tx_timer, ntb_netdev_tx_timer, (unsigned long)ndev); 201 + 272 202 netif_carrier_off(ndev); 273 203 ntb_transport_link_up(dev->qp); 204 + netif_start_queue(ndev); 274 205 275 206 return 0; 276 207 ··· 293 218 294 219 while ((skb = ntb_transport_rx_remove(dev->qp, &len))) 295 220 dev_kfree_skb(skb); 221 + 222 + del_timer_sync(&dev->tx_timer); 296 223 297 224 return 0; 298 225 }
+32 -7
drivers/ntb/hw/intel/ntb_hw_intel.c
··· 190 190 case PCI_DEVICE_ID_INTEL_NTB_SS_SNB: 191 191 case PCI_DEVICE_ID_INTEL_NTB_SS_IVT: 192 192 case PCI_DEVICE_ID_INTEL_NTB_SS_HSX: 193 + case PCI_DEVICE_ID_INTEL_NTB_SS_BDX: 193 194 case PCI_DEVICE_ID_INTEL_NTB_PS_JSF: 194 195 case PCI_DEVICE_ID_INTEL_NTB_PS_SNB: 195 196 case PCI_DEVICE_ID_INTEL_NTB_PS_IVT: 196 197 case PCI_DEVICE_ID_INTEL_NTB_PS_HSX: 198 + case PCI_DEVICE_ID_INTEL_NTB_PS_BDX: 197 199 case PCI_DEVICE_ID_INTEL_NTB_B2B_JSF: 198 200 case PCI_DEVICE_ID_INTEL_NTB_B2B_SNB: 199 201 case PCI_DEVICE_ID_INTEL_NTB_B2B_IVT: 200 202 case PCI_DEVICE_ID_INTEL_NTB_B2B_HSX: 203 + case PCI_DEVICE_ID_INTEL_NTB_B2B_BDX: 201 204 return 1; 202 205 } 203 206 return 0; ··· 240 237 241 238 static int ndev_mw_to_bar(struct intel_ntb_dev *ndev, int idx) 242 239 { 243 - if (idx < 0 || idx > ndev->mw_count) 240 + if (idx < 0 || idx >= ndev->mw_count) 244 241 return -EINVAL; 245 242 return ndev->reg->mw_bar[idx]; 246 243 } ··· 575 572 "Connection Topology -\t%s\n", 576 573 ntb_topo_string(ndev->ntb.topo)); 577 574 578 - off += scnprintf(buf + off, buf_size - off, 579 - "B2B Offset -\t\t%#lx\n", ndev->b2b_off); 580 - off += scnprintf(buf + off, buf_size - off, 581 - "B2B MW Idx -\t\t%d\n", ndev->b2b_idx); 575 + if (ndev->b2b_idx != UINT_MAX) { 576 + off += scnprintf(buf + off, buf_size - off, 577 + "B2B MW Idx -\t\t%u\n", ndev->b2b_idx); 578 + off += scnprintf(buf + off, buf_size - off, 579 + "B2B Offset -\t\t%#lx\n", ndev->b2b_off); 580 + } 581 + 582 582 off += scnprintf(buf + off, buf_size - off, 583 583 "BAR4 Split -\t\t%s\n", 584 584 ndev->bar4_split ? "yes" : "no"); ··· 1490 1484 pdev = ndev_pdev(ndev); 1491 1485 mmio = ndev->self_mmio; 1492 1486 1493 - if (ndev->b2b_idx >= ndev->mw_count) { 1487 + if (ndev->b2b_idx == UINT_MAX) { 1494 1488 dev_dbg(ndev_dev(ndev), "not using b2b mw\n"); 1495 1489 b2b_bar = 0; 1496 1490 ndev->b2b_off = 0; ··· 1782 1776 else 1783 1777 ndev->b2b_idx = b2b_mw_idx; 1784 1778 1779 + if (ndev->b2b_idx >= ndev->mw_count) { 1780 + dev_dbg(ndev_dev(ndev), 1781 + "b2b_mw_idx %d invalid for mw_count %u\n", 1782 + b2b_mw_idx, ndev->mw_count); 1783 + return -EINVAL; 1784 + } 1785 + 1785 1786 dev_dbg(ndev_dev(ndev), 1786 1787 "setting up b2b mw idx %d means %d\n", 1787 1788 b2b_mw_idx, ndev->b2b_idx); ··· 1856 1843 case PCI_DEVICE_ID_INTEL_NTB_SS_HSX: 1857 1844 case PCI_DEVICE_ID_INTEL_NTB_PS_HSX: 1858 1845 case PCI_DEVICE_ID_INTEL_NTB_B2B_HSX: 1846 + case PCI_DEVICE_ID_INTEL_NTB_SS_BDX: 1847 + case PCI_DEVICE_ID_INTEL_NTB_PS_BDX: 1848 + case PCI_DEVICE_ID_INTEL_NTB_B2B_BDX: 1859 1849 ndev->hwerr_flags |= NTB_HWERR_SDOORBELL_LOCKUP; 1860 1850 break; 1861 1851 } ··· 1873 1857 case PCI_DEVICE_ID_INTEL_NTB_SS_HSX: 1874 1858 case PCI_DEVICE_ID_INTEL_NTB_PS_HSX: 1875 1859 case PCI_DEVICE_ID_INTEL_NTB_B2B_HSX: 1860 + case PCI_DEVICE_ID_INTEL_NTB_SS_BDX: 1861 + case PCI_DEVICE_ID_INTEL_NTB_PS_BDX: 1862 + case PCI_DEVICE_ID_INTEL_NTB_B2B_BDX: 1876 1863 ndev->hwerr_flags |= NTB_HWERR_SB01BASE_LOCKUP; 1877 1864 break; 1878 1865 } ··· 1897 1878 case PCI_DEVICE_ID_INTEL_NTB_SS_HSX: 1898 1879 case PCI_DEVICE_ID_INTEL_NTB_PS_HSX: 1899 1880 case PCI_DEVICE_ID_INTEL_NTB_B2B_HSX: 1881 + case PCI_DEVICE_ID_INTEL_NTB_SS_BDX: 1882 + case PCI_DEVICE_ID_INTEL_NTB_PS_BDX: 1883 + case PCI_DEVICE_ID_INTEL_NTB_B2B_BDX: 1900 1884 ndev->hwerr_flags |= NTB_HWERR_B2BDOORBELL_BIT14; 1901 1885 break; 1902 1886 } ··· 2018 1996 ndev->ntb.ops = &intel_ntb_ops; 2019 1997 2020 1998 ndev->b2b_off = 0; 2021 - ndev->b2b_idx = INT_MAX; 1999 + ndev->b2b_idx = UINT_MAX; 2022 2000 2023 2001 ndev->bar4_split = 0; 2024 2002 ··· 2256 2234 {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_B2B_SNB)}, 2257 2235 {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_B2B_IVT)}, 2258 2236 {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_B2B_HSX)}, 2237 + {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_B2B_BDX)}, 2259 2238 {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_PS_JSF)}, 2260 2239 {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_PS_SNB)}, 2261 2240 {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_PS_IVT)}, 2262 2241 {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_PS_HSX)}, 2242 + {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_PS_BDX)}, 2263 2243 {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_SS_JSF)}, 2264 2244 {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_SS_SNB)}, 2265 2245 {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_SS_IVT)}, 2266 2246 {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_SS_HSX)}, 2247 + {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_SS_BDX)}, 2267 2248 {0} 2268 2249 }; 2269 2250 MODULE_DEVICE_TABLE(pci, intel_ntb_pci_tbl);
+3
drivers/ntb/hw/intel/ntb_hw_intel.h
··· 67 67 #define PCI_DEVICE_ID_INTEL_NTB_PS_HSX 0x2F0E 68 68 #define PCI_DEVICE_ID_INTEL_NTB_SS_HSX 0x2F0F 69 69 #define PCI_DEVICE_ID_INTEL_NTB_B2B_BWD 0x0C4E 70 + #define PCI_DEVICE_ID_INTEL_NTB_B2B_BDX 0x6F0D 71 + #define PCI_DEVICE_ID_INTEL_NTB_PS_BDX 0x6F0E 72 + #define PCI_DEVICE_ID_INTEL_NTB_SS_BDX 0x6F0F 70 73 71 74 /* Intel Xeon hardware */ 72 75
+91 -35
drivers/ntb/ntb_transport.c
··· 119 119 struct ntb_transport_ctx *transport; 120 120 struct ntb_dev *ndev; 121 121 void *cb_data; 122 - struct dma_chan *dma_chan; 122 + struct dma_chan *tx_dma_chan; 123 + struct dma_chan *rx_dma_chan; 123 124 124 125 bool client_ready; 125 126 bool link_is_up; ··· 298 297 299 298 static int ntb_bus_init(struct ntb_transport_ctx *nt) 300 299 { 301 - list_add(&nt->entry, &ntb_transport_list); 300 + list_add_tail(&nt->entry, &ntb_transport_list); 302 301 return 0; 303 302 } 304 303 ··· 453 452 454 453 out_offset = 0; 455 454 out_offset += snprintf(buf + out_offset, out_count - out_offset, 456 - "NTB QP stats\n"); 455 + "\nNTB QP stats:\n\n"); 457 456 out_offset += snprintf(buf + out_offset, out_count - out_offset, 458 457 "rx_bytes - \t%llu\n", qp->rx_bytes); 459 458 out_offset += snprintf(buf + out_offset, out_count - out_offset, ··· 471 470 out_offset += snprintf(buf + out_offset, out_count - out_offset, 472 471 "rx_err_ver - \t%llu\n", qp->rx_err_ver); 473 472 out_offset += snprintf(buf + out_offset, out_count - out_offset, 474 - "rx_buff - \t%p\n", qp->rx_buff); 473 + "rx_buff - \t0x%p\n", qp->rx_buff); 475 474 out_offset += snprintf(buf + out_offset, out_count - out_offset, 476 475 "rx_index - \t%u\n", qp->rx_index); 477 476 out_offset += snprintf(buf + out_offset, out_count - out_offset, 478 - "rx_max_entry - \t%u\n", qp->rx_max_entry); 477 + "rx_max_entry - \t%u\n\n", qp->rx_max_entry); 479 478 480 479 out_offset += snprintf(buf + out_offset, out_count - out_offset, 481 480 "tx_bytes - \t%llu\n", qp->tx_bytes); ··· 490 489 out_offset += snprintf(buf + out_offset, out_count - out_offset, 491 490 "tx_err_no_buf - %llu\n", qp->tx_err_no_buf); 492 491 out_offset += snprintf(buf + out_offset, out_count - out_offset, 493 - "tx_mw - \t%p\n", qp->tx_mw); 492 + "tx_mw - \t0x%p\n", qp->tx_mw); 494 493 out_offset += snprintf(buf + out_offset, out_count - out_offset, 495 - "tx_index - \t%u\n", qp->tx_index); 494 + "tx_index (H) - \t%u\n", qp->tx_index); 495 + out_offset += snprintf(buf + out_offset, out_count - out_offset, 496 + "RRI (T) - \t%u\n", 497 + qp->remote_rx_info->entry); 496 498 out_offset += snprintf(buf + out_offset, out_count - out_offset, 497 499 "tx_max_entry - \t%u\n", qp->tx_max_entry); 500 + out_offset += snprintf(buf + out_offset, out_count - out_offset, 501 + "free tx - \t%u\n", 502 + ntb_transport_tx_free_entry(qp)); 498 503 499 504 out_offset += snprintf(buf + out_offset, out_count - out_offset, 500 - "\nQP Link %s\n", 505 + "\n"); 506 + out_offset += snprintf(buf + out_offset, out_count - out_offset, 507 + "Using TX DMA - \t%s\n", 508 + qp->tx_dma_chan ? "Yes" : "No"); 509 + out_offset += snprintf(buf + out_offset, out_count - out_offset, 510 + "Using RX DMA - \t%s\n", 511 + qp->rx_dma_chan ? "Yes" : "No"); 512 + out_offset += snprintf(buf + out_offset, out_count - out_offset, 513 + "QP Link - \t%s\n", 501 514 qp->link_is_up ? "Up" : "Down"); 515 + out_offset += snprintf(buf + out_offset, out_count - out_offset, 516 + "\n"); 517 + 502 518 if (out_offset > out_count) 503 519 out_offset = out_count; 504 520 ··· 553 535 } 554 536 entry = list_first_entry(list, struct ntb_queue_entry, entry); 555 537 list_del(&entry->entry); 538 + 556 539 out: 557 540 spin_unlock_irqrestore(lock, flags); 558 541 ··· 1225 1206 { 1226 1207 struct dma_async_tx_descriptor *txd; 1227 1208 struct ntb_transport_qp *qp = entry->qp; 1228 - struct dma_chan *chan = qp->dma_chan; 1209 + struct dma_chan *chan = qp->rx_dma_chan; 1229 1210 struct dma_device *device; 1230 1211 size_t pay_off, buff_off, len; 1231 1212 struct dmaengine_unmap_data *unmap; ··· 1238 1219 goto err; 1239 1220 1240 1221 if (len < copy_bytes) 1241 - goto err_wait; 1222 + goto err; 1242 1223 1243 1224 device = chan->device; 1244 1225 pay_off = (size_t)offset & ~PAGE_MASK; 1245 1226 buff_off = (size_t)buf & ~PAGE_MASK; 1246 1227 1247 1228 if (!is_dma_copy_aligned(device, pay_off, buff_off, len)) 1248 - goto err_wait; 1229 + goto err; 1249 1230 1250 1231 unmap = dmaengine_get_unmap_data(device->dev, 2, GFP_NOWAIT); 1251 1232 if (!unmap) 1252 - goto err_wait; 1233 + goto err; 1253 1234 1254 1235 unmap->len = len; 1255 1236 unmap->addr[0] = dma_map_page(device->dev, virt_to_page(offset), ··· 1292 1273 dmaengine_unmap_put(unmap); 1293 1274 err_get_unmap: 1294 1275 dmaengine_unmap_put(unmap); 1295 - err_wait: 1296 - /* If the callbacks come out of order, the writing of the index to the 1297 - * last completed will be out of order. This may result in the 1298 - * receive stalling forever. 1299 - */ 1300 - dma_sync_wait(chan, qp->last_cookie); 1301 1276 err: 1302 1277 ntb_memcpy_rx(entry, offset); 1303 1278 qp->rx_memcpy++; ··· 1386 1373 break; 1387 1374 } 1388 1375 1389 - if (i && qp->dma_chan) 1390 - dma_async_issue_pending(qp->dma_chan); 1376 + if (i && qp->rx_dma_chan) 1377 + dma_async_issue_pending(qp->rx_dma_chan); 1391 1378 1392 1379 if (i == qp->rx_max_entry) { 1393 1380 /* there is more work to do */ ··· 1454 1441 { 1455 1442 struct ntb_payload_header __iomem *hdr; 1456 1443 struct dma_async_tx_descriptor *txd; 1457 - struct dma_chan *chan = qp->dma_chan; 1444 + struct dma_chan *chan = qp->tx_dma_chan; 1458 1445 struct dma_device *device; 1459 1446 size_t dest_off, buff_off; 1460 1447 struct dmaengine_unmap_data *unmap; ··· 1647 1634 dma_cap_set(DMA_MEMCPY, dma_mask); 1648 1635 1649 1636 if (use_dma) { 1650 - qp->dma_chan = dma_request_channel(dma_mask, ntb_dma_filter_fn, 1651 - (void *)(unsigned long)node); 1652 - if (!qp->dma_chan) 1653 - dev_info(&pdev->dev, "Unable to allocate DMA channel\n"); 1637 + qp->tx_dma_chan = 1638 + dma_request_channel(dma_mask, ntb_dma_filter_fn, 1639 + (void *)(unsigned long)node); 1640 + if (!qp->tx_dma_chan) 1641 + dev_info(&pdev->dev, "Unable to allocate TX DMA channel\n"); 1642 + 1643 + qp->rx_dma_chan = 1644 + dma_request_channel(dma_mask, ntb_dma_filter_fn, 1645 + (void *)(unsigned long)node); 1646 + if (!qp->rx_dma_chan) 1647 + dev_info(&pdev->dev, "Unable to allocate RX DMA channel\n"); 1654 1648 } else { 1655 - qp->dma_chan = NULL; 1649 + qp->tx_dma_chan = NULL; 1650 + qp->rx_dma_chan = NULL; 1656 1651 } 1657 - dev_dbg(&pdev->dev, "Using %s memcpy\n", qp->dma_chan ? "DMA" : "CPU"); 1652 + 1653 + dev_dbg(&pdev->dev, "Using %s memcpy for TX\n", 1654 + qp->tx_dma_chan ? "DMA" : "CPU"); 1655 + 1656 + dev_dbg(&pdev->dev, "Using %s memcpy for RX\n", 1657 + qp->rx_dma_chan ? "DMA" : "CPU"); 1658 1658 1659 1659 for (i = 0; i < NTB_QP_DEF_NUM_ENTRIES; i++) { 1660 1660 entry = kzalloc_node(sizeof(*entry), GFP_ATOMIC, node); ··· 1702 1676 err1: 1703 1677 while ((entry = ntb_list_rm(&qp->ntb_rx_q_lock, &qp->rx_free_q))) 1704 1678 kfree(entry); 1705 - if (qp->dma_chan) 1706 - dma_release_channel(qp->dma_chan); 1679 + if (qp->tx_dma_chan) 1680 + dma_release_channel(qp->tx_dma_chan); 1681 + if (qp->rx_dma_chan) 1682 + dma_release_channel(qp->rx_dma_chan); 1707 1683 nt->qp_bitmap_free |= qp_bit; 1708 1684 err: 1709 1685 return NULL; ··· 1729 1701 1730 1702 pdev = qp->ndev->pdev; 1731 1703 1732 - if (qp->dma_chan) { 1733 - struct dma_chan *chan = qp->dma_chan; 1704 + if (qp->tx_dma_chan) { 1705 + struct dma_chan *chan = qp->tx_dma_chan; 1734 1706 /* Putting the dma_chan to NULL will force any new traffic to be 1735 1707 * processed by the CPU instead of the DAM engine 1736 1708 */ 1737 - qp->dma_chan = NULL; 1709 + qp->tx_dma_chan = NULL; 1710 + 1711 + /* Try to be nice and wait for any queued DMA engine 1712 + * transactions to process before smashing it with a rock 1713 + */ 1714 + dma_sync_wait(chan, qp->last_cookie); 1715 + dmaengine_terminate_all(chan); 1716 + dma_release_channel(chan); 1717 + } 1718 + 1719 + if (qp->rx_dma_chan) { 1720 + struct dma_chan *chan = qp->rx_dma_chan; 1721 + /* Putting the dma_chan to NULL will force any new traffic to be 1722 + * processed by the CPU instead of the DAM engine 1723 + */ 1724 + qp->rx_dma_chan = NULL; 1738 1725 1739 1726 /* Try to be nice and wait for any queued DMA engine 1740 1727 * transactions to process before smashing it with a rock ··· 1886 1843 entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q); 1887 1844 if (!entry) { 1888 1845 qp->tx_err_no_buf++; 1889 - return -ENOMEM; 1846 + return -EBUSY; 1890 1847 } 1891 1848 1892 1849 entry->cb_data = cb; ··· 1997 1954 unsigned int ntb_transport_max_size(struct ntb_transport_qp *qp) 1998 1955 { 1999 1956 unsigned int max; 1957 + unsigned int copy_align; 2000 1958 2001 1959 if (!qp) 2002 1960 return 0; 2003 1961 2004 - if (!qp->dma_chan) 1962 + if (!qp->tx_dma_chan && !qp->rx_dma_chan) 2005 1963 return qp->tx_max_frame - sizeof(struct ntb_payload_header); 1964 + 1965 + copy_align = max(qp->tx_dma_chan->device->copy_align, 1966 + qp->rx_dma_chan->device->copy_align); 2006 1967 2007 1968 /* If DMA engine usage is possible, try to find the max size for that */ 2008 1969 max = qp->tx_max_frame - sizeof(struct ntb_payload_header); 2009 - max -= max % (1 << qp->dma_chan->device->copy_align); 1970 + max -= max % (1 << copy_align); 2010 1971 2011 1972 return max; 2012 1973 } 2013 1974 EXPORT_SYMBOL_GPL(ntb_transport_max_size); 1975 + 1976 + unsigned int ntb_transport_tx_free_entry(struct ntb_transport_qp *qp) 1977 + { 1978 + unsigned int head = qp->tx_index; 1979 + unsigned int tail = qp->remote_rx_info->entry; 1980 + 1981 + return tail > head ? tail - head : qp->tx_max_entry + tail - head; 1982 + } 1983 + EXPORT_SYMBOL_GPL(ntb_transport_tx_free_entry); 2014 1984 2015 1985 static void ntb_transport_doorbell_callback(void *data, int vector) 2016 1986 {
+4 -5
include/linux/ntb.h
··· 522 522 * @speed: OUT - The link speed expressed as PCIe generation number. 523 523 * @width: OUT - The link width expressed as the number of PCIe lanes. 524 524 * 525 - * Set the translation of a memory window. The peer may access local memory 526 - * through the window starting at the address, up to the size. The address 527 - * must be aligned to the alignment specified by ntb_mw_get_range(). The size 528 - * must be aligned to the size alignment specified by ntb_mw_get_range(). 525 + * Get the current state of the ntb link. It is recommended to query the link 526 + * state once after every link event. It is safe to query the link state in 527 + * the context of the link event callback. 529 528 * 530 529 * Return: One if the link is up, zero if the link is down, otherwise a 531 530 * negative value indicating the error number. ··· 794 795 } 795 796 796 797 /** 797 - * ntb_peer_db_clear() - clear bits in the local doorbell register 798 + * ntb_peer_db_clear() - clear bits in the peer doorbell register 798 799 * @ntb: NTB device context. 799 800 * @db_bits: Doorbell bits to clear. 800 801 *
+1
include/linux/ntb_transport.h
··· 83 83 void ntb_transport_link_up(struct ntb_transport_qp *qp); 84 84 void ntb_transport_link_down(struct ntb_transport_qp *qp); 85 85 bool ntb_transport_link_query(struct ntb_transport_qp *qp); 86 + unsigned int ntb_transport_tx_free_entry(struct ntb_transport_qp *qp);