Skip to content

Commit e00bc40

Browse files
Kelvin Caowesleywesley
authored andcommitted
Improve mrpc efficiency by leveraging write combining
Previously, fill 1k mrpc input buffer took 1024 memwr tlps, with each payload 1 dwords, while only 1 byte is valid(enabled). In this case, too many of tlps within a timer windows introduce tlp throttling. By use of the write combining buffer, 1k data fillingtake 16 memwr tlps with each payload 16 dwords.
1 parent 9ac6b1d commit e00bc40

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

switchtec.c

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@ static void stuser_set_state(struct switchtec_user *stuser,
128128

129129
static void mrpc_complete_cmd(struct switchtec_dev *stdev);
130130

131+
static void flush_wc_buf(struct switchtec_dev *stdev)
132+
{
133+
struct ntb_dbmsg_regs __iomem *mmio_dbmsg;
134+
135+
mmio_dbmsg = (void __iomem *)stdev->mmio_ntb +
136+
SWITCHTEC_NTB_REG_DBMSG_OFFSET;
137+
ioread32(&mmio_dbmsg->reserved1[0]);
138+
}
139+
131140
static void mrpc_cmd_submit(struct switchtec_dev *stdev)
132141
{
133142
/* requires the mrpc_mutex to already be held when called */
@@ -152,6 +161,7 @@ static void mrpc_cmd_submit(struct switchtec_dev *stdev)
152161
stdev->mrpc_busy = 1;
153162
memcpy_toio(&stdev->mmio_mrpc->input_data,
154163
stuser->data, stuser->data_len);
164+
flush_wc_buf(stdev);
155165
iowrite32(stuser->cmd, &stdev->mmio_mrpc->cmd);
156166

157167
schedule_delayed_work(&stdev->mrpc_timeout,
@@ -1379,23 +1389,38 @@ static int switchtec_init_pci(struct switchtec_dev *stdev,
13791389
struct pci_dev *pdev)
13801390
{
13811391
int rc;
1392+
void __iomem *map;
1393+
unsigned long res_start, res_len;
13821394

13831395
rc = pcim_enable_device(pdev);
13841396
if (rc)
13851397
return rc;
13861398

1387-
rc = pcim_iomap_regions(pdev, 0x1, KBUILD_MODNAME);
1388-
if (rc)
1389-
return rc;
1390-
13911399
rc = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
13921400
if (rc)
13931401
return rc;
13941402

13951403
pci_set_master(pdev);
13961404

1397-
stdev->mmio = pcim_iomap_table(pdev)[0];
1398-
stdev->mmio_mrpc = stdev->mmio + SWITCHTEC_GAS_MRPC_OFFSET;
1405+
res_start = pci_resource_start(pdev, 0);
1406+
res_len = pci_resource_len(pdev, 0);
1407+
1408+
if (!devm_request_mem_region(&pdev->dev, res_start,
1409+
res_len, KBUILD_MODNAME))
1410+
return -EBUSY;
1411+
1412+
stdev->mmio_mrpc = devm_ioremap_wc(&pdev->dev, res_start,
1413+
SWITCHTEC_GAS_TOP_CFG_OFFSET);
1414+
if (!stdev->mmio_mrpc)
1415+
return -ENOMEM;
1416+
1417+
map = devm_ioremap(&pdev->dev,
1418+
res_start + SWITCHTEC_GAS_TOP_CFG_OFFSET,
1419+
res_len - SWITCHTEC_GAS_TOP_CFG_OFFSET);
1420+
if (!map)
1421+
return -ENOMEM;
1422+
1423+
stdev->mmio = map - SWITCHTEC_GAS_TOP_CFG_OFFSET;
13991424
stdev->mmio_sw_event = stdev->mmio + SWITCHTEC_GAS_SW_EVENT_OFFSET;
14001425
stdev->mmio_sys_info = stdev->mmio + SWITCHTEC_GAS_SYS_INFO_OFFSET;
14011426
stdev->mmio_flash_info = stdev->mmio + SWITCHTEC_GAS_FLASH_INFO_OFFSET;

0 commit comments

Comments
 (0)