24 Sep, 2019

1 commit


13 Jun, 2019

2 commits

  • Introduce the module parameter 'use_msi' which, when set, uses
    MSI interrupts instead of doorbells for each queue pair (QP). The
    parameter is only available if NTB MSI support is configured into
    the kernel. We also require there to be more than one memory window
    (MW) so that an extra one is available to forward the APIC region.

    To use MSIs, we request one interrupt per QP and forward the MSI address
    and data to the peer using scratch pad registers (SPADS) above the MW
    SPADS. (If there are not enough SPADS the MSI interrupt will not be used.)

    Once registered, we simply use ntb_msi_peer_trigger and the receiving
    ISR simply queues up the rxc_db_work for the queue.

    This addition can significantly improve performance of ntb_transport.
    In a simple, untuned, apples-to-apples comparision using ntb_netdev
    and iperf with switchtec hardware, I see 3.88Gb/s without MSI
    interrupts and 14.1Gb/s wit MSI, which is a more than 3x improvement.

    Signed-off-by: Logan Gunthorpe
    Cc: Dave Jiang
    Cc: Allen Hubbe
    Signed-off-by: Jon Mason

    Logan Gunthorpe
     
  • Dan Carpenter's static checker reported:

    drivers/ntb/ntb_transport.c:1926 ntb_transport_create_queue()
    error: we previously assumed 'qp->tx_dma_chan' could be null (see line 1872)

    This is because the tx_mw_dma_addr is uninitialized in this function and
    may be incorrectly released using a NULL DMA channel.

    In practice this bug will not likely be seen. I'd guess you could hit
    this if you loaded ntb_netdev with use_dma=True, then unloaded it and
    loaded it again after setting the module parameter to use_dma=False.

    To fix this, we simply ensure that tx_mw_dma_addr is always
    initialized to zero. This is the safest in case any other part of the
    code operates on it if it is non-zero.

    Fixes: c59666bb32b9 ("NTB: ntb_transport: Ensure the destination buffer is mapped for TX DMA")
    Signed-off-by: Logan Gunthorpe
    Cc: Dan Carpenter
    Signed-off-by: Jon Mason

    Logan Gunthorpe
     

11 Feb, 2019

2 commits

  • Presently, when ntb_transport is used with DMA and the IOMMU turned on,
    it fails with errors from the IOMMU such as:

    DMAR: DRHD: handling fault status reg 202
    DMAR: [DMA Write] Request device [00:04.0] fault addr
    381fc0340000 [fault reason 05] PTE Write access is not set

    This is because ntb_transport does not map the BAR space with the IOMMU.

    To fix this, we map the entire MW region for each QP after we assign
    the DMA channel. This prevents needing an extra DMA map in the fast
    path.

    Link: https://lore.kernel.org/linux-pci/499934e7-3734-1aee-37dd-b42a5d2a2608@intel.com/
    Signed-off-by: Logan Gunthorpe
    Reviewed-by: Dave Jiang
    Signed-off-by: Jon Mason

    Logan Gunthorpe
     
  • If NTB peer host crashes or reboots, the NTB transport link will be
    down and the MWs of NTB transport will be invalid. But the
    ntb_transport_link_cleanup() does not free these invalid MWs. When
    the NTB peer host is recovered later, NTB transport link will be
    up and the ntb_set_mw() will not reset up MWs. Because the MWs of
    NTB transport are invalid, the NTB transport will not work.

    We can fix it by freeing MWs when NTB transport link is down, then
    the ntb_set_mw() will reset up MWs when NTB transport link is up.

    Signed-off-by: Joey Zhang
    Reviewed-by: Logan Gunthorpe
    Signed-off-by: Jon Mason

    Joey Zhang
     

01 Nov, 2018

