Skip to contentSkip to conversation

RapidIO subsystem updates

PATCH In review Alexandre Bounine 4 participants 21 messages Jul 21, 2016 – Jul 28, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover RapidIO subsystem updates

This set of patches contains RapidIO subsystem fixes and updates that have been made since kernel v4.6. The most significant update brings changes related to the latest revision of RapidIO specification (rev.3.x) and introduction of next generation of RapidIO switches by IDT (RXS1632 and RXS2448).

Alexandre Bounine (12):
rapidio/documentation: fix mangled paragraph in mport_cdev
rapidio: fix return value description for dma_prep functions rapidio/tsi721_dma: add channel mask and queue size parameters rapidio/tsi721: add PCIe MRRS override parameter rapidio/tsi721: add messaging mbox selector parameter rapidio/tsi721_dma: advance queue processing from transfer submit
call
rapidio: fix error handling in mbox request/release functions rapidio/idt_gen2: fix locking warning
rapidio: change inbound window size type to u64
rapidio: modify for rev.3 specification changes powerpc/fsl_rio: apply changes for RIO spec rev 3 rapidio/switches: add driver for IDT gen3 switches

Joe Perches (1):
rapidio: Remove unnecessary 0x prefixes before %pa extension uses

 Documentation/rapidio/mport_cdev.txt     |    3 +-
 Documentation/rapidio/tsi721.txt         |   26 ++
 arch/powerpc/sysdev/fsl_rio.c            |   16 +-
 drivers/rapidio/devices/rio_mport_cdev.c |    6 +-
 drivers/rapidio/devices/tsi721.c         |   57 ++++-
 drivers/rapidio/devices/tsi721.h         |    2 +-
 drivers/rapidio/devices/tsi721_dma.c     |   27 ++-
 drivers/rapidio/rio-scan.c               |   74 ++-----
 drivers/rapidio/rio.c                    |  211 ++++++++++-------
 drivers/rapidio/rio.h                    |    2 +-
 drivers/rapidio/switches/Kconfig         |    6 +
 drivers/rapidio/switches/Makefile        |    1 +
 drivers/rapidio/switches/idt_gen2.c      |    7 +-
 drivers/rapidio/switches/idt_gen3.c      |  381 ++++++++++++++++++++++++++++++
 drivers/rapidio/switches/tsi57x.c        |   26 +-
 include/linux/rio.h                      |   13 +-
 include/linux/rio_ids.h                  |    2 +
 include/linux/rio_regs.h                 |  167 ++++++++++---
 18 files changed, 783 insertions(+), 244 deletions(-)
 create mode 100644 drivers/rapidio/switches/idt_gen3.c
Signature · 1 line
1.7.8.4
#1 lore raw

PATCH 1/13 rapidio: Remove unnecessary 0x prefixes before %pa extension uses

From: Joe Perches <[email protected]>

