A few bug fixes and support for new AMD NTB Hardware

-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEoE9b9c3U2JxX98mqbmZLrHqL0iMFAl2JQbYACgkQbmZLrHqL
 0iPozg//V6e+FM25tB5pl1W7q6zP2KVCs2WsZQqdKQvTFlmGjq+ty+xq/Ye/Pq6K
 ueRGwDEuHA9t435Vi93itjVPqFIb99dbw7QGCRyESfK15pb9EdqTlIfOfaxY+4Ai
 fs0hSne/Fw2PVeykOaP+d6RVVjxunOxjZ6sBoFRggUszhuCZQTbYeuFvxggzbMyE
 Zse04vK3yHAWNXcBZBrePbp8GrpBTtGdsABTFLd12Odb9LT1yGkYjBcD63kJ1TYG
 Oqwtpx3l9/ujhDrCmco6yayX8jJSWgK5dJ0O4fpzfJ4RpeIcoUCV2nnKSq/ndjWF
 0BcQlDQiSpo8fiDDr/1JawvlvqiBciKCw+QP+JVXMLKWZwUifxGLF0Ne+wRqkKBe
 xBF+cUa1WTSARA0tbztpg+a6MWj5DxuWChF8SH3w3lfU7FVTzrASajmPvXGmn5l2
 2qSvNpIdSyPA7mAPt/tnUW8IgcsjYEE+QUCc41Y8TWX4DYdEnbztaqrtymHg7APb
 /EUz0xTy2j4BFzGF4AqjD70rOdd+M/Btd4BCyLcpI1oMJj9xCMP6COpTEwrarX7V
 QLOi2WnKJFg13Kv8lVA/Y7h+cG4c7yncYz2ey4Ef9y6IshAzab36ukvPZ1kubmQt
 EJLmMdWmHoIzSdViWhzihnes3qqvmQp50GPbbwOu9VGHz6iXrRc=
 =rPCf
 -----END PGP SIGNATURE-----

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

Pull NTB updates from Jon Mason:
 "A few bugfixes and support for new AMD NTB hardware"

* tag 'ntb-5.4' of git://github.com/jonmason/ntb:
  NTB: fix IDT Kconfig typos/spellos
  ntb_hw_amd: Add memory window support for new AMD hardware
  ntb_hw_amd: Add a new NTB PCI device ID
  NTB: ntb_transport: remove redundant assignment to rc
  ntb_hw_switchtec: make ntb_mw_set_trans() work when addr == 0
  ntb: point to right memory window index
This commit is contained in:
Linus Torvalds 2019-09-27 11:05:49 -07:00
commit 0cd81d77d0
6 changed files with 30 additions and 12 deletions

View File

@ -78,7 +78,7 @@ static int ndev_mw_to_bar(struct amd_ntb_dev *ndev, int idx)
if (idx < 0 || idx > ndev->mw_count)
return -EINVAL;
return 1 << idx;
return ndev->dev_data->mw_idx << idx;
}
static int amd_ntb_mw_count(struct ntb_dev *ntb, int pidx)
@ -909,7 +909,7 @@ static int amd_init_ntb(struct amd_ntb_dev *ndev)
{
void __iomem *mmio = ndev->self_mmio;
ndev->mw_count = AMD_MW_CNT;
ndev->mw_count = ndev->dev_data->mw_count;
ndev->spad_count = AMD_SPADS_CNT;
ndev->db_count = AMD_DB_CNT;
@ -1069,6 +1069,8 @@ static int amd_ntb_pci_probe(struct pci_dev *pdev,
goto err_ndev;
}
ndev->dev_data = (struct ntb_dev_data *)id->driver_data;
ndev_init_struct(ndev, pdev);
rc = amd_ntb_init_pci(ndev, pdev);
@ -1123,9 +1125,21 @@ static const struct file_operations amd_ntb_debugfs_info = {
.read = ndev_debugfs_read,
};
static const struct ntb_dev_data dev_data[] = {
{ /* for device 145b */
.mw_count = 3,
.mw_idx = 1,
},
{ /* for device 148b */
.mw_count = 2,
.mw_idx = 2,
},
};
static const struct pci_device_id amd_ntb_pci_tbl[] = {
{PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_NTB)},
{0}
{ PCI_VDEVICE(AMD, 0x145b), (kernel_ulong_t)&dev_data[0] },
{ PCI_VDEVICE(AMD, 0x148b), (kernel_ulong_t)&dev_data[1] },
{ 0, }
};
MODULE_DEVICE_TABLE(pci, amd_ntb_pci_tbl);

View File

@ -52,7 +52,6 @@
#include <linux/ntb.h>
#include <linux/pci.h>
#define PCI_DEVICE_ID_AMD_NTB 0x145B
#define AMD_LINK_HB_TIMEOUT msecs_to_jiffies(1000)
#define AMD_LINK_STATUS_OFFSET 0x68
#define NTB_LIN_STA_ACTIVE_BIT 0x00000002
@ -93,7 +92,6 @@ static inline void _write64(u64 val, void __iomem *mmio)
enum {
/* AMD NTB Capability */
AMD_MW_CNT = 3,
AMD_DB_CNT = 16,
AMD_MSIX_VECTOR_CNT = 24,
AMD_SPADS_CNT = 16,
@ -170,6 +168,11 @@ enum {
AMD_PEER_OFFSET = 0x400,
};
struct ntb_dev_data {
const unsigned char mw_count;
const unsigned int mw_idx;
};
struct amd_ntb_dev;
struct amd_ntb_vec {
@ -185,6 +188,7 @@ struct amd_ntb_dev {
u32 cntl_sta;
u32 peer_sta;
struct ntb_dev_data *dev_data;
unsigned char mw_count;
unsigned char spad_count;
unsigned char db_count;

View File

@ -4,11 +4,11 @@ config NTB_IDT
depends on PCI
select HWMON
help
This driver supports NTB of cappable IDT PCIe-switches.
This driver supports NTB of capable IDT PCIe-switches.
Some of the pre-initializations must be made before IDT PCIe-switch
exposes it NT-functions correctly. It should be done by either proper
initialisation of EEPROM connected to master smbus of the switch or
exposes its NT-functions correctly. It should be done by either proper
initialization of EEPROM connected to master SMbus of the switch or
by BIOS using slave-SMBus interface changing corresponding registers
value. Evidently it must be done before PCI bus enumeration is
finished in Linux kernel.

View File

@ -306,7 +306,7 @@ static int switchtec_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int widx,
if (rc)
return rc;
if (addr == 0 || size == 0) {
if (size == 0) {
if (widx < nr_direct_mw)
switchtec_ntb_mw_clr_direct(sndev, widx);
else

View File

@ -292,7 +292,7 @@ static int ntb_transport_bus_match(struct device *dev,
static int ntb_transport_bus_probe(struct device *dev)
{
const struct ntb_transport_client *client;
int rc = -EINVAL;
int rc;
get_device(dev);

View File

@ -1378,7 +1378,7 @@ static int perf_setup_peer_mw(struct perf_peer *peer)
int ret;
/* Get outbound MW parameters and map it */
ret = ntb_peer_mw_get_addr(perf->ntb, peer->gidx, &phys_addr,
ret = ntb_peer_mw_get_addr(perf->ntb, perf->gidx, &phys_addr,
&peer->outbuf_size);
if (ret)
return ret;