16 Mar, 2019

1 commit

  • Pull NTB updates from Jon Mason:

    - fixes for switchtec debugability and mapping table entries

    - NTB transport improvements

    - a reworking of the peer_db_addr for better abstraction

    * tag 'ntb-5.1' of git://github.com/jonmason/ntb:
    NTB: add new parameter to peer_db_addr() db_bit and db_data
    NTB: ntb_transport: Ensure the destination buffer is mapped for TX DMA
    NTB: ntb_transport: Free MWs in ntb_transport_link_cleanup()
    ntb_hw_switchtec: Added support of >=4G memory windows
    ntb_hw_switchtec: NT req id mapping table register entry number should be 512
    ntb_hw_switchtec: debug print 64bit aligned crosslink BAR Numbers

    Linus Torvalds
     

14 Feb, 2019

1 commit

  • NTB door bell usage depends on NTB hardware.

    ex: intel NTB gen1 has one peer door bell register which can be controlled
    by the bitmap writen to it, while Intel NTB gen3 has a registers
    per door bell and the data trigering the each door bell is always 1.

    therefore exposing only peer door bell address forcing the user
    to be aware of such low level details

    Signed-off-by: Leonid Ravich
    Acked-by: Logan Gunthorpe
    Acked-by: Dave Jiang
    Acked-by: Allen Hubbe
    Signed-off-by: Jon Mason

    Leonid Ravich
     

11 Feb, 2019

4 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
     
  • Current Switchtec's BAR setup registers are limited to 32bits,
    corresponding to the maximum MW (memory window) size is
    Signed-off-by: Paul Selles
    Signed-off-by: Wesley Sheng
    Reviewed-by: Logan Gunthorpe
    Signed-off-by: Jon Mason

    Paul Selles
     
  • Switchtec NTB crosslink BARs are 64bit addressed but they are printed as
    32bit addressed BARs. Fix debug log to increment the BAR numbers by 2 to
    reflect the 64bit address alignment.

    Fixes: 017525018202 ("ntb_hw_switchtec: Add initialization code for crosslink")
    Signed-off-by: Paul Selles
    Signed-off-by: Wesley Sheng
    Reviewed-by: Logan Gunthorpe
    Signed-off-by: Jon Mason

    Paul Selles
     

28 Jan, 2019

1 commit


22 Jan, 2019

2 commits


08 Jan, 2019

1 commit

  • We already need to zero out memory for dma_alloc_coherent(), as such
    using dma_zalloc_coherent() is superflous. Phase it out.

    This change was generated with the following Coccinelle SmPL patch:

    @ replace_dma_zalloc_coherent @
    expression dev, size, data, handle, flags;
    @@

    -dma_zalloc_coherent(dev, size, handle, flags)
    +dma_alloc_coherent(dev, size, handle, flags)

    Suggested-by: Christoph Hellwig
    Signed-off-by: Luis Chamberlain
    [hch: re-ran the script on the latest tree]
    Signed-off-by: Christoph Hellwig

    Luis Chamberlain
     

01 Nov, 2018

