1. 12 Aug, 2022 1 commit
  2. 09 Aug, 2022 15 commits
    • Dan Carpenter's avatar
      NTB: EPF: Tidy up some bounds checks · b8c0aa9b
      Dan Carpenter authored
      This sscanf() is reading from the filename which was set by the kernel
      so it should be trust worthy.  Although the data is likely trust worthy
      there is some bounds checking but unfortunately, it is not complete or
      consistent.  Additionally, the Smatch static checker marks everything
      that comes from sscanf() as tainted and so Smatch complains that this
      code can lead to an out of bounds issue.  Let's clean things up and make
      Smatch happy.
      
      The first problem is that there is no bounds checking in the _show()
      functions.  The _store() and _show() functions are very similar so make
      the bounds checking the same in both.
      
      The second issue is that if "win_no" is zero it leads to an array
      underflow so add an if (win_no <= 0) check for that.
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Acked-by: default avatarSouptick Joarder (HPE) <jrdr.linux@gmail.com>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      b8c0aa9b
    • Dan Carpenter's avatar
      NTB: EPF: Fix error code in epf_ntb_bind() · 3305f43c
      Dan Carpenter authored
      Return an error code if pci_register_driver() fails.  Don't return
      success.
      
      Fixes: da51fd247424 ("NTB: EPF: support NTB transfer between PCI RC and EP connection")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Acked-by: default avatarSouptick Joarder (HPE) <jrdr.linux@gmail.com>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      3305f43c
    • Tom Rix's avatar
      PCI: endpoint: pci-epf-vntb: reduce several globals to statics · ae9f38ad
      Tom Rix authored
      sparse reports
      drivers/pci/endpoint/functions/pci-epf-vntb.c:975:5: warning: symbol 'pci_read' was not declared. Should it be static?
      drivers/pci/endpoint/functions/pci-epf-vntb.c:984:5: warning: symbol 'pci_write' was not declared. Should it be static?
      drivers/pci/endpoint/functions/pci-epf-vntb.c:989:16: warning: symbol 'vpci_ops' was not declared. Should it be static?
      
      These functions and variables are only used in pci-epf-vntb.c, so their storage
      class specifiers should be static.
      
      Fixes: ff32fac00d97 ("NTB: EPF: support NTB transfer between PCI RC and EP connection")
      Signed-off-by: default avatarTom Rix <trix@redhat.com>
      Acked-by: default avatarFrank Li <Frank.Li@nxp.com>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      ae9f38ad
    • Yang Yingliang's avatar
      PCI: endpoint: pci-epf-vntb: fix error handle in epf_ntb_mw_bar_init() · 8e4bfbe6
      Yang Yingliang authored
      In error case of epf_ntb_mw_bar_init(), memory window BARs should be
      cleared, so add 'num_mws' parameter in epf_ntb_mw_bar_clear() and
      calling it in error path to clear the BARs. Also add missing error
      code when pci_epc_mem_alloc_addr() fails.
      
      Fixes: ff32fac00d97 ("NTB: EPF: support NTB transfer between PCI RC and EP connection")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      8e4bfbe6
    • Ren Zhijie's avatar
      PCI: endpoint: Fix Kconfig dependency · 556a2c7d
      Ren Zhijie authored
      If CONFIG_NTB is not set and CONFIG_PCI_EPF_VNTB is y.
      
      make ARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu-, will be failed, like this:
      
      drivers/pci/endpoint/functions/pci-epf-vntb.o: In function `epf_ntb_cmd_handler':
      pci-epf-vntb.c:(.text+0x95e): undefined reference to `ntb_db_event'
      pci-epf-vntb.c:(.text+0xa1f): undefined reference to `ntb_link_event'
      pci-epf-vntb.c:(.text+0xa42): undefined reference to `ntb_link_event'
      drivers/pci/endpoint/functions/pci-epf-vntb.o: In function `pci_vntb_probe':
      pci-epf-vntb.c:(.text+0x1250): undefined reference to `ntb_register_device'
      
      The functions ntb_*() are defined in drivers/ntb/core.c, which need CONFIG_NTB setting y to be build-in.
      To fix this build error, add depends on NTB.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Fixes: ff32fac00d97("NTB: EPF: support NTB transfer between PCI RC and EP connection")
      Signed-off-by: default avatarRen Zhijie <renzhijie2@huawei.com>
      Acked-by: default avatarFrank Li <frank.li@nxp.com>
      Acked-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Tested-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
      Reported-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      556a2c7d
    • Colin Ian King's avatar
      NTB: EPF: set pointer addr to null using NULL rather than 0 · 7b14a5e9
      Colin Ian King authored
      The pointer addr is being set to null using 0. Use NULL instead.
      
      Cleans up sparse warning:
      warning: Using plain integer as NULL pointer
      Signed-off-by: default avatarColin Ian King <colin.i.king@gmail.com>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      7b14a5e9
    • Bagas Sanjaya's avatar
      Documentation: PCI: extend subheading underline for "lspci output" section · 9458c27a
      Bagas Sanjaya authored
      The underline syntax for "lspci output..." section is off-by-one less
      than the section heading's length, hence triggers the warning:
      
      Documentation/PCI/endpoint/pci-vntb-howto.rst:131: WARNING: Title underline too short.
      
      Extend the underline by one to match the heading length.
      
      Link: https://lore.kernel.org/linux-next/20220621200235.211b2e32@canb.auug.org.au/
      Fixes: 0c4b285d9636cc ("Documentation: PCI: Add specification for the PCI vNTB function device")
      Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Cc: Kishon Vijay Abraham I <kishon@ti.com>
      Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
      Cc: "Krzysztof Wilczyński" <kw@linux.com>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Frank Li <Frank.Li@nxp.com>
      Cc: linux-pci@vger.kernel.org
      Cc: linux-next@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarBagas Sanjaya <bagasdotme@gmail.com>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      9458c27a
    • Bagas Sanjaya's avatar
      Documentation: PCI: Use code-block block for scratchpad registers diagram · e9ac6e33
      Bagas Sanjaya authored
      The diagram in "Scratchpad Registers" isn't formatted inside code block,
      hence triggers indentation warning:
      
      Documentation/PCI/endpoint/pci-vntb-function.rst:82: WARNING: Unexpected indentation.
      
      Fix the warning by using code-block directive to format the diagram
      inside code block, as in other diagrams in Documentation/. While at it,
      unindent the preceeding text.
      
      Link: https://lore.kernel.org/linux-next/20220621200235.211b2e32@canb.auug.org.au/
      Fixes: 0c4b285d9636cc ("Documentation: PCI: Add specification for the PCI vNTB function device")
      Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Cc: Kishon Vijay Abraham I <kishon@ti.com>
      Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
      Cc: "Krzysztof Wilczyński" <kw@linux.com>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Frank Li <Frank.Li@nxp.com>
      Cc: linux-pci@vger.kernel.org
      Cc: linux-next@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarBagas Sanjaya <bagasdotme@gmail.com>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      e9ac6e33
    • Frank Li's avatar
      Documentation: PCI: Add specification for the PCI vNTB function device · 4ac8c8e5
      Frank Li authored
      Add specification for the PCI vNTB function device. The endpoint function
      driver and the host PCI driver should be created based on this
      specification.
      Signed-off-by: default avatarFrank Li <Frank.Li@nxp.com>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      4ac8c8e5
    • Frank Li's avatar
      PCI: endpoint: Support NTB transfer between RC and EP · e35f56bb
      Frank Li authored
      Add NTB function driver and virtual PCI Bus and Virtual NTB driver
      to implement communication between PCIe Root Port and PCIe EP devices
      
      ┌────────────┐         ┌─────────────────────────────────────┐
      │            │         │                                     │
      ├────────────┤         │                      ┌──────────────┤
      │ NTB        │         │                      │ NTB          │
      │ NetDev     │         │                      │ NetDev       │
      ├────────────┤         │                      ├──────────────┤
      │ NTB        │         │                      │ NTB          │
      │ Transfer   │         │                      │ Transfer     │
      ├────────────┤         │                      ├──────────────┤
      │            │         │                      │              │
      │  PCI NTB   │         │                      │              │
      │    EPF     │         │                      │              │
      │   Driver   │         │                      │ PCI Virtual  │
      │            │         ├───────────────┐      │ NTB Driver   │
      │            │         │ PCI EP NTB    │◄────►│              │
      │            │         │  FN Driver    │      │              │
      ├────────────┤         ├───────────────┤      ├──────────────┤
      │            │         │               │      │              │
      │  PCI Bus   │ ◄─────► │  PCI EP Bus   │      │  Virtual PCI │
      │            │  PCI    │               │      │     Bus      │
      └────────────┘         └───────────────┴──────┴──────────────┘
      PCIe Root Port                        PCI EP
      
      This driver includes 3 parts:
       1 PCI EP NTB function driver
       2 Virtual PCI bus
       3 PCI virtual NTB driver, which is loaded only by above virtual PCI bus
      Signed-off-by: default avatarFrank Li <Frank.Li@nxp.com>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      e35f56bb
    • Frank Li's avatar
      NTB: epf: Allow more flexibility in the memory BAR map method · e75d5ae8
      Frank Li authored
      Support the below BAR configuration methods for epf NTB.
      
      BAR 0: config and scratchpad
      BAR 2: doorbell
      BAR 4: memory map windows
      
      Set difference BAR number information into struct ntb_epf_data. So difference
      VID/PID can choose different BAR configurations. There are difference
      BAR map method between epf NTB and epf vNTB Endpoint function.
      Signed-off-by: default avatarFrank Li <Frank.Li@nxp.com>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      e75d5ae8
    • Frank Li's avatar
      PCI: designware-ep: Allow pci_epc_set_bar() update inbound map address · 4284c88f
      Frank Li authored
      ntb_mw_set_trans() will set memory map window after endpoint function
      driver bind. The inbound map address need be updated dynamically when
      using NTB by PCIe Root Port and PCIe Endpoint connection.
      
      Checking if iatu already assigned to the BAR, if yes, using assigned iatu
      number to update inbound address map and skip set BAR's register.
      Signed-off-by: default avatarFrank Li <Frank.Li@nxp.com>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      4284c88f
    • Dave Jiang's avatar
      ntb: intel: add GNR support for Intel PCIe gen5 NTB · a914fc52
      Dave Jiang authored
      Add Intel Granite Rapids NTB PCI device ID and related enabling.
      Expectation is same hardware interface as Saphire Rapids Xeon platforms.
      Signed-off-by: default avatarDave Jiang <dave.jiang@intel.com>
      Acked-by: default avatarAllen Hubbe <allenbh@gmail.com>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      a914fc52
    • Dan Carpenter's avatar
      NTB: ntb_tool: uninitialized heap data in tool_fn_write() · 45e1058b
      Dan Carpenter authored
      The call to:
      
      	ret = simple_write_to_buffer(buf, size, offp, ubuf, size);
      
      will return success if it is able to write even one byte to "buf".
      The value of "*offp" controls which byte.  This could result in
      reading uninitialized data when we do the sscanf() on the next line.
      
      This code is not really desigined to handle partial writes where
      *offp is non-zero and the "buf" is preserved and re-used between writes.
      Just ban partial writes and replace the simple_write_to_buffer() with
      copy_from_user().
      
      Fixes: 578b881b ("NTB: Add tool test client")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      45e1058b
    • Justin Stitt's avatar
      ntb: idt: fix clang -Wformat warnings · a44252d5
      Justin Stitt authored
      When building with Clang we encounter these warnings:
      | drivers/ntb/hw/idt/ntb_hw_idt.c:2409:28: error: format specifies type
      | 'unsigned char' but the argument has type 'int' [-Werror,-Wformat]
      | "\t%hhu-%hhu.\t", idx + cnt - 1);
      -
      | drivers/ntb/hw/idt/ntb_hw_idt.c:2438:29: error: format specifies type
      | 'unsigned char' but the argument has type 'int' [-Werror,-Wformat]
      | "\t%hhu-%hhu.\t", idx + cnt - 1);
      -
      | drivers/ntb/hw/idt/ntb_hw_idt.c:2484:15: error: format specifies type
      | 'unsigned char' but the argument has type 'int' [-Werror,-Wformat], src);
      
      For the first two warnings the format specifier used is `%hhu` which
      describes a u8. Both `idx` and `cnt` are u8 as well. However, the
      expression as a whole is promoted to an int as you cannot get
      smaller-than-int from addition. Therefore, to fix the warning, use the
      promoted-to-type's format specifier -- in this case `%d`.
      
      example:
      ``
      uint8_t a = 4, b = 7;
      int size = sizeof(a + b - 1);
      printf("%d\n", size);
      // output: 4
      ```
      
      For the last warning, src is of type `int` while the format specifier
      describes a u8. The fix here is just to use the proper specifier `%d`.
      
      See more:
      (https://wiki.sei.cmu.edu/confluence/display/c/INT02-C.+Understand+integer+conversion+rules)
      "Integer types smaller than int are promoted when an operation is
      performed on them. If all values of the original type can be represented
      as an int, the value of the smaller type is converted to an int;
      otherwise, it is converted to an unsigned int."
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/378Signed-off-by: default avatarJustin Stitt <justinstitt@google.com>
      Acked-by: default avatarSerge Semin <fancer.lancer@gmail.com>
      Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
      a44252d5
  3. 31 Jul, 2022 6 commits
  4. 30 Jul, 2022 2 commits
  5. 29 Jul, 2022 16 commits