This is RapidIO part of the original patch submitted by Joe Perches. (see: https://lkml.org/lkml/2016/3/5/19)

Since commit 3cab1e711297 ("lib/vsprintf: refactor duplicate code to special_hex_number()") %pa uses have been output with a 0x prefix.

These 0x prefixes in the formats are unnecessary.

---
 drivers/rapidio/devices/rio_mport_cdev.c |    4 ++--
 drivers/rapidio/devices/tsi721.c         |    8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/rapidio/devices/rio_mport_cdev.c +2 -2
index e165b7c..de0c692 100644
@@ -2242,7 +2242,7 @@ static void mport_mm_open(struct vm_area_struct *vma)
 {
 	struct rio_mport_mapping *map = vma->vm_private_data;
 
-rmcd_debug(MMAP, "0x%pad", &map->phys_addr);
+	rmcd_debug(MMAP, "%pad", &map->phys_addr);
 	kref_get(&map->ref);
 }
 
@@ -2250,7 +2250,7 @@ static void mport_mm_close(struct vm_area_struct *vma)
 {
 	struct rio_mport_mapping *map = vma->vm_private_data;
 
-rmcd_debug(MMAP, "0x%pad", &map->phys_addr);
+	rmcd_debug(MMAP, "%pad", &map->phys_addr);
 	mutex_lock(&map->md->buf_mutex);
 	kref_put(&map->ref, mport_release_mapping);
 	mutex_unlock(&map->md->buf_mutex);
drivers/rapidio/devices/tsi721.c +4 -4
index b5b4556..4c20e99 100644
@@ -1101,7 +1101,7 @@ static int tsi721_rio_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart,
 		ibw_start = lstart & ~(ibw_size - 1);
 
 		tsi_debug(IBW, &priv->pdev->dev,
-			"Direct (RIO_0x%llx -> PCIe_0x%pad), size=0x%x, ibw_start = 0x%llx",
+			"Direct (RIO_0x%llx -> PCIe_%pad), size=0x%x, ibw_start = 0x%llx",
 			rstart, &lstart, size, ibw_start);
 
 		while ((lstart + size) > (ibw_start + ibw_size)) {
@@ -1120,7 +1120,7 @@ static int tsi721_rio_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart,
 
 	} else {
 		tsi_debug(IBW, &priv->pdev->dev,
-			"Translated (RIO_0x%llx -> PCIe_0x%pad), size=0x%x",
+			"Translated (RIO_0x%llx -> PCIe_%pad), size=0x%x",
 			rstart, &lstart, size);
 
 		if (!is_power_of_2(size) || size < 0x1000 ||
@@ -1215,7 +1215,7 @@ static int tsi721_rio_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart,
 	priv->ibwin_cnt--;
 
 	tsi_debug(IBW, &priv->pdev->dev,
-		"Configured IBWIN%d (RIO_0x%llx -> PCIe_0x%pad), size=0x%llx",
+		"Configured IBWIN%d (RIO_0x%llx -> PCIe_%pad), size=0x%llx",
 		i, ibw_start, &loc_start, ibw_size);
 
 	return 0;
@@ -1237,7 +1237,7 @@ static void tsi721_rio_unmap_inb_mem(struct rio_mport *mport,
 	int i;
 
 	tsi_debug(IBW, &priv->pdev->dev,
-		"Unmap IBW mapped to PCIe_0x%pad", &lstart);
+		"Unmap IBW mapped to PCIe_%pad", &lstart);
 
 	/* Search for matching active inbound translation window */
 	for (i = 0; i < TSI721_IBWIN_NUM; i++) {
Signature · 1 line
1.7.8.4
#2 lore raw

PATCH 2/13 rapidio/documentation: fix mangled paragraph in mport_cdev

In reply to Alexandre Bounine

Minor edits to correct parameter description.

This patch is applicable to kernel versions starting from v4.6.

---
 Documentation/rapidio/mport_cdev.txt |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
Documentation/rapidio/mport_cdev.txt +1 -2
index 20c120d..6e491a6 100644
@@ -82,8 +82,7 @@ III. Module parameters
 
 - 'dbg_level' - This parameter allows to control amount of debug information
         generated by this device driver. This parameter is formed by set of
-        This parameter can be changed bit masks that correspond to the specific
-        functional block.
+        bit masks that correspond to the specific functional blocks.
         For mask definitions see 'drivers/rapidio/devices/rio_mport_cdev.c'
         This parameter can be changed dynamically.
         Use CONFIG_RAPIDIO_DEBUG=y to enable debug output at the top level.
Signature · 1 line
1.7.8.4
#3 lore raw

PATCH 3/13 rapidio: fix return value description for dma_prep functions

In reply to Alexandre Bounine

Update return value description for rio_dma_prep_... functions to include error-valued pointer that can be returned by HW mport device drivers. Return values from these functions must be checked using IS_ERR_OR_NULL macro.

This patch is applicable to kernel versions starting from v4.6-rc1.

---
 drivers/rapidio/rio.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/rapidio/rio.c +6 -2
index 0dcaa66..8408029 100644
@@ -1848,7 +1848,9 @@ EXPORT_SYMBOL_GPL(rio_release_dma);
  * Initializes RapidIO capable DMA channel for the specified data transfer.
  * Uses DMA channel private extension to pass information related to remote
  * target RIO device.
- * Returns pointer to DMA transaction descriptor or NULL if failed.
+ *
+ * Returns: pointer to DMA transaction descriptor if successful,
+ *          error-valued pointer or NULL if failed.
  */
 struct dma_async_tx_descriptor *rio_dma_prep_xfer(struct dma_chan *dchan,
 	u16 destid, struct rio_dma_data *data,
@@ -1883,7 +1885,9 @@ EXPORT_SYMBOL_GPL(rio_dma_prep_xfer);
  * Initializes RapidIO capable DMA channel for the specified data transfer.
  * Uses DMA channel private extension to pass information related to remote
  * target RIO device.
- * Returns pointer to DMA transaction descriptor or NULL if failed.
+ *
+ * Returns: pointer to DMA transaction descriptor if successful,
+ *          error-valued pointer or NULL if failed.
  */
 struct dma_async_tx_descriptor *rio_dma_prep_slave_sg(struct rio_dev *rdev,
 	struct dma_chan *dchan, struct rio_dma_data *data,
Signature · 1 line
1.7.8.4
#4 lore raw

PATCH 4/13 rapidio/tsi721_dma: add channel mask and queue size parameters

In reply to Alexandre Bounine

Add module parameters to allow load time configuration of DMA channels.

Depending on application, performance of DMA data transfers can benefit from adjusted sizes of buffer descriptor ring and/or transaction requests queue.

Having HW DMA channel selector mask allows to define which channels (from seven available) are controlled by the mport device driver and reserve some of them for direct use by other drivers.

---
 Documentation/rapidio/tsi721.txt     |   14 ++++++++++++++
 drivers/rapidio/devices/tsi721.h     |    2 +-
 drivers/rapidio/devices/tsi721_dma.c |   26 +++++++++++++++++---------
 3 files changed, 32 insertions(+), 10 deletions(-)
Documentation/rapidio/tsi721.txt +14 -0
index 7c1c7bf..0e0e90be 100644
@@ -25,6 +25,20 @@ fully compatible with RIONET driver (Ethernet over RapidIO messaging services).
         This parameter can be changed dynamically.
         Use CONFIG_RAPIDIO_DEBUG=y to enable debug output at the top level.
 
+- 'dma_desc_per_channel' - This parameter defines number of hardware buffer
+        descriptors allocated for each registered Tsi721 DMA channel.
+        Its default value is 128.
+
+- 'dma_txqueue_sz' - DMA transactions queue size. Defines number of pending
+        transaction requests that can be accepted by each DMA channel.
+        Default value is 16.
+
+- 'dma_sel' - DMA channel selection mask. Bitmask that defines which hardware
+        DMA channels (0 ... 6) will be registered with DmaEngine core.
+        If bit is set to 1, the corresponding DMA channel will be registered.
+        DMA channels not selected by this mask will not be used by this device
+        driver. Default value is 0x7f (use all channels).
+
 II. Known problems
 
   None.
drivers/rapidio/devices/tsi721.h +1 -1
index 5456dbd..5941437 100644
@@ -661,7 +661,7 @@ enum dma_rtype {
  */
 #define TSI721_DMA_CHNUM	TSI721_DMA_MAXCH
 
-#define TSI721_DMACH_MAINT	0	/* DMA channel for maint requests */
+#define TSI721_DMACH_MAINT	7	/* DMA channel for maint requests */
 #define TSI721_DMACH_MAINT_NBD	32	/* Number of BDs for maint requests */
 
 #define TSI721_DMACH_DMA	1	/* DMA channel for data transfers */
drivers/rapidio/devices/tsi721_dma.c +17 -9
index 155cae1..13c669b 100644
@@ -36,18 +36,26 @@
 
 #include "tsi721.h"
 
-#define TSI721_DMA_TX_QUEUE_SZ	16	/* number of transaction descriptors */
-
 #ifdef CONFIG_PCI_MSI
 static irqreturn_t tsi721_bdma_msix(int irq, void *ptr);
 #endif
 static int tsi721_submit_sg(struct tsi721_tx_desc *desc);
 
 static unsigned int dma_desc_per_channel = 128;
-module_param(dma_desc_per_channel, uint, S_IWUSR | S_IRUGO);
+module_param(dma_desc_per_channel, uint, S_IRUGO);
 MODULE_PARM_DESC(dma_desc_per_channel,
 		 "Number of DMA descriptors per channel (default: 128)");
 
+static unsigned int dma_txqueue_sz = 16;
+module_param(dma_txqueue_sz, uint, S_IRUGO);
+MODULE_PARM_DESC(dma_txqueue_sz,
+		 "DMA Transactions Queue Size (default: 16)");
+
+static u8 dma_sel = 0x7f;
+module_param(dma_sel, byte, S_IRUGO);
+MODULE_PARM_DESC(dma_sel,
+		 "DMA Channel Selection Mask (default: 0x7f = all)");
+
 static inline struct tsi721_bdma_chan *to_tsi721_chan(struct dma_chan *chan)
 {
 	return container_of(chan, struct tsi721_bdma_chan, dchan);
@@ -732,7 +740,7 @@ static int tsi721_alloc_chan_resources(struct dma_chan *dchan)
 	tsi_debug(DMA, &dchan->dev->device, "DMAC%d", bdma_chan->id);
 
 	if (bdma_chan->bd_base)
-		return TSI721_DMA_TX_QUEUE_SZ;
+		return dma_txqueue_sz;
 
 	/* Initialize BDMA channel */
 	if (tsi721_bdma_ch_init(bdma_chan, dma_desc_per_channel)) {
@@ -742,7 +750,7 @@ static int tsi721_alloc_chan_resources(struct dma_chan *dchan)
 	}
 
 	/* Allocate queue of transaction descriptors */
-	desc = kcalloc(TSI721_DMA_TX_QUEUE_SZ, sizeof(struct tsi721_tx_desc),
+	desc = kcalloc(dma_txqueue_sz, sizeof(struct tsi721_tx_desc),
 			GFP_ATOMIC);
 	if (!desc) {
 		tsi_err(&dchan->dev->device,
@@ -754,7 +762,7 @@ static int tsi721_alloc_chan_resources(struct dma_chan *dchan)
 
 	bdma_chan->tx_desc = desc;
 
-	for (i = 0; i < TSI721_DMA_TX_QUEUE_SZ; i++) {
+	for (i = 0; i < dma_txqueue_sz; i++) {
 		dma_async_tx_descriptor_init(&desc[i].txd, dchan);
 		desc[i].txd.tx_submit = tsi721_tx_submit;
 		desc[i].txd.flags = DMA_CTRL_ACK;
@@ -766,7 +774,7 @@ static int tsi721_alloc_chan_resources(struct dma_chan *dchan)
 	bdma_chan->active = true;
 	tsi721_bdma_interrupt_enable(bdma_chan, 1);
 
-	return TSI721_DMA_TX_QUEUE_SZ;
+	return dma_txqueue_sz;
 }
 
 static void tsi721_sync_dma_irq(struct tsi721_bdma_chan *bdma_chan)
@@ -962,7 +970,7 @@ void tsi721_dma_stop_all(struct tsi721_device *priv)
 	int i;
 
 	for (i = 0; i < TSI721_DMA_MAXCH; i++) {
-		if (i != TSI721_DMACH_MAINT)
+		if ((i != TSI721_DMACH_MAINT) && (dma_sel & (1 << i)))
 			tsi721_dma_stop(&priv->bdma[i]);
 	}
 }
@@ -979,7 +987,7 @@ int tsi721_register_dma(struct tsi721_device *priv)
 	for (i = 0; i < TSI721_DMA_MAXCH; i++) {
 		struct tsi721_bdma_chan *bdma_chan = &priv->bdma[i];
 
-		if (i == TSI721_DMACH_MAINT)
+		if ((i == TSI721_DMACH_MAINT) || (dma_sel & (1 << i)) == 0)
 			continue;
 
 		bdma_chan->regs = priv->regs + TSI721_DMAC_BASE(i);
Signature · 1 line
1.7.8.4
#5 lore raw

PATCH 5/13 rapidio/tsi721: add PCIe MRRS override parameter

In reply to Alexandre Bounine

Add PCIe Maximum Read Request Size (MRRS) adjustment parameter to allow users to override configuration register value set during PCIe bus initialization.

Performance of Tsi721 device as PCIe bus master can be improved if MRRS is set to its maximum value (4096 bytes).
Some platforms have limitations for supported MRRS and therefore the default value should be preserved, unless it is known that given platform supports full set of MRRS values defined by PCI Express specification.

---
 Documentation/rapidio/tsi721.txt |    7 +++++++
 drivers/rapidio/devices/tsi721.c |   16 +++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletions(-)
Documentation/rapidio/tsi721.txt +7 -0
index 0e0e90be..9c6ee38 100644
@@ -39,6 +39,13 @@ fully compatible with RIONET driver (Ethernet over RapidIO messaging services).
         DMA channels not selected by this mask will not be used by this device
         driver. Default value is 0x7f (use all channels).
 
+- 'pcie_mrrs' - override value for PCIe Maximum Read Request Size (MRRS).
+        This parameter gives an ability to override MRRS value set during PCIe
+        configuration process. Tsi721 supports read request sizes up to 4096B.
+        Value for this parameter must be set as defined by PCIe specification:
+        0 = 128B, 1 = 256B, 2 = 512B, 3 = 1024B, 4 = 2048B and 5 = 4096B.
+        Default value is '-1' (= keep platform setting).
+
 II. Known problems
 
   None.
drivers/rapidio/devices/tsi721.c +15 -1
index 4c20e99..85098f8 100644
@@ -37,11 +37,15 @@
 #include "tsi721.h"
 
 #ifdef DEBUG
-u32 dbg_level = DBG_INIT | DBG_EXIT;
+u32 dbg_level;
 module_param(dbg_level, uint, S_IWUSR | S_IRUGO);
 MODULE_PARM_DESC(dbg_level, "Debugging output level (default 0 = none)");
 #endif
 
+static int pcie_mrrs = -1;
+module_param(pcie_mrrs, int, S_IRUGO);
+MODULE_PARM_DESC(pcie_mrrs, "PCIe MRRS override value (0...5)");
+
 static void tsi721_omsg_handler(struct tsi721_device *priv, int ch);
 static void tsi721_imsg_handler(struct tsi721_device *priv, int ch);
 
@@ -2840,6 +2844,16 @@ static int tsi721_probe(struct pci_dev *pdev,
 	pcie_capability_clear_and_set_word(pdev, PCI_EXP_DEVCTL,
 		PCI_EXP_DEVCTL_RELAX_EN | PCI_EXP_DEVCTL_NOSNOOP_EN, 0);
 
+	/* Override PCIe Maximum Read Request Size setting if requested */
+	if (pcie_mrrs >= 0) {
+		if (pcie_mrrs <= 5)
+			pcie_capability_clear_and_set_word(pdev, PCI_EXP_DEVCTL,
+					PCI_EXP_DEVCTL_READRQ, pcie_mrrs << 12);
+		else
+			tsi_info(&pdev->dev,
+				 "Invalid MRRS override value %d", pcie_mrrs);
+	}
+
 	/* Adjust PCIe completion timeout. */
 	pcie_capability_clear_and_set_word(pdev, PCI_EXP_DEVCTL2, 0xf, 0x2);
 
Signature · 1 line
1.7.8.4
#6 lore raw

PATCH 6/13 rapidio/tsi721: add messaging mbox selector parameter

In reply to Alexandre Bounine

Add module parameter to allow load time configuration of available RapidIO messaging mailboxes (MBOX1 - MBOX4).

Having a messaging MBOX selector mask allows to define which MBOXes are controlled by the mport device driver and reserve some of them for direct use by other drivers.

---
 Documentation/rapidio/tsi721.txt |    5 +++++
 drivers/rapidio/devices/tsi721.c |   15 +++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)
Documentation/rapidio/tsi721.txt +5 -0
index 9c6ee38..cd2a293 100644
@@ -46,6 +46,11 @@ fully compatible with RIONET driver (Ethernet over RapidIO messaging services).
         0 = 128B, 1 = 256B, 2 = 512B, 3 = 1024B, 4 = 2048B and 5 = 4096B.
         Default value is '-1' (= keep platform setting).
 
+- 'mbox_sel' - RIO messaging MBOX selection mask. This is a bitmask that defines
+        messaging MBOXes are managed by this device driver. Mask bits 0 - 3
+        correspond to MBOX0 - MBOX3. MBOX is under driver's control if the
+        corresponding bit is set to '1'. Default value is 0x0f (= all).
+
 II. Known problems
 
   None.
drivers/rapidio/devices/tsi721.c +15 -0
index 85098f8..8e07cd5 100644
@@ -46,6 +46,11 @@ static int pcie_mrrs = -1;
 module_param(pcie_mrrs, int, S_IRUGO);
 MODULE_PARM_DESC(pcie_mrrs, "PCIe MRRS override value (0...5)");
 
+static u8 mbox_sel = 0x0f;
+module_param(mbox_sel, byte, S_IRUGO);
+MODULE_PARM_DESC(mbox_sel,
+		 "RIO Messaging MBOX Selection Mask (default: 0x0f = all)");
+
 static void tsi721_omsg_handler(struct tsi721_device *priv, int ch);
 static void tsi721_imsg_handler(struct tsi721_device *priv, int ch);
 
@@ -1881,6 +1886,11 @@ static int tsi721_open_outb_mbox(struct rio_mport *mport, void *dev_id,
 		goto out;
 	}
 
+	if ((mbox_sel & (1 << mbox)) == 0) {
+		rc = -ENODEV;
+		goto out;
+	}
+
 	priv->omsg_ring[mbox].dev_id = dev_id;
 	priv->omsg_ring[mbox].size = entries;
 	priv->omsg_ring[mbox].sts_rdptr = 0;
@@ -2165,6 +2175,11 @@ static int tsi721_open_inb_mbox(struct rio_mport *mport, void *dev_id,
 		goto out;
 	}
 
+	if ((mbox_sel & (1 << mbox)) == 0) {
+		rc = -ENODEV;
+		goto out;
+	}
+
 	/* Initialize IB Messaging Ring */
 	priv->imsg_ring[mbox].dev_id = dev_id;
 	priv->imsg_ring[mbox].size = entries;
Signature · 1 line
1.7.8.4
#7 lore raw

PATCH 7/13 rapidio/tsi721_dma: advance queue processing from transfer submit call

In reply to Alexandre Bounine

Add advancing transfer queue immediately from transfer submit call. DMA performance improvement: This will start transfer without waiting for 'issue_pending' command if there is no DMA transfer in progress.

---
 drivers/rapidio/devices/tsi721_dma.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/rapidio/devices/tsi721_dma.c +1 -0
index 13c669b..e2a4185 100644
@@ -726,6 +726,7 @@ static dma_cookie_t tsi721_tx_submit(struct dma_async_tx_descriptor *txd)
 	cookie = dma_cookie_assign(txd);
 	desc->status = DMA_IN_PROGRESS;
 	list_add_tail(&desc->desc_node, &bdma_chan->queue);
+	tsi721_advance_work(bdma_chan, NULL);
 
 	spin_unlock_bh(&bdma_chan->lock);
 	return cookie;
Signature · 1 line
1.7.8.4
#8 lore raw

PATCH 8/13 rapidio: fix error handling in mbox request/release functions

In reply to Alexandre Bounine

Add checking for error code returned by HW-specific mbox open routines. Ensure that resources are properly release if failed.

This patch is applicable to kernel versions starting from v2.6.15.

---
 drivers/rapidio/rio.c |   54 ++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 42 insertions(+), 12 deletions(-)
drivers/rapidio/rio.c +42 -12
index 8408029..1cd3260 100644
@@ -268,6 +268,12 @@ int rio_request_inb_mbox(struct rio_mport *mport,
 		mport->inb_msg[mbox].mcback = minb;
 
 		rc = mport->ops->open_inb_mbox(mport, dev_id, mbox, entries);
+		if (rc) {
+			mport->inb_msg[mbox].mcback = NULL;
+			mport->inb_msg[mbox].res = NULL;
+			release_resource(res);
+			kfree(res);
+		}
 	} else
 		rc = -ENOMEM;
 
@@ -285,13 +291,22 @@ int rio_request_inb_mbox(struct rio_mport *mport,
  */
 int rio_release_inb_mbox(struct rio_mport *mport, int mbox)
 {
-	if (mport->ops->close_inb_mbox) {
-		mport->ops->close_inb_mbox(mport, mbox);
+	int rc;
 
-		/* Release the mailbox resource */
-		return release_resource(mport->inb_msg[mbox].res);
-	} else
-		return -ENOSYS;
+	if (!mport->ops->close_inb_mbox || !mport->inb_msg[mbox].res)
+		return -EINVAL;
+
+	mport->ops->close_inb_mbox(mport, mbox);
+	mport->inb_msg[mbox].mcback = NULL;
+
+	rc = release_resource(mport->inb_msg[mbox].res);
+	if (rc)
+		return rc;
+
+	kfree(mport->inb_msg[mbox].res);
+	mport->inb_msg[mbox].res = NULL;
+
+	return 0;
 }
 
 /**
@@ -336,6 +351,12 @@ int rio_request_outb_mbox(struct rio_mport *mport,
 		mport->outb_msg[mbox].mcback = moutb;
 
 		rc = mport->ops->open_outb_mbox(mport, dev_id, mbox, entries);
+		if (rc) {
+			mport->outb_msg[mbox].mcback = NULL;
+			mport->outb_msg[mbox].res = NULL;
+			release_resource(res);
+			kfree(res);
+		}
 	} else
 		rc = -ENOMEM;
 
@@ -353,13 +374,22 @@ int rio_request_outb_mbox(struct rio_mport *mport,
  */
 int rio_release_outb_mbox(struct rio_mport *mport, int mbox)
 {
-	if (mport->ops->close_outb_mbox) {
-		mport->ops->close_outb_mbox(mport, mbox);
+	int rc;
 
-		/* Release the mailbox resource */
-		return release_resource(mport->outb_msg[mbox].res);
-	} else
-		return -ENOSYS;
+	if (!mport->ops->close_outb_mbox || !mport->outb_msg[mbox].res)
+		return -EINVAL;
+
+	mport->ops->close_outb_mbox(mport, mbox);
+	mport->outb_msg[mbox].mcback = NULL;
+
+	rc = release_resource(mport->outb_msg[mbox].res);
+	if (rc)
+		return rc;
+
+	kfree(mport->outb_msg[mbox].res);
+	mport->outb_msg[mbox].res = NULL;
+
+	return 0;
 }
 
 /**
Signature · 1 line
1.7.8.4
#9 lore raw

PATCH 9/13 rapidio/idt_gen2: fix locking warning

In reply to Alexandre Bounine

Fix lockdep warning during device probing: move sysfs initialization out of code protected by a spin lock.

---
 drivers/rapidio/switches/idt_gen2.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/rapidio/switches/idt_gen2.c +3 -4
index 9f7fe21..e67b923 100644
@@ -436,10 +436,11 @@ static int idtg2_probe(struct rio_dev *rdev, const struct rio_device_id *id)
 				    RIO_STD_RTE_DEFAULT_PORT, IDT_NO_ROUTE);
 	}
 
+	spin_unlock(&rdev->rswitch->lock);
+
 	/* Create device-specific sysfs attributes */
 	idtg2_sysfs(rdev, true);
 
-	spin_unlock(&rdev->rswitch->lock);
 	return 0;
 }
 
@@ -452,11 +453,9 @@ static void idtg2_remove(struct rio_dev *rdev)
 		return;
 	}
 	rdev->rswitch->ops = NULL;
-
+	spin_unlock(&rdev->rswitch->lock);
 	/* Remove device-specific sysfs attributes */
 	idtg2_sysfs(rdev, false);
-
-	spin_unlock(&rdev->rswitch->lock);
 }
 
 static struct rio_device_id idtg2_id_table[] = {
Signature · 1 line
1.7.8.4
#10 lore raw

PATCH 10/13 rapidio: change inbound window size type to u64

In reply to Alexandre Bounine

Current definition of map_inb() mport operations callback uses u32 type to specify required inbound window (IBW) size. This is limiting factor because existing hardware - tsi721 and fsl_rio, both support IBW size up to 16GB.

Changing type of size parameter to u64 to allow IBW size configurations larger than 4GB.

Cc Matt Porter <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Andre van Herk <[email protected]>
Cc Barry Wood <[email protected]>
---
 arch/powerpc/sysdev/fsl_rio.c    |    4 ++--
 drivers/rapidio/devices/tsi721.c |   14 +++++++++-----
 include/linux/rio.h              |    2 +-
 3 files changed, 12 insertions(+), 8 deletions(-)
arch/powerpc/sysdev/fsl_rio.c +2 -2
index f5bf38b9..1958838 100644
@@ -289,7 +289,7 @@ static void fsl_rio_inbound_mem_init(struct rio_priv *priv)
 }
 
 int fsl_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart,
-	u64 rstart, u32 size, u32 flags)
+	u64 rstart, u64 size, u32 flags)
 {
 	struct rio_priv *priv = mport->priv;
 	u32 base_size;
@@ -298,7 +298,7 @@ int fsl_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart,
 	u32 riwar;
 	int i;
 
-	if ((size & (size - 1)) != 0)
+	if ((size & (size - 1)) != 0 || size > 0x400000000UL)
 		return -EINVAL;
 
 	base_size_log = ilog2(size);
drivers/rapidio/devices/tsi721.c +9 -5
index 8e07cd5..53daf63 100644
@@ -1090,7 +1090,7 @@ static void tsi721_init_pc2sr_mapping(struct tsi721_device *priv)
  * from rstart to lstart.
  */
 static int tsi721_rio_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart,
-		u64 rstart, u32 size, u32 flags)
+		u64 rstart, u64 size, u32 flags)
 {
 	struct tsi721_device *priv = mport->priv;
 	int i, avail = -1;
@@ -1103,6 +1103,10 @@ static int tsi721_rio_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart,
 	struct tsi721_ib_win_mapping *map = NULL;
 	int ret = -EBUSY;
 
+	/* Max IBW size supported by HW is 16GB */
+	if (size > 0x400000000UL)
+		return -EINVAL;
+
 	if (direct) {
 		/* Calculate minimal acceptable window size and base address */
 
@@ -1110,15 +1114,15 @@ static int tsi721_rio_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart,
 		ibw_start = lstart & ~(ibw_size - 1);
 
 		tsi_debug(IBW, &priv->pdev->dev,
-			"Direct (RIO_0x%llx -> PCIe_%pad), size=0x%x, ibw_start = 0x%llx",
+			"Direct (RIO_0x%llx -> PCIe_%pad), size=0x%llx, ibw_start = 0x%llx",
 			rstart, &lstart, size, ibw_start);
 
 		while ((lstart + size) > (ibw_start + ibw_size)) {
 			ibw_size *= 2;
 			ibw_start = lstart & ~(ibw_size - 1);
-			if (ibw_size > 0x80000000) { /* Limit max size to 2GB */
+			/* Check for crossing IBW max size 16GB */
+			if (ibw_size > 0x400000000UL)
 				return -EBUSY;
-			}
 		}
 
 		loc_start = ibw_start;
@@ -1129,7 +1133,7 @@ static int tsi721_rio_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart,
 
 	} else {
 		tsi_debug(IBW, &priv->pdev->dev,
-			"Translated (RIO_0x%llx -> PCIe_%pad), size=0x%x",
+			"Translated (RIO_0x%llx -> PCIe_%pad), size=0x%llx",
 			rstart, &lstart, size);
 
 		if (!is_power_of_2(size) || size < 0x1000 ||
include/linux/rio.h +1 -1
index aa23238..f7ec35b 100644
@@ -425,7 +425,7 @@ struct rio_ops {
 	int (*add_inb_buffer)(struct rio_mport *mport, int mbox, void *buf);
 	void *(*get_inb_message)(struct rio_mport *mport, int mbox);
 	int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
-			u64 rstart, u32 size, u32 flags);
+			u64 rstart, u64 size, u32 flags);
 	void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
 	int (*query_mport)(struct rio_mport *mport,
 			   struct rio_mport_attr *attr);
Signature · 1 line
1.7.8.4
#11 lore raw

PATCH 11/13 rapidio: modify for rev.3 specification changes

In reply to Alexandre Bounine

Implement changes made in RapidIO specification rev.3 to LP-Serial Physical Layer register definitions:
- use per-port register offset calculations based on LP-Serial Extended Features Block (EFB) Register Map type (I or II) with different per-port offset step (0x20 vs. 0x40 respectfully).
- remove deprecated Parallel Physical layer definitions and related code.

---
 drivers/rapidio/devices/rio_mport_cdev.c |    2 +-
 drivers/rapidio/devices/tsi721.c         |    8 +-
 drivers/rapidio/rio-scan.c               |   74 +++----------
 drivers/rapidio/rio.c                    |  149 ++++++++++++++-------------
 drivers/rapidio/rio.h                    |    2 +-
 drivers/rapidio/switches/tsi57x.c        |   26 ++---
 include/linux/rio.h                      |   11 +--
 include/linux/rio_regs.h                 |  167 +++++++++++++++++++++++------
 8 files changed, 248 insertions(+), 191 deletions(-)
drivers/rapidio/devices/rio_mport_cdev.c +1 -1
index de0c692..436dfe8 100644
@@ -1813,7 +1813,7 @@ static int rio_mport_add_riodev(struct mport_cdev_priv *priv,
 	if (rdev->pef & RIO_PEF_EXT_FEATURES) {
 		rdev->efptr = rval & 0xffff;
 		rdev->phys_efptr = rio_mport_get_physefb(mport, 0, destid,
-							 hopcount);
+						hopcount, &rdev->phys_rmap);
 
 		rdev->em_efptr = rio_mport_get_feature(mport, 0, destid,
 						hopcount, RIO_EFB_ERR_MGMNT);
drivers/rapidio/devices/tsi721.c +4 -4
index 53daf63..32f0f01 100644
@@ -2555,11 +2555,11 @@ static int tsi721_query_mport(struct rio_mport *mport,
 	struct tsi721_device *priv = mport->priv;
 	u32 rval;
 
-	rval = ioread32(priv->regs + (0x100 + RIO_PORT_N_ERR_STS_CSR(0)));
+	rval = ioread32(priv->regs + 0x100 + RIO_PORT_N_ERR_STS_CSR(0, 0));
 	if (rval & RIO_PORT_N_ERR_STS_PORT_OK) {
-		rval = ioread32(priv->regs + (0x100 + RIO_PORT_N_CTL2_CSR(0)));
+		rval = ioread32(priv->regs + 0x100 + RIO_PORT_N_CTL2_CSR(0, 0));
 		attr->link_speed = (rval & RIO_PORT_N_CTL2_SEL_BAUD) >> 28;
-		rval = ioread32(priv->regs + (0x100 + RIO_PORT_N_CTL_CSR(0)));
+		rval = ioread32(priv->regs + 0x100 + RIO_PORT_N_CTL_CSR(0, 0));
 		attr->link_width = (rval & RIO_PORT_N_CTL_IPW) >> 27;
 	} else
 		attr->link_speed = RIO_LINK_DOWN;
@@ -2673,9 +2673,9 @@ static int tsi721_setup_mport(struct tsi721_device *priv)
 	mport->ops = &tsi721_rio_ops;
 	mport->index = 0;
 	mport->sys_size = 0; /* small system */
-	mport->phy_type = RIO_PHY_SERIAL;
 	mport->priv = (void *)priv;
 	mport->phys_efptr = 0x100;
+	mport->phys_rmap = 1;
 	mport->dev.parent = &pdev->dev;
 	mport->dev.release = tsi721_mport_release;
 
drivers/rapidio/rio-scan.c +18 -56

129 lines not on this page · raw message

drivers/rapidio/rio.c +76 -73

296 lines not on this page · raw message

drivers/rapidio/rio.h +1 -1
index 625d09a..9796b3f 100644
@@ -22,7 +22,7 @@
 extern u32 rio_mport_get_feature(struct rio_mport *mport, int local, u16 destid,
 				 u8 hopcount, int ftr);
 extern u32 rio_mport_get_physefb(struct rio_mport *port, int local,
-				 u16 destid, u8 hopcount);
+				 u16 destid, u8 hopcount, u32 *rmap);
 extern u32 rio_mport_get_efb(struct rio_mport *port, int local, u16 destid,
 			     u8 hopcount, u32 from);
 extern int rio_mport_chk_dev_access(struct rio_mport *mport, u16 destid,
drivers/rapidio/switches/tsi57x.c +12 -14
index 42c8b01..2700d15 100644
@@ -175,12 +175,10 @@ tsi57x_em_init(struct rio_dev *rdev)
 
 		/* Clear all pending interrupts */
 		rio_read_config_32(rdev,
-				rdev->phys_efptr +
-					RIO_PORT_N_ERR_STS_CSR(portnum),
+				RIO_DEV_PORT_N_ERR_STS_CSR(rdev, portnum),
 				&regval);
 		rio_write_config_32(rdev,
-				rdev->phys_efptr +
-					RIO_PORT_N_ERR_STS_CSR(portnum),
+				RIO_DEV_PORT_N_ERR_STS_CSR(rdev, portnum),
 				regval & 0x07120214);
 
 		rio_read_config_32(rdev,
@@ -198,7 +196,7 @@ tsi57x_em_init(struct rio_dev *rdev)
 
 		/* Skip next (odd) port if the current port is in x4 mode */
 		rio_read_config_32(rdev,
-				rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum),
+				RIO_DEV_PORT_N_CTL_CSR(rdev, portnum),
 				&regval);
 		if ((regval & RIO_PORT_N_CTL_PWIDTH) == RIO_PORT_N_CTL_PWIDTH_4)
 			portnum++;
@@ -221,23 +219,23 @@ tsi57x_em_handler(struct rio_dev *rdev, u8 portnum)
 	u32 regval;
 
 	rio_read_config_32(rdev,
-			rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum),
+			RIO_DEV_PORT_N_ERR_STS_CSR(rdev, portnum),
 			&err_status);
 
 	if ((err_status & RIO_PORT_N_ERR_STS_PORT_OK) &&
-	    (err_status & (RIO_PORT_N_ERR_STS_PW_OUT_ES |
-			  RIO_PORT_N_ERR_STS_PW_INP_ES))) {
+	    (err_status & (RIO_PORT_N_ERR_STS_OUT_ES |
+			  RIO_PORT_N_ERR_STS_INP_ES))) {
 		/* Remove any queued packets by locking/unlocking port */
 		rio_read_config_32(rdev,
-			rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum),
+			RIO_DEV_PORT_N_CTL_CSR(rdev, portnum),
 			&regval);
 		if (!(regval & RIO_PORT_N_CTL_LOCKOUT)) {
 			rio_write_config_32(rdev,
-				rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum),
+				RIO_DEV_PORT_N_CTL_CSR(rdev, portnum),
 				regval | RIO_PORT_N_CTL_LOCKOUT);
 			udelay(50);
 			rio_write_config_32(rdev,
-				rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum),
+				RIO_DEV_PORT_N_CTL_CSR(rdev, portnum),
 				regval);
 		}
 
@@ -245,7 +243,7 @@ tsi57x_em_handler(struct rio_dev *rdev, u8 portnum)
 		 * valid bit
 		 */
 		rio_read_config_32(rdev,
-			rdev->phys_efptr + RIO_PORT_N_MNT_RSP_CSR(portnum),
+			RIO_DEV_PORT_N_MNT_RSP_CSR(rdev, portnum),
 			&regval);
 
 		/* Send a Packet-Not-Accepted/Link-Request-Input-Status control
@@ -259,8 +257,8 @@ tsi57x_em_handler(struct rio_dev *rdev, u8 portnum)
 			while (checkcount--) {
 				udelay(50);
 				rio_read_config_32(rdev,
-					rdev->phys_efptr +
-						RIO_PORT_N_MNT_RSP_CSR(portnum),
+					RIO_DEV_PORT_N_MNT_RSP_CSR(rdev,
+								   portnum),
 					&regval);
 				if (regval & RIO_PORT_N_MNT_RSP_RVAL)
 					goto exit_es;
include/linux/rio.h +4 -7
index f7ec35b..37b95c4 100644
@@ -163,6 +163,7 @@ enum rio_device_state {
  * @dst_ops: Destination operation capabilities
  * @comp_tag: RIO component tag
  * @phys_efptr: RIO device extended features pointer
+ * @phys_rmap: LP-Serial Register Map Type (1 or 2)
  * @em_efptr: RIO Error Management features pointer
  * @dma_mask: Mask of bits of RIO address this device implements
  * @driver: Driver claiming this device
@@ -193,6 +194,7 @@ struct rio_dev {
 	u32 dst_ops;
 	u32 comp_tag;
 	u32 phys_efptr;
+	u32 phys_rmap;
 	u32 em_efptr;
 	u64 dma_mask;
 	struct rio_driver *driver;	/* RIO driver claiming this device */
@@ -237,11 +239,6 @@ struct rio_dbell {
 	void *dev_id;
 };
 
-enum rio_phy_type {
-	RIO_PHY_PARALLEL,
-	RIO_PHY_SERIAL,
-};
-
 /**
  * struct rio_mport - RIO master port info
  * @dbells: List of doorbell events
@@ -259,8 +256,8 @@ enum rio_phy_type {
  * @id: Port ID, unique among all ports
  * @index: Port index, unique among all port interfaces of the same type
  * @sys_size: RapidIO common transport system size
- * @phy_type: RapidIO phy type
  * @phys_efptr: RIO port extended features pointer
+ * @phys_rmap: LP-Serial EFB Register Mapping type (1 or 2).
  * @name: Port name string
  * @dev: device structure associated with an mport
  * @priv: Master port private data
@@ -289,8 +286,8 @@ struct rio_mport {
 				 * 0 - Small size. 256 devices.
 				 * 1 - Large size, 65536 devices.
 				 */
-	enum rio_phy_type phy_type;	/* RapidIO phy type */
 	u32 phys_efptr;
+	u32 phys_rmap;
 	unsigned char name[RIO_MAX_MPORT_NAME];
 	struct device dev;
 	void *priv;		/* Master port private data */
include/linux/rio_regs.h +132 -35

237 lines not on this page · raw message

Signature · 1 line
1.7.8.4
#12 lore raw

Re: [PATCH 11/13] rapidio: modify for rev.3 specification changes

Quoted 13 lines · Alexandre Bounine

Implement changes made in RapidIO specification rev.3 to LP-Serial Physical Layer register definitions:
- use per-port register offset calculations based on LP-Serial Extended Features Block (EFB) Register Map type (I or II) with different per-port offset step (0x20 vs. 0x40 respectfully).
- remove deprecated Parallel Physical layer definitions and related code.

Quoted 10 lines
---
 drivers/rapidio/devices/rio_mport_cdev.c |    2 +-
 drivers/rapidio/devices/tsi721.c         |    8 +-
 drivers/rapidio/rio-scan.c               |   74 +++----------
 drivers/rapidio/rio.c                    |  149 ++++++++++++++-------------
 drivers/rapidio/rio.h                    |    2 +-
 drivers/rapidio/switches/tsi57x.c        |   26 ++---
 include/linux/rio.h                      |   11 +--
 include/linux/rio_regs.h                 |  167 +++++++++++++++++++++++------
 8 files changed, 248 insertions(+), 191 deletions(-)

This is breaking the build for me on powerpc, for
corenet64_smp_defconfig at least.

eg.

http://kisskb.ellerman.id.au/kisskb/buildresult/12750751/

Commit: Add linux-next specific files for 20160722

	  13123042d0dbf7635f052efc2ae69fd9af624f1d

Compiler: powerpc-linux-gcc (GCC) 4.6.3

Possible errors
---------------

arch/powerpc/sysdev/fsl_rio.c:702:11: error: 'struct rio_mport' has no member named 'phy_type' arch/powerpc/sysdev/fsl_rio.c:702:25: error: 'RIO_PHY_SERIAL' undeclared (first use in this function) make[2]: *** [arch/powerpc/sysdev/fsl_rio.o] Error 1
make[1]: *** [arch/powerpc/sysdev] Error 2
make: *** [sub-make] Error 2

cheers

#13 lore raw

RE: [PATCH 11/13] rapidio: modify for rev.3 specification changes

Hi Michael,

Alex is currently on vacation, but will return August 2. He will resolve this issue at that time.

Cheers,
Barry

-----Original Message-----
From: Michael Ellerman [mailto:[email protected]]
Sent: Wednesday, July 27, 2016 12:53 AM
To: Bounine, Alexandre; Andrew Morton
Cc: Bounine, Alexandre; Matt Porter; Andre van Herk; Wood, Barry; [email protected]
Subject: Re: [PATCH 11/13] rapidio: modify for rev.3 specification changes

Quoted 13 lines · Alexandre Bounine

Implement changes made in RapidIO specification rev.3 to LP-Serial Physical Layer register definitions:
- use per-port register offset calculations based on LP-Serial Extended Features Block (EFB) Register Map type (I or II) with different per-port offset step (0x20 vs. 0x40 respectfully).
- remove deprecated Parallel Physical layer definitions and related code.

Quoted 10 lines
---
 drivers/rapidio/devices/rio_mport_cdev.c |    2 +-
 drivers/rapidio/devices/tsi721.c         |    8 +-
 drivers/rapidio/rio-scan.c               |   74 +++----------
 drivers/rapidio/rio.c                    |  149 ++++++++++++++-------------
 drivers/rapidio/rio.h                    |    2 +-
 drivers/rapidio/switches/tsi57x.c        |   26 ++---
 include/linux/rio.h                      |   11 +--
 include/linux/rio_regs.h                 |  167 +++++++++++++++++++++++------
 8 files changed, 248 insertions(+), 191 deletions(-)

This is breaking the build for me on powerpc, for corenet64_smp_defconfig at least.

eg.

http://kisskb.ellerman.id.au/kisskb/buildresult/12750751/

Commit: Add linux-next specific files for 20160722

	  13123042d0dbf7635f052efc2ae69fd9af624f1d

Compiler: powerpc-linux-gcc (GCC) 4.6.3

Possible errors
---------------

arch/powerpc/sysdev/fsl_rio.c:702:11: error: 'struct rio_mport' has no member named 'phy_type' arch/powerpc/sysdev/fsl_rio.c:702:25: error: 'RIO_PHY_SERIAL' undeclared (first use in this function) make[2]: *** [arch/powerpc/sysdev/fsl_rio.o] Error 1
make[1]: *** [arch/powerpc/sysdev] Error 2
make: *** [sub-make] Error 2

cheers

#14 lore raw

Re: [PATCH 11/13] rapidio: modify for rev.3 specification changes

In reply to Michael Ellerman
Quoted 37 lines · On Wed, 27 Jul 2016 14:53:25 +1000 Michael Ellerman <[email protected]> wrote:
Quoted 13 lines · Alexandre Bounine

Implement changes made in RapidIO specification rev.3 to LP-Serial Physical Layer register definitions:
- use per-port register offset calculations based on LP-Serial Extended Features Block (EFB) Register Map type (I or II) with different per-port offset step (0x20 vs. 0x40 respectfully).
- remove deprecated Parallel Physical layer definitions and related code.

Quoted 10 lines
---
 drivers/rapidio/devices/rio_mport_cdev.c |    2 +-
 drivers/rapidio/devices/tsi721.c         |    8 +-
 drivers/rapidio/rio-scan.c               |   74 +++----------
 drivers/rapidio/rio.c                    |  149 ++++++++++++++-------------
 drivers/rapidio/rio.h                    |    2 +-
 drivers/rapidio/switches/tsi57x.c        |   26 ++---
 include/linux/rio.h                      |   11 +--
 include/linux/rio_regs.h                 |  167 +++++++++++++++++++++++------
 8 files changed, 248 insertions(+), 191 deletions(-)

This is breaking the build for me on powerpc, for
corenet64_smp_defconfig at least.

eg.

http://kisskb.ellerman.id.au/kisskb/buildresult/12750751/

Commit: Add linux-next specific files for 20160722

	  13123042d0dbf7635f052efc2ae69fd9af624f1d

Compiler: powerpc-linux-gcc (GCC) 4.6.3

Quoted 8 lines

Possible errors
---------------

arch/powerpc/sysdev/fsl_rio.c:702:11: error: 'struct rio_mport' has no member named 'phy_type' arch/powerpc/sysdev/fsl_rio.c:702:25: error: 'RIO_PHY_SERIAL' undeclared (first use in this function) make[2]: *** [arch/powerpc/sysdev/fsl_rio.o] Error 1
make[1]: *** [arch/powerpc/sysdev] Error 2
make: *** [sub-make] Error 2

I'll go out on a limb and assume it's this:

arch/powerpc/sysdev/fsl_rio.c renamed from arch/powerpc/sysdev/fsl_rio.c~powerpc-fsl_rio-apply-changes-for-rio-spec-rev-3-fix +0 -5
@@ -698,11 +698,6 @@ int fsl_rio_setup(struct platform_device
 			RIO_INB_ATMU_REGS_PORT2_OFFSET));
 
 
-		/* Set to receive any dist ID for serial RapidIO controller. */
-		if (port->phy_type == RIO_PHY_SERIAL)
-			out_be32((priv->regs_win
-				+ RIO_ISR_AACR + i*0x80), RIO_ISR_AACR_AA);
-
 		/* Configure maintenance transaction window */
 		out_be32(&priv->maint_atmu_regs->rowbar,
 			port->iores.start >> 12);

_

#15 lore raw

Re: [PATCH 11/13] rapidio: modify for rev.3 specification changes

Quoted 9 lines · Andrew Morton
Quoted 2 lines · On Wed, 27 Jul 2016 14:53:25 +1000 Michael Ellerman <[email protected]> wrote:

arch/powerpc/sysdev/fsl_rio.c:702:11: error: 'struct rio_mport' has no member named 'phy_type' arch/powerpc/sysdev/fsl_rio.c:702:25: error: 'RIO_PHY_SERIAL' undeclared (first use in this function)

I'll go out on a limb and assume it's this:

arch/powerpc/sysdev/fsl_rio.c int fsl_rio_setup(struct platform_device · line 705

Quoted 8 lines
arch/powerpc/sysdev/fsl_rio.c renamed from arch/powerpc/sysdev/fsl_rio.c~powerpc-fsl_rio-apply-changes-for-rio-spec-rev-3-fix +0 -5
@@ -698,11 +698,6 @@ int fsl_rio_setup(struct platform_device
 			RIO_INB_ATMU_REGS_PORT2_OFFSET));
 
 
-		/* Set to receive any dist ID for serial RapidIO controller. */
-		if (port->phy_type == RIO_PHY_SERIAL)
-			out_be32((priv->regs_win
-				+ RIO_ISR_AACR + i*0x80), RIO_ISR_AACR_AA);
-

Yep, thanks.

Hopefully someone somewhere is testing this on powerpc, I don't have one of those FSL boxes. But at least it will build now.

cheers

#16 lore raw

PATCH 12/13 powerpc/fsl_rio: apply changes for RIO spec rev 3

In reply to Alexandre Bounine

- Remove check for parallel PHY
- Set LP-Serial Register Map type

Cc Matt Porter <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Andre van Herk <[email protected]>
Cc Barry Wood <[email protected]>
---
 arch/powerpc/sysdev/fsl_rio.c |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)
arch/powerpc/sysdev/fsl_rio.c +2 -10
index 1958838..ee5b9f1 100644
@@ -643,19 +643,11 @@ int fsl_rio_setup(struct platform_device *dev)
 		port->ops = ops;
 		port->priv = priv;
 		port->phys_efptr = 0x100;
+		port->phys_rmap = 1;
 		priv->regs_win = rio_regs_win;
 
-		/* Probe the master port phy type */
 		ccsr = in_be32(priv->regs_win + RIO_CCSR + i*0x20);
-		port->phy_type = (ccsr & 1) ? RIO_PHY_SERIAL : RIO_PHY_PARALLEL;
-		if (port->phy_type == RIO_PHY_PARALLEL) {
-			dev_err(&dev->dev, "RIO: Parallel PHY type, unsupported port type!\n");
-			release_resource(&port->iores);
-			kfree(priv);
-			kfree(port);
-			continue;
-		}
-		dev_info(&dev->dev, "RapidIO PHY type: Serial\n");
+
 		/* Checking the port training status */
 		if (in_be32((priv->regs_win + RIO_ESCSR + i*0x20)) & 1) {
 			dev_err(&dev->dev, "Port %d is not ready. "
Signature · 1 line
1.7.8.4
#17 lore raw

PATCH 13/13 rapidio/switches: add driver for IDT gen3 switches

In reply to Alexandre Bounine

Add RapidIO switch driver for IDT Gen3 switch devices: RXS1632 and RXS2448.

---
 drivers/rapidio/switches/Kconfig    |    6 +
 drivers/rapidio/switches/Makefile   |    1 +
 drivers/rapidio/switches/idt_gen3.c |  381 +++++++++++++++++++++++++++++++++++
 include/linux/rio_ids.h             |    2 +
 4 files changed, 390 insertions(+), 0 deletions(-)
 create mode 100644 drivers/rapidio/switches/idt_gen3.c
drivers/rapidio/switches/Kconfig +6 -0
index 3458415..92767fd 100644
@@ -22,3 +22,9 @@ config RAPIDIO_CPS_GEN2
 	default n
 	---help---
 	  Includes support for ITD CPS Gen.2 serial RapidIO switches.
+
+config RAPIDIO_RXS_GEN3
+	tristate "IDT RXS Gen.3 SRIO switch support"
+	default n
+	---help---
+	  Includes support for ITD RXS Gen.3 serial RapidIO switches.
drivers/rapidio/switches/Makefile +1 -0
index 051cc6b..6bdd54c 100644
@@ -6,3 +6,4 @@ obj-$(CONFIG_RAPIDIO_TSI57X)	+= tsi57x.o
 obj-$(CONFIG_RAPIDIO_CPS_XX)	+= idtcps.o
 obj-$(CONFIG_RAPIDIO_TSI568)	+= tsi568.o
 obj-$(CONFIG_RAPIDIO_CPS_GEN2)	+= idt_gen2.o
+obj-$(CONFIG_RAPIDIO_RXS_GEN3)	+= idt_gen3.o
drivers/rapidio/switches/idt_gen3.c new file +381 -0

381 lines not on this page · raw message

include/linux/rio_ids.h +2 -0
index 2543bc1..334c576 100644
@@ -38,5 +38,7 @@
 #define RIO_DID_IDTVPS1616		0x0377
 #define RIO_DID_IDTSPS1616		0x0378
 #define RIO_DID_TSI721			0x80ab
+#define RIO_DID_IDTRXS1632		0x80e5
+#define RIO_DID_IDTRXS2448		0x80e6
 
 #endif				/* LINUX_RIO_IDS_H */
Signature · 1 line
1.7.8.4
#18 lore raw

Re: [PATCH 13/13] rapidio/switches: add driver for IDT gen3 switches

Quoted 20 lines · On Thu, 21 Jul 2016 14:18:54 -0400 Alexandre Bounine…

Add RapidIO switch driver for IDT Gen3 switch devices: RXS1632 and RXS2448.

...

drivers/rapidio/switches/idt_gen3.c new file +16 -0
+static int
+idtg3_em_handler(struct rio_dev *rdev, u8 pnum)
+{
+	u32 err_status;
+	u32 rval;
+
+	rio_read_config_32(rdev,
+			RIO_DEV_PORT_N_ERR_STS_CSR(rdev, pnum),
+			&err_status);
+
+	/* Do nothing for device/link removal */
+	if (err_status & RIO_PORT_N_ERR_STS_PORT_UNINIT)
+		return 0;
+
+	/* When link is OK we have a device insertion.
+	 * Request port soft reset to clear errors if they present.

drivers/rapidio/switches/idt_gen3.c line 258

Quoted 10 lines
drivers/rapidio/switches/idt_gen3.c new file +10 -0
+	 * Inbound and outbound ackIDs will be 0 after reset.
+	 */
+	if (err_status & (RIO_PORT_N_ERR_STS_OUT_ES |
+				RIO_PORT_N_ERR_STS_INP_ES)) {
+		rio_read_config_32(rdev, RIO_PLM_SPx_IMP_SPEC_CTL(pnum), &rval);
+		rio_write_config_32(rdev, RIO_PLM_SPx_IMP_SPEC_CTL(pnum),
+				    rval | RIO_PLM_SPx_IMP_SPEC_CTL_SOFT_RST);
+		udelay(10);
+		rio_write_config_32(rdev, RIO_PLM_SPx_IMP_SPEC_CTL(pnum), rval);
+		mdelay(500);

Yikes, that's a very long busywait. A half-second machine freeze on uniprocessor (if such exists ;)). We can't use msleep()?

Quoted 7 lines
drivers/rapidio/switches/idt_gen3.c new file +4 -0
+	}
+
+	return 0;
+}
 
...
#19 lore raw

RE: [PATCH 13/13] rapidio/switches: add driver for IDT gen3 switches

Quoted 44 lines

-----Original Message-----
From: Andrew Morton [mailto:[email protected]]
Sent: Thursday, July 21, 2016 2:37 PM
To: Bounine, Alexandre
Cc: Matt Porter; Andre van Herk; Wood, Barry; linux- [email protected]
Subject: Re: [PATCH 13/13] rapidio/switches: add driver for IDT gen3 switches

Quoted 1 line · On Thu, 21 Jul 2016 14:18:54 -0400 Alexandre Bounine…

Add RapidIO switch driver for IDT Gen3 switch devices: RXS1632 and

RXS2448.

Quoted 14 lines

...

drivers/rapidio/switches/idt_gen3.c new file +11 -0
+static int
+idtg3_em_handler(struct rio_dev *rdev, u8 pnum)
+{
+	u32 err_status;
+	u32 rval;
+
+	rio_read_config_32(rdev,
+			RIO_DEV_PORT_N_ERR_STS_CSR(rdev, pnum),
+			&err_status);
+
+	/* Do nothing for device/link removal */

drivers/rapidio/switches/idt_gen3.c

Quoted 10 lines
drivers/rapidio/switches/idt_gen3.c new file +10 -0
+	if (err_status & RIO_PORT_N_ERR_STS_PORT_UNINIT)
+		return 0;
+
+	/* When link is OK we have a device insertion.
+	 * Request port soft reset to clear errors if they present.
+	 * Inbound and outbound ackIDs will be 0 after reset.
+	 */
+	if (err_status & (RIO_PORT_N_ERR_STS_OUT_ES |
+				RIO_PORT_N_ERR_STS_INP_ES)) {
+		rio_read_config_32(rdev, RIO_PLM_SPx_IMP_SPEC_CTL(pnum),

&rval);

drivers/rapidio/switches/idt_gen3.c

Quoted 4 lines
drivers/rapidio/switches/idt_gen3.c new file +4 -0
+		rio_write_config_32(rdev, RIO_PLM_SPx_IMP_SPEC_CTL(pnum),
+				    rval | RIO_PLM_SPx_IMP_SPEC_CTL_SOFT_RST);
+		udelay(10);
+		rio_write_config_32(rdev, RIO_PLM_SPx_IMP_SPEC_CTL(pnum),

rval);

Quoted 5 lines

drivers/rapidio/switches/idt_gen3.c line 258

Quoted 1 line
drivers/rapidio/switches/idt_gen3.c new file +1 -0
+		mdelay(500);

Yikes, that's a very long busywait. A half-second machine freeze on uniprocessor (if such exists ;)). We can't use msleep()?

My bad ;) No problem with msleep() at all. We just need to give enough time for Rapidio link to get back (spec defines 500mS).
Do you want a patch on patch?

Quoted 7 lines
Quoted 7 lines
drivers/rapidio/switches/idt_gen3.c new file +4 -0
+	}
+
+	return 0;
+}
 
...
#20 lore raw

Re: [PATCH 13/13] rapidio/switches: add driver for IDT gen3 switches

Quoted 9 lines · Alexandre
Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+		udelay(10);
+		rio_write_config_32(rdev, RIO_PLM_SPx_IMP_SPEC_CTL(pnum),

rval);

drivers/rapidio/switches/idt_gen3.c line 258

Quoted 1 line
drivers/rapidio/switches/idt_gen3.c new file +1 -0
+		mdelay(500);

Yikes, that's a very long busywait. A half-second machine freeze on uniprocessor (if such exists ;)). We can't use msleep()?

Quoted 3 lines

My bad ;) No problem with msleep() at all. We just need to give enough time for Rapidio link to get back (spec defines 500mS).
Do you want a patch on patch?

Patch on patch is good. But something tested, please ;)