9 commits

  • Since IDT PCIe-switch temperature sensor is now always available
    irregardless of the EEPROM/BIOS settings, Kconfig and in-code
    description should be properly altered. In addition lets update
    the driver copyright lines.

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

    Serge Semin
     
  • IDT PCIe-switch temperature sensor interface is very broken. First
    of all only a few combinations of TMPCTL threshold enable bits
    really cause the interrupts unmasked. Even if an individual bit
    indicates the event unmasked, corresponding IRQ just isn't generated.
    Most of the threshold enable bits combinations are in fact useless and
    non of them can help to create a fully functional alarm interface.
    So to speak, we can't create a well defined hwmon alarms based on
    the IDT PCI-switch threshold IRQs.

    Secondly a single threshold IRQ (not a combination of thresholds) can
    be successfully enabled without the issue described above. But in this
    case we experienced an enormous number of interrupts generated by
    the chip if the temperature got near the enabled threshold value. Filter
    adjustment didn't help much. It also doesn't provide a hysteresis settings.
    Due to the temperature sample fluctuations near the threshold the
    interrupts spate makes the system nearly unusable until the temperature
    value finally settled so being pushed either to be fully higher or lower
    the threshold.

    All of these issues makes the temperature sensor alarm interface useless
    and even at some point dangerous to be used in the driver. In this case
    it is safer to completely discard it and disable the temperature alarm
    interrupts.

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

    Serge Semin
     
  • IDT PCIe switches provide an embedded temperature sensor working
    within [0; 127.5]C with resolution of 0.5C. They also can generate
    a PCIe upstream interrupt in case if the temperature passes through
    specified thresholds. Since this thresholds interface is very broken
    the created hwmon-sysfs interface exposes only the next set of hwmon
    nodes: current input temperature, lowest and highest values measured,
    history resetting, value offset. HWmon alarm interface isn't provided.

    IDT PCIe switch also've got an ADC/filter settings of the sensor.
    This driver doesn't expose them to the hwmon-sysfs interface at the
    moment, except the offset node.

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

    Serge Semin
     
  • In order to create a hwmon interface for the IDT PCIe-switch temperature
    sensor the already available reader method should be improved. Particularly
    we need to redesign it so one would be able to read temperature/offset
    values from registers of the passed types. Since IDT sensor interface
    provides temperature in unsigned format 0:7:1 (7 bits for real value
    and one for fraction) we also need to have helpers for the typical sysfs
    temperature data type conversion to and from this format. Even though
    the IDT PCIe-switch provided temperature offset got the same but signed
    type it can be translated by these methods too.

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

    Serge Semin
     
  • 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
     
  • IDT NTB driver sets the upper limit of actual translation address
    being written to the corresponding memory window setup. It is achieved
    by BARLIMITx register initialization. Needless to say, that the register
    works within PCIe bus address space.

    In general CPU and PCIe address spaces are different. It means,
    that addresses used for Memory TLPs routine can be different from
    CPU addresses. While in most of cases they are the same, there are
    exceptions when the proper mapping must be performed to have the
    portable driver code. There used to be a virt_to_bus()/bus_to_virt()
    interface for this purpose. But it's deprecated now. It was also a
    mistake to use pci_resource_start() since the return address of the
    method is at the CPU address space. In order to achieve the desired
    purpose we need to use pci_bus_address() helper. This method shall
    return a PCIe bus base address of the corresponding BAR resource.

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

    Serge Semin
     
  • Both devm_kcalloc() and devm_kzalloc() return NULL on error. They
    never return error pointers.

    The use of IS_ERR_OR_NULL is currently applied to the wrong
    context.

    Fix this by replacing IS_ERR_OR_NULL with regular NULL checks.

    Fixes: bf2a952d31d2 ("NTB: Add IDT 89HPESxNTx PCIe-switches support")
    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Jon Mason

    Gustavo A. R. Silva
     
  • ndev_vec_mask() should be returning u64 mask value instead of int.
    Otherwise the mask value returned can be incorrect for larger
    vectors.

    Fixes: e26a5843f7f5 ("NTB: Split ntb_hw_intel and ntb_transport drivers")

    Signed-off-by: Dave Jiang
    Tested-by: Lucas Van
    Signed-off-by: Jon Mason

    Dave Jiang
     

30 Jun, 2018

1 commit

  • Move the Microsemi Switchtec PCI Vendor ID (same as
    PCI_VENDOR_ID_PMC_Sierra) to pci_ids.h. Also, replace Microsemi class
    constants with the standard PCI definitions.

    Signed-off-by: Doug Meyer
    [bhelgaas: restore SPDX (I assume it was removed by mistake), remove
    device ID definitions]
    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Logan Gunthorpe

    Doug Meyer
     

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

6 commits


29 Jan, 2018

