myri10ge minor updates
Subsystems (2)
cover myri10ge minor updates
Hi Jeff,
4 small updates of myri10ge for 2.6.21 will follow this mail:
1) fix error checking and return value in myri10ge_allocate_rings
2) use pci_map_page to prepare the dmatest buffer
3) prevent 4k rdma on SGI TIOCE chipset
4) add a wc_enabled flag to myri10ge_priv
Thanks,
Brice
PATCH 1/4 myri10ge: fix error checking and return value in myri10ge_allocate_rings
Fix a missing error check in myri10ge_allocate_rings() and set status to -ENOMEM before all actual allocations so that the error path returns what it should.
--- drivers/net/myri10ge/myri10ge.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/myri10ge/myri10ge.c +4 -0
@@ -1456,6 +1456,8 @@ status =myri10ge_send_cmd (mgp,MXGEFW_CMD_GET_SEND_RING_SIZE , &cmd,0 ); tx_ring_size = cmd.data0; status |=myri10ge_send_cmd (mgp,MXGEFW_CMD_GET_RX_RING_SIZE , &cmd,0 ); +if (status !=0 ) +return status; rx_ring_size = cmd.data0; tx_ring_entries = tx_ring_size /sizeof (struct mcp_kreq_ether_send );
@@ -1463,6 +1465,8 @@ mgp->tx.mask = tx_ring_entries -1 ; mgp->rx_small.mask = mgp->rx_big.mask = rx_ring_entries -1 ; + status = -ENOMEM ; +/* allocate the host shadow rings */ bytes =8 + (MYRI10GE_MAX_SEND_DESC_TSO +4 )
Re: [PATCH 1/4] myri10ge: fix error checking and return value in myri10ge_allocate_rings
Quoted 8 lines · Brice Goglin
Fix a missing error check in
myri10ge_allocate_rings()and set status to-ENOMEMbefore all actual allocations so that the error path returns what it should.Signed-off-by Brice Goglin <[email protected]>--- drivers/net/myri10ge/myri10ge.c | 4 ++++ 1 file changed, 4 insertions(+)
applied 1-4
PATCH 2/4 myri10ge: use pci_map_page to prepare the dmatest buffer
In reply to Brice GoglinAllocate a specific page and use pci_map_page for dma test instead of relying on another existing buffer.
--- drivers/net/myri10ge/myri10ge.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/net/myri10ge/myri10ge.c +16 -6
@@ -717,6 +717,8 @@int status;size_t bytes;u32 len; +struct page *dmatest_page; +dma_addr_t dmatest_bus;/* try to send a reset command to the card to see if it * is alive */
@@ -726,6 +728,11 @@dev_err (&mgp->pdev->dev,"failed reset\n" );return -ENXIO ; } + dmatest_page =alloc_page (GFP_KERNEL ); +if (!dmatest_page) +return -ENOMEM ; + dmatest_bus =pci_map_page (mgp->pdev, dmatest_page,0 ,PAGE_SIZE , +DMA_BIDIRECTIONAL );/* Now exchange information about interrupts */
@@ -764,8 +771,8 @@ len = mgp->tx.boundary; - cmd.data0 =MYRI10GE_LOWPART_TO_U32 (mgp->rx_done.bus); - cmd.data1 =MYRI10GE_HIGHPART_TO_U32 (mgp->rx_done.bus); + cmd.data0 =MYRI10GE_LOWPART_TO_U32 (dmatest_bus); + cmd.data1 =MYRI10GE_HIGHPART_TO_U32 (dmatest_bus); cmd.data2 = len *0x10000 ; status =myri10ge_send_cmd (mgp,MXGEFW_DMA_TEST , &cmd,0 );if (status ==0 )
@@ -774,8 +781,8 @@else dev_warn (&mgp->pdev->dev,"DMA read benchmark failed: %d\n" , status); - cmd.data0 =MYRI10GE_LOWPART_TO_U32 (mgp->rx_done.bus); - cmd.data1 =MYRI10GE_HIGHPART_TO_U32 (mgp->rx_done.bus); + cmd.data0 =MYRI10GE_LOWPART_TO_U32 (dmatest_bus); + cmd.data1 =MYRI10GE_HIGHPART_TO_U32 (dmatest_bus); cmd.data2 = len *0x1 ; status =myri10ge_send_cmd (mgp,MXGEFW_DMA_TEST , &cmd,0 );if (status ==0 )
@@ -785,8 +792,8 @@dev_warn (&mgp->pdev->dev,"DMA write benchmark failed: %d\n" , status); - cmd.data0 =MYRI10GE_LOWPART_TO_U32 (mgp->rx_done.bus); - cmd.data1 =MYRI10GE_HIGHPART_TO_U32 (mgp->rx_done.bus); + cmd.data0 =MYRI10GE_LOWPART_TO_U32 (dmatest_bus); + cmd.data1 =MYRI10GE_HIGHPART_TO_U32 (dmatest_bus); cmd.data2 = len *0x10001 ; status =myri10ge_send_cmd (mgp,MXGEFW_DMA_TEST , &cmd,0 );if (status ==0 )
@@ -796,6 +803,9 @@dev_warn (&mgp->pdev->dev,"DMA read/write benchmark failed: %d\n" , status); +pci_unmap_page (mgp->pdev, dmatest_bus,PAGE_SIZE ,DMA_BIDIRECTIONAL ); +put_page (dmatest_page); +memset (mgp->rx_done.entry,0 , bytes);/* reset mcp/driver shared state back to 0 */
PATCH 3/4 myri10ge: prevent 4k rdma on SGI TIOCE chipset
In reply to Brice GoglinDo not use 4k rdma request on SGI TIOCE chipset since this bridge does not support it.
--- drivers/net/myri10ge/myri10ge.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/myri10ge/myri10ge.c +6 -0
@@ -2514,6 +2514,12 @@ bridge->vendor, bridge->device); mgp->tx.boundary =4096 ; mgp->fw_name = myri10ge_fw_aligned; + }else if (bridge && + bridge->vendor ==PCI_VENDOR_ID_SGI && + bridge->device ==0x4002 /* TIOCE pcie-port */ ) { +/* this pcie bridge does not support 4K rdma request */ + mgp->tx.boundary =2048 ; + mgp->fw_name = myri10ge_fw_aligned; } }else {if (myri10ge_force_firmware ==1 ) {
PATCH 4/4 myri10ge: add a wc_enabled flag to myri10ge_priv
In reply to Brice GoglinAdd a wc_enabled flag in the myri10ge_priv instead of relying on mtrr >= 0.
--- drivers/net/myri10ge/myri10ge.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/myri10ge/myri10ge.c +7 -3
@@ -181,6 +181,7 @@int intr_coal_delay;__be32 __iomem *intr_coal_delay_ptr;int mtrr; +int wc_enabled;int wake_queue;int stop_queue;int down_cnt;
@@ -1385,7 +1386,7 @@ data[i] = ((unsigned long *)&mgp->stats)[i]; data[i++] = (unsigned int )mgp->tx.boundary; - data[i++] = (unsigned int )(mgp->mtrr >=0 ); + data[i++] = (unsigned int )mgp->wc_enabled; data[i++] = (unsigned int )mgp->pdev->irq; data[i++] = (unsigned int )mgp->msi_enabled; data[i++] = (unsigned int )mgp->read_dma;
@@ -1749,7 +1750,7 @@ goto abort_with_irq; } -if (myri10ge_wcfifo && mgp->mtrr >=0 ) { +if (myri10ge_wcfifo && mgp->wc_enabled) { mgp->tx.wc_fifo = (u8 __iomem *) mgp->sram +MXGEFW_ETH_SEND_4 ; mgp->rx_small.wc_fifo = (u8 __iomem *) mgp->sram +MXGEFW_ETH_RECV_SMALL ;
@@ -2850,9 +2851,12 @@ mgp->board_span =pci_resource_len (pdev,0 ); mgp->iomem_base =pci_resource_start (pdev,0 ); mgp->mtrr =-1 ; + mgp->wc_enabled =0 ;#ifdef CONFIG_MTRR mgp->mtrr =mtrr_add (mgp->iomem_base, mgp->board_span,MTRR_TYPE_WRCOMB ,1 ); +if (mgp->mtrr >=0 ) + mgp->wc_enabled =1 ;#endif /* Hack. need to get rid of these magic numbers */ mgp->sram_size =
@@ -2947,7 +2951,7 @@dev_info (dev,"%s IRQ %d, tx bndry %d, fw %s, WC %s\n" , (mgp->msi_enabled ?"MSI" :"xPIC" ), netdev->irq, mgp->tx.boundary, mgp->fw_name, - (mgp->mtrr >=0 ?"Enabled" :"Disabled" )); + (mgp->wc_enabled ?"Enabled" :"Disabled" ));return 0 ;