2 commits

  • Be a little wasteful if the (likely CMA) message window buffer is not
    suitably aligned after our first attempt; allocate a buffer twice as big
    as we need and manually align our MW buffer within it.

    This was needed on Intel Broadwell DE platforms with intel_iommu=off

    Signed-off-by: Aaron Sierra
    Reviewed-by: Dave Jiang
    Signed-off-by: Jon Mason

    Aaron Sierra
     
  • In preparation to enabling -Wimplicit-fallthrough, mark switch cases
    where we are expecting to fall through.

    Addresses-Coverity-ID: 1373888 ("Missing break in switch")
    Addresses-Coverity-ID: 1373889 ("Missing break in switch")
    Signed-off-by: Gustavo A. R. Silva
    Acked-by: Allen Hubbe
    Signed-off-by: Jon Mason

    Gustavo A. R. Silva
     

13 Jun, 2018

2 commits

  • Pull more overflow updates from Kees Cook:
    "The rest of the overflow changes for v4.18-rc1.

    This includes the explicit overflow fixes from Silvio, further
    struct_size() conversions from Matthew, and a bug fix from Dan.

    But the bulk of it is the treewide conversions to use either the
    2-factor argument allocators (e.g. kmalloc(a * b, ...) into
    kmalloc_array(a, b, ...) or the array_size() macros (e.g. vmalloc(a *
    b) into vmalloc(array_size(a, b)).

    Coccinelle was fighting me on several fronts, so I've done a bunch of
    manual whitespace updates in the patches as well.

    Summary:

    - Error path bug fix for overflow tests (Dan)

    - Additional struct_size() conversions (Matthew, Kees)

    - Explicitly reported overflow fixes (Silvio, Kees)

    - Add missing kvcalloc() function (Kees)

    - Treewide conversions of allocators to use either 2-factor argument
    variant when available, or array_size() and array3_size() as needed
    (Kees)"

    * tag 'overflow-v4.18-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: (26 commits)
    treewide: Use array_size in f2fs_kvzalloc()
    treewide: Use array_size() in f2fs_kzalloc()
    treewide: Use array_size() in f2fs_kmalloc()
    treewide: Use array_size() in sock_kmalloc()
    treewide: Use array_size() in kvzalloc_node()
    treewide: Use array_size() in vzalloc_node()
    treewide: Use array_size() in vzalloc()
    treewide: Use array_size() in vmalloc()
    treewide: devm_kzalloc() -> devm_kcalloc()
    treewide: devm_kmalloc() -> devm_kmalloc_array()
    treewide: kvzalloc() -> kvcalloc()
    treewide: kvmalloc() -> kvmalloc_array()
    treewide: kzalloc_node() -> kcalloc_node()
    treewide: kzalloc() -> kcalloc()
    treewide: kmalloc() -> kmalloc_array()
    mm: Introduce kvcalloc()
    video: uvesafb: Fix integer overflow in allocation
    UBIFS: Fix potential integer overflow in allocation
    leds: Use struct_size() in allocation
    Convert intel uncore to struct_size
    ...

    Linus Torvalds
     
  • The kzalloc_node() function has a 2-factor argument form, kcalloc_node(). This
    patch replaces cases of:

    kzalloc_node(a * b, gfp, node)

    with:
    kcalloc_node(a * b, gfp, node)

    as well as handling cases of:

    kzalloc_node(a * b * c, gfp, node)

    with:

    kzalloc_node(array3_size(a, b, c), gfp, node)

    as it's slightly less ugly than:

    kcalloc_node(array_size(a, b), c, gfp, node)

    This does, however, attempt to ignore constant size factors like:

    kzalloc_node(4 * 1024, gfp, node)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kzalloc_node(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kzalloc_node(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kzalloc_node(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc_node(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc_node(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc_node(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc_node(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc_node(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc_node(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kzalloc_node(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kzalloc_node
    + kcalloc_node
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc_node
    + kcalloc_node
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc_node
    + kcalloc_node
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc_node
    + kcalloc_node
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc_node
    + kcalloc_node
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc_node
    + kcalloc_node
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc_node
    + kcalloc_node
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kzalloc_node
    + kcalloc_node
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kzalloc_node
    + kcalloc_node
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kzalloc_node(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc_node(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc_node(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc_node(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc_node(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc_node(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc_node(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc_node(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kzalloc_node(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc_node(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc_node(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc_node(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc_node(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kzalloc_node(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kzalloc_node(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc_node(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc_node(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc_node(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc_node(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc_node(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc_node(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc_node(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kzalloc_node(C1 * C2 * C3, ...)
    |
    kzalloc_node(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc_node(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc_node(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc_node(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kzalloc_node(sizeof(THING) * C2, ...)
    |
    kzalloc_node(sizeof(TYPE) * C2, ...)
    |
    kzalloc_node(C1 * C2 * C3, ...)
    |
    kzalloc_node(C1 * C2, ...)
    |
    - kzalloc_node
    + kcalloc_node
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc_node
    + kcalloc_node
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc_node
    + kcalloc_node
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc_node
    + kcalloc_node
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc_node
    + kcalloc_node
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kzalloc_node
    + kcalloc_node
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kzalloc_node
    + kcalloc_node
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

12 Jun, 2018

2 commits

  • ntb_transport_create_queue() is never called in atomic context.

    ntb_transport_create_queue() is only called by ntb_netdev_probe(),
    which is set as ".probe" in struct ntb_transport_client.

    Despite never getting called from atomic context,
    ntb_transport_create_queue() calls kzalloc_node() with GFP_ATOMIC,
    which does not sleep for allocation.
    GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
    which can sleep and improve the possibility of sucessful allocation.

    This is found by a static analysis tool named DCNS written by myself.
    And I also manually check it

    Signed-off-by: Jia-Ju Bai
    Signed-off-by: Jon Mason

    Jia-Ju Bai
     
  • ntb_transport_setup_qp_mw() is never called in atomic context.

    ntb_transport_setup_qp_mw() is only called by ntb_transport_link_work(),
    which is set as a parameter of INIT_DELAYED_WORK()
    in ntb_transport_probe().

    Despite never getting called from atomic context,
    ntb_transport_setup_qp_mw() calls kzalloc_node() with GFP_ATOMIC,
    which does not sleep for allocation.
    GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
    which can sleep and improve the possibility of sucessful allocation.

    This is found by a static analysis tool named DCNS written by myself.
    And I also manually check it.

    Signed-off-by: Jia-Ju Bai
    Signed-off-by: Jon Mason

    Jia-Ju Bai
     

29 Jan, 2018

1 commit

  • When using the max_mw_size parameter of ntb_transport to limit the size of
    the Memory windows, communication cannot be established and the queues
    freeze.

    This is because the mw_size that's reported to the peer is correctly
    limited but the size used locally is not. So the MW is initialized
    with a buffer smaller than the window but the TX side is using the
    full window. This means the TX side will be writing to a region of the
    window that points nowhere.

    This is easily fixed by applying the same limit to tx_size in
    ntb_transport_init_queue().

    Fixes: e26a5843f7f5 ("NTB: Split ntb_hw_intel and ntb_transport drivers")
    Signed-off-by: Logan Gunthorpe
    Acked-by: Allen Hubbe
    Cc: Dave Jiang
    Signed-off-by: Jon Mason

    Logan Gunthorpe
     

19 Nov, 2017

1 commit

  • With Switchtec hardware it's impossible to get the alignment parameters
    for a peer's memory window until the peer's driver has configured its
    windows. Strictly speaking, the link doesn't have to be up for this,
    but the link being up is the only way the client can tell that
    the other side has been configured.

    This patch converts ntb_transport and ntb_perf to use this function after
    the link goes up. This simplifies these clients slightly because they
    no longer have to store the alignment parameters. It also tweaks
    ntb_tool so that peer_mw_trans will print zero if it is run before
    the link goes up.

    Signed-off-by: Logan Gunthorpe
    Acked-by: Allen Hubbe
    Signed-off-by: Jon Mason

    Logan Gunthorpe
     

02 Aug, 2017

1 commit

  • It seems that under certain scenarios the SPAD can have bogus values caused
    by an agent (i.e. BIOS or other software) that is not the kernel driver, and
    that causes memory window setup failure. This should not cause the link to
    be disabled because if we do that, the driver will never recover again. We
    have verified in testing that this issue happens and prevents proper link
    recovery.

    Signed-off-by: Dave Jiang
    Acked-by: Allen Hubbe
    Signed-off-by: Jon Mason
    Fixes: 84f766855f61 ("ntb: stop link work when we do not have memory")

    Dave Jiang
     

18 Jul, 2017

1 commit

  • After converting to the new API, both ntb_tool and ntb_transport are
    using ntb_mw_count to iterate through ntb_peer_get_addr when they
    should be using ntb_peer_mw_count.

    This probably isn't an issue with the Intel and AMD drivers but
    this will matter for any future driver with asymetric memory window
    counts.

    Signed-off-by: Logan Gunthorpe
    Acked-by: Allen Hubbe
    Signed-off-by: Jon Mason
    Fixes: 443b9a14ecbe ("NTB: Alter MW API to support multi-ports devices")

    Logan Gunthorpe
     

06 Jul, 2017

3 commits

  • Even though there is no any real NTB hardware, which would have both more
    than two ports and Scratchpad registers, it is logically correct to have
    Scratchpad API accepting a peer port index as well. Intel/AMD drivers utilize
    Primary and Secondary topology to split Scratchpad between connected root
    devices. Since port-index API introduced, Intel/AMD NTB hardware drivers can
    use device port to determine which Scratchpad registers actually belong to
    local and peer devices. The same approach can be used if some potential
    hardware in future will be multi-port and have some set of Scratchpads.
    Here are the brief of changes in the API:
    ntb_spad_count() - return number of Scratchpads per each port
    ntb_peer_spad_addr(pidx, sidx) - address of Scratchpad register of the
    peer device with pidx-index
    ntb_peer_spad_read(pidx, sidx) - read specified Scratchpad register of the
    peer with pidx-index
    ntb_peer_spad_write(pidx, sidx) - write data to Scratchpad register of the
    peer with pidx-index

    Since there is hardware which doesn't support Scratchpad registers, the
    corresponding API methods are now made optional.

    Signed-off-by: Serge Semin
    Acked-by: Allen Hubbe
    Signed-off-by: Jon Mason

    Serge Semin
     
  • Multi-port NTB devices permit to share a memory between all accessible peers.
    Memory Windows API is altered to correspondingly initialize and map memory
    windows for such devices:
    ntb_mw_count(pidx); - number of inbound memory windows, which can be allocated
    for shared buffer with specified peer device.
    ntb_mw_get_align(pidx, widx); - get alignment and size restriction parameters
    to properly allocate inbound memory region.
    ntb_peer_mw_count(); - get number of outbound memory windows.
    ntb_peer_mw_get_addr(widx); - get mapping address of an outbound memory window

    If hardware supports inbound translation configured on the local ntb port:
    ntb_mw_set_trans(pidx, widx); - set translation address of allocated inbound
    memory window so a peer device could access it.
    ntb_mw_clear_trans(pidx, widx); - clear the translation address of an inbound
    memory window.

    If hardware supports outbound translation configured on the peer ntb port:
    ntb_peer_mw_set_trans(pidx, widx); - set translation address of a memory
    window retrieved from a peer device
    ntb_peer_mw_clear_trans(pidx, widx); - clear the translation address of an
    outbound memory window

    Signed-off-by: Serge Semin
    Acked-by: Allen Hubbe
    Signed-off-by: Jon Mason

    Serge Semin
     
  • There is some NTB hardware, which can combine more than just two domains
    over NTB. For instance, some IDT PCIe-switches can have NTB-functions
    activated on more than two-ports. The different domains are distinguished
    by ports they are connected to. So the new port-related methods are added to
    the NTB API:
    ntb_port_number() - return local port
    ntb_peer_port_count() - return number of peers local port can connect to
    ntb_peer_port_number(pdix) - return port number by it index
    ntb_peer_port_idx(port) - return port index by it number

    Current test-drivers aren't changed much. They still support two-ports devices
    for the time being while multi-ports hardware drivers aren't added.

    By default port-related API is declared for two-ports hardware.
    So corresponding hardware drivers won't need to implement it.

    Signed-off-by: Serge Semin
    Signed-off-by: Jon Mason

    Serge Semin
     

20 Jun, 2017

3 commits

  • Do not sleep in ntb_async_tx_submit, which could deadlock.
    This reverts commit "8c874cc140d667f84ae4642bb5b5e0d6396d2ca4"

    Fixes: 8c874cc140d6 ("NTB: Address out of DMA descriptor issue with NTB")
    Reported-by: Jia-Ju Bai
    Signed-off-by: Allen Hubbe
    Acked-by: Dave Jiang
    Signed-off-by: Jon Mason

    Allen Hubbe
     
  • A divide by zero error occurs if qp_count is less than mw_count because
    num_qps_mw is calculated to be zero. The calculation appears to be
    incorrect.

    The requirement is for num_qps_mw to be set to qp_count / mw_count
    with any remainder divided among the earlier mws.

    For example, if mw_count is 5 and qp_count is 12 then mws 0 and 1
    will have 3 qps per window and mws 2 through 4 will have 2 qps per window.
    Thus, when mw_num < qp_count % mw_count, num_qps_mw is 1 higher
    than when mw_num >= qp_count.

    Signed-off-by: Logan Gunthorpe
    Fixes: e26a5843f7f5 ("NTB: Split ntb_hw_intel and ntb_transport drivers")
    Acked-by: Allen Hubbe
    Signed-off-by: Jon Mason

    Logan Gunthorpe
     
  • In cases where there are more mw's than spads/2-2, the mw count gets
    reduced to match the limitation. ntb_transport also tries to ensure that
    there are fewer qps than mws but uses the full mw count instead of
    the reduced one. When this happens, the math in
    'ntb_transport_setup_qp_mw' will get confused and result in a kernel
    paging request bug.

    This patch fixes the bug by reducing qp_count to the reduced mw count
    instead of the full mw count.

    Signed-off-by: Logan Gunthorpe
    Fixes: e26a5843f7f5 ("NTB: Split ntb_hw_intel and ntb_transport drivers")
    Acked-by: Allen Hubbe
    Signed-off-by: Jon Mason

    Logan Gunthorpe
     

17 Feb, 2017

2 commits

  • Fix typo causing ntb_transport_create_queue to select the first
    queue every time, instead of using the next free queue.

    Signed-off-by: Thomas VanSelus
    Signed-off-by: Aaron Sierra
    Acked-by: Allen Hubbe
    Fixes: fce8a7bb5 ("PCI-Express Non-Transparent Bridge Support")
    Signed-off-by: Jon Mason

    Thomas VanSelus
     
  • The call to debugfs_remove_recursive(qp->debugfs_dir) of the sub-level
    directory must not be later than
    debugfs_remove_recursive(nt_debugfs_dir) of the top-level directory.
    Otherwise, the sub-level directory will not exist, and it would be
    invalid (panic) to attempt to remove it. This removes the top-level
    directory last, after sub-level directories have been cleaned up.

    Signed-off-by: Allen Hubbe
    Fixes: e26a5843f ("NTB: Split ntb_hw_intel and ntb_transport drivers")
    Signed-off-by: Jon Mason

    Allen Hubbe
     

24 Dec, 2016

2 commits


14 Nov, 2016

1 commit


08 Aug, 2016

2 commits

  • Adding support on the rx DMA path to allow recovery of errors when
    DMA responds with error status and abort all the subsequent ops.

    Signed-off-by: Dave Jiang
    Acked-by: Allen Hubbe
    Cc: Jon Mason
    Cc: linux-ntb@googlegroups.com
    Signed-off-by: Vinod Koul

    Dave Jiang
     
  • Adding support on the tx DMA path to allow recovery of errors when
    DMA responds with error status and abort all the subsequent ops.

    Signed-off-by: Dave Jiang
    Acked-by: Allen Hubbe
    Cc: Jon Mason
    Cc: linux-ntb@googlegroups.com
    Signed-off-by: Vinod Koul

    Dave Jiang
     

05 Aug, 2016

2 commits

  • I'm working on hardware that currently has a limited number of
    scratchpad registers and ntb_ndev fails with no clue as to why. I
    feel it is better to fail early and provide a reasonable error message
    then to fail later on.

    The same is done to ntb_perf, but it doesn't currently require enough
    spads to actually fail. I've also removed the unused SPAD_MSG and
    SPAD_ACK enums so that MAX_SPAD accurately reflects the number of
    spads used.

    Signed-off-by: Logan Gunthorpe
    Acked-by: Dave Jiang
    Signed-off-by: Jon Mason

    Logan Gunthorpe
     
  • Currently we only allocate a fixed default number of descriptors for the tx
    and rx side. We should dynamically resize it to the number of descriptors
    resides in the transport rings. We should know the number of transmit
    descriptors at initializaiton. We will allocate the default number of
    descriptors for receive side and allocate additional ones when we know the
    actual max entries for receive.

    Signed-off-by: Dave Jiang
    Acked-by: Allen Hubbe
    Signed-off-by: Jon Mason

    Dave Jiang
     

18 Mar, 2016

2 commits


11 Jan, 2016

2 commits

  • The transport right now does not handle the case where we run out of DMA
    descriptors. We just fail when we do not succeed. Adding code to retry for
    a bit attempting to use the DMA engine instead of instantly fail to CPU
    copy.

    Signed-off-by: Dave Jiang
    Reviewed-by: Allen Hubbe
    Signed-off-by: Jon Mason

    Dave Jiang
     
  • The transmit overrun avoidance error path in ntb_process_tx accidentally
    swapped the first two values being passed to the tx_handler client.
    This could result in crashes in the ntb_netdev (or other out-of-tree NTB
    clients).

    Reported-by: Alex Depoutovitch
    Signed-off-by: Jon Mason

    Jon Mason
     

09 Nov, 2015

5 commits

  • resource_size_t may be 32-bit wide on some architectures, which causes
    this warning when building the NTB code:

    drivers/ntb/ntb_transport.c: In function 'ntb_transport_link_work':
    drivers/ntb/ntb_transport.c:828:46: warning: right shift count >= width of type [-Wshift-count-overflow]

    The warning is harmless but can be avoided by using the upper_32_bits()
    macro.

    Signed-off-by: Arnd Bergmann
    Fixes: e26a5843f7f5 ("NTB: Split ntb_hw_intel and ntb_transport drivers")
    Signed-off-by: Jon Mason

    Arnd Bergmann
     
  • Order of operations issue with the QP Num and MW count, which would
    result in the receive buffer pointer being invalid if there are more
    than 1 MW. Corrected with parenthesis to enforce the proper order of
    operations.

    Reported-by: John I. Kading
    Signed-off-by: Jon Mason

    Jon Mason
     
  • These variables were not used anywhere. So remove them.

    Signed-off-by: Sudip Mukherjee
    Signed-off-by: Jon Mason

    Sudip Mukherjee
     
  • We were accessing nt->mw_vec after freeing it. Fix the error path so
    that we free nt->mw_vec after we have finished using it.

    Signed-off-by: Sudip Mukherjee
    Signed-off-by: Jon Mason

    Sudip Mukherjee
     
  • smatch detected an issue in the function ntb_transport_max_size() where
    we could be dereferencing a dma channel pointer when it is NULL.

    Reported-by: Dan Carpenter
    Signed-off-by: Dave Jiang
    Signed-off-by: Jon Mason

    Dave Jiang
     

08 Sep, 2015

1 commit

  • Allocate two DMA channels, one for TX operation and one for RX
    operation, instead of having one DMA channel for everything. This
    provides slightly better performance, and also will make error handling
    cleaner later on.

    Signed-off-by: Dave Jiang
    Signed-off-by: Jon Mason

    Dave Jiang