12 commits

  • Sparse is whining about the u32 and __le32 mixed usage in the driver

    drivers/ntb/test/ntb_perf.c:288:21: warning: cast to restricted __le32
    drivers/ntb/test/ntb_perf.c:295:37: warning: incorrect type in argument 4 (different base types)
    drivers/ntb/test/ntb_perf.c:295:37: expected unsigned int [unsigned] [usertype] val
    drivers/ntb/test/ntb_perf.c:295:37: got restricted __le32 [usertype]
    ...

    NTB hardware drivers shall accept CPU-endian data and translate it to
    the portable formate by internal means, so the explicit conversions
    are not necessary before Scratchpad/Messages API usage anymore.

    Fixes: b83003b3fdc1 ("NTB: ntb_perf: Add full multi-port NTB API support")
    Signed-off-by: Serge Semin
    Acked-by: Arnd Bergmann
    Signed-off-by: Jon Mason

    Serge Semin
     
  • We accidentally return success if dmaengine_submit() fails. The fix is
    to preserve the error code from dma_submit_error().

    Signed-off-by: Dan Carpenter
    Acked-by: Serge Semin
    Signed-off-by: Jon Mason

    Dan Carpenter
     
  • Fixes the following sparse warnings:

    drivers/ntb/hw/mscc/ntb_hw_switchtec.c:1552:6: warning:
    symbol 'switchtec_ntb_remove' was not declared. Should it be static?

    Signed-off-by: Wei Yongjun
    Reviewed-by: Logan Gunthorpe
    Signed-off-by: Jon Mason

    Wei Yongjun
     
  • Currently there is a memory leak on buf when the call to ntb_mw_get_align
    fails. Add an exit err label and jump to this so that kfree on buf frees
    the memory.

    Detected by CoverityScan, CID#1464286 ("Resource leak")

    Fixes: d637628ce00c ("NTB: ntb_tool: Add full multi-port NTB API support")
    Signed-off-by: Colin Ian King
    Acked-by: Serge Semin
    Signed-off-by: Jon Mason

    Colin Ian King
     
  • On 32-bit architectures, resource_size_t is usually 'unsigned int' or
    'unsigned long' but not 'unsigned long long', so we get a warning
    about printing the wrong data:

    drivers/ntb/test/ntb_perf.c: In function 'perf_setup_peer_mw':
    drivers/ntb/test/ntb_perf.c:1390:35: error: format '%llx' expects argument of type 'long long unsigned int', but argument 4 has type 'resource_size_t {aka unsigned int}' [-Werror=format=]

    This changes the format string to the special %pa that is already
    used elsewhere in the same file.

    Fixes: b83003b3fdc1 ("NTB: ntb_perf: Add full multi-port NTB API support")
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Jon Mason

    Arnd Bergmann
     
  • Since Switchtec patch there has been a new topology added to
    the NTB API. It's called NTB_TOPO_SWITCH and dedicated for
    PCIe switch chips. Even though topo field isn't used within the
    IDT driver much, lets set it for the sake of unification.

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

    Serge Semin
     
  • Former NTB Performance driver could only work with NTB devices, which
    got Scratchpads available and had just two ports. Since there are
    devices, which don't have Scratchpads and got more than two peer
    ports, the performance measuring tool needs to be rewritten. This
    patch adds the ability to test any available NTB peer.
    Additionally it allows to set NTB memory windows up using any
    available data exchange interface: Scratchpad or Message registers.
    Some cleanups are also added here.

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

    Serge Semin
     
  • Former NTB Debugging tool driver supported only the limited
    functionality of the recently updated NTB API, which is now available
    to work with the truly NTB multi-port devices and devices, which
    got NTB Message registers instead of Scratchpads. This patch
    fully rewrites the driver so one would fully expose all the new
    NTB API interfaces. Particularly it concerns the Message registers,
    peer ports API, NTB link settings. Additional cleanups are also added
    here.

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

    Serge Semin
     
  • Current Ping Pong driver can't truly work with multi-port devices.
    Additionally it requires the Scratchpad registers being available
    on NTB device. This patches rewrites the driver so one would
    perform the cyclic Ping-Pong algorithm around all the available
    NTB peers and makes it working with NTB hardware, which doesn't
    support Scratchpads, but such alternative as NTB Message register.
    Additional cleanups are also added here.

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

    Serge Semin
     
  • The dma_mask and dma_coherent_mask fields of the NTB struct device
    weren't initialized in hardware drivers. In fact it should be done
    instead of PCIe interface usage, since NTB clients are supposed to
    use NTB API and left unaware of real hardware implementation.
    In addition to that ntb_device_register() method shouldn't clear
    the passed ntb_dev structure, since it dma_mask is initialized
    by hardware drivers.

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

    Serge Semin
     
  • There is a common methods signature form used over all the NTB API
    like functions naming scheme, arguments names and order, etc.
    Recently added NTB messaging API IO callbacks were named a bit
    different so should be renamed to be in compliance with the rest
    of the API.

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

    Serge Semin
     
  • Newer gcc (version 7 and 8 presumably) warn about a statement mixing
    the << operator with logical and:

    drivers/ntb/hw/mscc/ntb_hw_switchtec.c: In function 'switchtec_ntb_init_sndev':
    drivers/ntb/hw/mscc/ntb_hw_switchtec.c:888:24: error: '<
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Jon Mason

    Arnd Bergmann