diff options
| author | Om Prakash Singh <omp@nvidia.com> | 2020-04-13 02:39:39 -0400 |
|---|---|---|
| committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2020-04-13 15:39:01 -0400 |
| commit | 28f161a7886c439db5c19d60fb0f02a09e89c8ae (patch) | |
| tree | 6c824a2e8d38ec0620c26e8b1216744dfe1f0e77 | |
| parent | c0bd0881a099b2773aaed0c2626054920c26ce4a (diff) | |
PCI: tvnet: fix memory barrier usage
replace smp_mb() memory barrier with mb() to take care of IO and
Memory access synchronization as well.
Bug 200600954
Change-Id: I2526c1b972166f241339e25f5ae8722a8d532bd6
Signed-off-by: Om Prakash Singh <omp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2327768
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Manikanta Maddireddy <mmaddireddy@nvidia.com>
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
| -rw-r--r-- | drivers/net/ethernet/nvidia/pcie/tegra_vnet.c | 18 | ||||
| -rw-r--r-- | drivers/pci/endpoint/functions/pci-epf-tegra-vnet.c | 8 |
2 files changed, 13 insertions, 13 deletions
diff --git a/drivers/net/ethernet/nvidia/pcie/tegra_vnet.c b/drivers/net/ethernet/nvidia/pcie/tegra_vnet.c index 6f5cdd510..b1f6f5d7a 100644 --- a/drivers/net/ethernet/nvidia/pcie/tegra_vnet.c +++ b/drivers/net/ethernet/nvidia/pcie/tegra_vnet.c | |||
| @@ -79,7 +79,7 @@ static void tvnet_host_raise_ep_ctrl_irq(struct tvnet_priv *tvnet) | |||
| 79 | /* BAR0 mmio address is wc mem, add mb to make sure | 79 | /* BAR0 mmio address is wc mem, add mb to make sure |
| 80 | * multiple interrupt writes are not combined. | 80 | * multiple interrupt writes are not combined. |
| 81 | */ | 81 | */ |
| 82 | smp_mb(); | 82 | mb(); |
| 83 | } else { | 83 | } else { |
| 84 | pr_err("%s: invalid irq type: %d\n", __func__, irq->irq_type); | 84 | pr_err("%s: invalid irq type: %d\n", __func__, irq->irq_type); |
| 85 | } | 85 | } |
| @@ -95,7 +95,7 @@ static void tvnet_host_raise_ep_data_irq(struct tvnet_priv *tvnet) | |||
| 95 | /* BAR0 mmio address is wc mem, add mb to make sure | 95 | /* BAR0 mmio address is wc mem, add mb to make sure |
| 96 | * multiple interrupt writes are not combined. | 96 | * multiple interrupt writes are not combined. |
| 97 | */ | 97 | */ |
| 98 | smp_mb(); | 98 | mb(); |
| 99 | } else { | 99 | } else { |
| 100 | pr_err("%s: invalid irq type: %d\n", __func__, irq->irq_type); | 100 | pr_err("%s: invalid irq type: %d\n", __func__, irq->irq_type); |
| 101 | } | 101 | } |
| @@ -138,7 +138,7 @@ static int tvnet_host_write_ctrl_msg(struct tvnet_priv *tvnet, | |||
| 138 | /* BAR0 mmio address is wc mem, add mb to make sure ctrl msg is written | 138 | /* BAR0 mmio address is wc mem, add mb to make sure ctrl msg is written |
| 139 | * before updating counters. | 139 | * before updating counters. |
| 140 | */ | 140 | */ |
| 141 | smp_mb(); | 141 | mb(); |
| 142 | tvnet_ivc_advance_wr(&tvnet->h2ep_ctrl); | 142 | tvnet_ivc_advance_wr(&tvnet->h2ep_ctrl); |
| 143 | tvnet_host_raise_ep_ctrl_irq(tvnet); | 143 | tvnet_host_raise_ep_ctrl_irq(tvnet); |
| 144 | 144 | ||
| @@ -192,7 +192,7 @@ static void tvnet_host_alloc_empty_buffers(struct tvnet_priv *tvnet) | |||
| 192 | /* BAR0 mmio address is wc mem, add mb to make sure that empty | 192 | /* BAR0 mmio address is wc mem, add mb to make sure that empty |
| 193 | * buffers are updated before updating counters. | 193 | * buffers are updated before updating counters. |
| 194 | */ | 194 | */ |
| 195 | smp_mb(); | 195 | mb(); |
| 196 | tvnet_ivc_advance_wr(&tvnet->ep2h_empty); | 196 | tvnet_ivc_advance_wr(&tvnet->ep2h_empty); |
| 197 | 197 | ||
| 198 | tvnet_host_raise_ep_ctrl_irq(tvnet); | 198 | tvnet_host_raise_ep_ctrl_irq(tvnet); |
| @@ -472,7 +472,7 @@ static netdev_tx_t tvnet_host_start_xmit(struct sk_buff *skb, | |||
| 472 | dma_desc[desc_widx].dar_low = lower_32_bits(dst_iova); | 472 | dma_desc[desc_widx].dar_low = lower_32_bits(dst_iova); |
| 473 | dma_desc[desc_widx].dar_high = upper_32_bits(dst_iova); | 473 | dma_desc[desc_widx].dar_high = upper_32_bits(dst_iova); |
| 474 | /* CB bit should be set at the end */ | 474 | /* CB bit should be set at the end */ |
| 475 | smp_mb(); | 475 | mb(); |
| 476 | /* RIE is not required for polling mode */ | 476 | /* RIE is not required for polling mode */ |
| 477 | ctrl_d = DMA_CH_CONTROL1_OFF_RDCH_RIE; | 477 | ctrl_d = DMA_CH_CONTROL1_OFF_RDCH_RIE; |
| 478 | ctrl_d |= DMA_CH_CONTROL1_OFF_RDCH_LIE; | 478 | ctrl_d |= DMA_CH_CONTROL1_OFF_RDCH_LIE; |
| @@ -485,7 +485,7 @@ static netdev_tx_t tvnet_host_start_xmit(struct sk_buff *skb, | |||
| 485 | ctrl_d = dma_desc[desc_widx].ctrl_reg.ctrl_d; | 485 | ctrl_d = dma_desc[desc_widx].ctrl_reg.ctrl_d; |
| 486 | 486 | ||
| 487 | /* DMA write should not go out of order wrt CB bit set */ | 487 | /* DMA write should not go out of order wrt CB bit set */ |
| 488 | smp_mb(); | 488 | mb(); |
| 489 | 489 | ||
| 490 | timeout = jiffies + msecs_to_jiffies(1000); | 490 | timeout = jiffies + msecs_to_jiffies(1000); |
| 491 | dma_common_wr8(tvnet->dma_base, DMA_RD_DATA_CH, DMA_READ_DOORBELL_OFF); | 491 | dma_common_wr8(tvnet->dma_base, DMA_RD_DATA_CH, DMA_READ_DOORBELL_OFF); |
| @@ -516,7 +516,7 @@ static netdev_tx_t tvnet_host_start_xmit(struct sk_buff *skb, | |||
| 516 | desc_ridx = tvnet->desc_cnt.rd_cnt % DMA_DESC_COUNT; | 516 | desc_ridx = tvnet->desc_cnt.rd_cnt % DMA_DESC_COUNT; |
| 517 | /* Clear DMA cycle bit and increment rd_cnt */ | 517 | /* Clear DMA cycle bit and increment rd_cnt */ |
| 518 | dma_desc[desc_ridx].ctrl_reg.ctrl_e.cb = 0; | 518 | dma_desc[desc_ridx].ctrl_reg.ctrl_e.cb = 0; |
| 519 | smp_mb(); | 519 | mb(); |
| 520 | 520 | ||
| 521 | tvnet->desc_cnt.rd_cnt++; | 521 | tvnet->desc_cnt.rd_cnt++; |
| 522 | #else | 522 | #else |
| @@ -525,7 +525,7 @@ static netdev_tx_t tvnet_host_start_xmit(struct sk_buff *skb, | |||
| 525 | /* BAR0 mmio address is wc mem, add mb to make sure that complete | 525 | /* BAR0 mmio address is wc mem, add mb to make sure that complete |
| 526 | * skb->data is written before updating counters. | 526 | * skb->data is written before updating counters. |
| 527 | */ | 527 | */ |
| 528 | smp_mb(); | 528 | mb(); |
| 529 | #endif | 529 | #endif |
| 530 | 530 | ||
| 531 | /* Push dst to H2EP full ring */ | 531 | /* Push dst to H2EP full ring */ |
| @@ -537,7 +537,7 @@ static netdev_tx_t tvnet_host_start_xmit(struct sk_buff *skb, | |||
| 537 | /* BAR0 mmio address is wc mem, add mb to make sure that full | 537 | /* BAR0 mmio address is wc mem, add mb to make sure that full |
| 538 | * buffer is written before updating counters. | 538 | * buffer is written before updating counters. |
| 539 | */ | 539 | */ |
| 540 | smp_mb(); | 540 | mb(); |
| 541 | tvnet_ivc_advance_wr(&tvnet->h2ep_full); | 541 | tvnet_ivc_advance_wr(&tvnet->h2ep_full); |
| 542 | tvnet_host_raise_ep_data_irq(tvnet); | 542 | tvnet_host_raise_ep_data_irq(tvnet); |
| 543 | 543 | ||
diff --git a/drivers/pci/endpoint/functions/pci-epf-tegra-vnet.c b/drivers/pci/endpoint/functions/pci-epf-tegra-vnet.c index 8d0886d49..f55790f8c 100644 --- a/drivers/pci/endpoint/functions/pci-epf-tegra-vnet.c +++ b/drivers/pci/endpoint/functions/pci-epf-tegra-vnet.c | |||
| @@ -584,13 +584,13 @@ static netdev_tx_t tvnet_ep_start_xmit(struct sk_buff *skb, | |||
| 584 | ep_dma_virt[desc_widx].dar_low = lower_32_bits(dst_iova); | 584 | ep_dma_virt[desc_widx].dar_low = lower_32_bits(dst_iova); |
| 585 | ep_dma_virt[desc_widx].dar_high = upper_32_bits(dst_iova); | 585 | ep_dma_virt[desc_widx].dar_high = upper_32_bits(dst_iova); |
| 586 | /* CB bit should be set at the end */ | 586 | /* CB bit should be set at the end */ |
| 587 | smp_mb(); | 587 | mb(); |
| 588 | ctrl_d = DMA_CH_CONTROL1_OFF_WRCH_LIE; | 588 | ctrl_d = DMA_CH_CONTROL1_OFF_WRCH_LIE; |
| 589 | ctrl_d |= DMA_CH_CONTROL1_OFF_WRCH_CB; | 589 | ctrl_d |= DMA_CH_CONTROL1_OFF_WRCH_CB; |
| 590 | ep_dma_virt[desc_widx].ctrl_reg.ctrl_d = ctrl_d; | 590 | ep_dma_virt[desc_widx].ctrl_reg.ctrl_d = ctrl_d; |
| 591 | 591 | ||
| 592 | /* DMA write should not go out of order wrt CB bit set */ | 592 | /* DMA write should not go out of order wrt CB bit set */ |
| 593 | smp_mb(); | 593 | mb(); |
| 594 | 594 | ||
| 595 | timeout = jiffies + msecs_to_jiffies(1000); | 595 | timeout = jiffies + msecs_to_jiffies(1000); |
| 596 | dma_common_wr8(tvnet->dma_base, DMA_WR_DATA_CH, DMA_WRITE_DOORBELL_OFF); | 596 | dma_common_wr8(tvnet->dma_base, DMA_WR_DATA_CH, DMA_WRITE_DOORBELL_OFF); |
| @@ -622,7 +622,7 @@ static netdev_tx_t tvnet_ep_start_xmit(struct sk_buff *skb, | |||
| 622 | desc_ridx = tvnet->desc_cnt.rd_cnt % DMA_DESC_COUNT; | 622 | desc_ridx = tvnet->desc_cnt.rd_cnt % DMA_DESC_COUNT; |
| 623 | /* Clear DMA cycle bit and increment rd_cnt */ | 623 | /* Clear DMA cycle bit and increment rd_cnt */ |
| 624 | ep_dma_virt[desc_ridx].ctrl_reg.ctrl_e.cb = 0; | 624 | ep_dma_virt[desc_ridx].ctrl_reg.ctrl_e.cb = 0; |
| 625 | smp_mb(); | 625 | mb(); |
| 626 | 626 | ||
| 627 | tvnet->desc_cnt.rd_cnt++; | 627 | tvnet->desc_cnt.rd_cnt++; |
| 628 | #else | 628 | #else |
| @@ -632,7 +632,7 @@ static netdev_tx_t tvnet_ep_start_xmit(struct sk_buff *skb, | |||
| 632 | * tx_dst_va is ioremap_wc() mem, add mb to make sure complete skb->data | 632 | * tx_dst_va is ioremap_wc() mem, add mb to make sure complete skb->data |
| 633 | * written to dst before adding it to full buffer | 633 | * written to dst before adding it to full buffer |
| 634 | */ | 634 | */ |
| 635 | smp_mb(); | 635 | mb(); |
| 636 | #endif | 636 | #endif |
| 637 | 637 | ||
| 638 | /* Push dst to EP2H full ring */ | 638 | /* Push dst to EP2H full ring */ |
