mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-23 17:55:05 +03:00
PCI: EPF: tvnet: fixed the fence memory issue
1.Make the allocate_fence() thread-safe
2.Update the fence_do_work according to auto
fix: https://nvbugs/4539983
3.Shouldn't creat fence in callback
4.There was typo which mixed ctrl with data.
Bug 4456727
Bug 4451567
Change-Id: If7676c8d77dc40bd5f77927efa7616e7970da183
Signed-off-by: Jason Mei <jianjunm@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3087944
(cherry picked from commit 396db89160)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3096906
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
f67a6565fb
commit
df830d411d
@@ -991,14 +991,15 @@ allocate_fence(struct syncpt_t *syncpt)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct dma_fence *fence = NULL;
|
struct dma_fence *fence = NULL;
|
||||||
|
|
||||||
|
mutex_lock(&syncpt->lock);
|
||||||
fence = host1x_fence_create(syncpt->sp, ++syncpt->threshold, false);
|
fence = host1x_fence_create(syncpt->sp, ++syncpt->threshold, false);
|
||||||
if (IS_ERR_OR_NULL(fence)) {
|
if (IS_ERR_OR_NULL(fence)) {
|
||||||
ret = PTR_ERR(fence);
|
ret = PTR_ERR(fence);
|
||||||
pr_err("host1x_fence_create failed with: %d\n", ret);
|
pr_err("host1x_fence_create failed with: %d\n", ret);
|
||||||
|
mutex_unlock(&syncpt->lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&syncpt->lock);
|
|
||||||
ret = dma_fence_add_callback(fence, &syncpt->fence_cb, host1x_cb_func);
|
ret = dma_fence_add_callback(fence, &syncpt->fence_cb, host1x_cb_func);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
/* If already expired. */
|
/* If already expired. */
|
||||||
@@ -1030,8 +1031,10 @@ fence_do_work(struct syncpt_t *syncpt)
|
|||||||
|
|
||||||
mutex_lock(&syncpt->lock);
|
mutex_lock(&syncpt->lock);
|
||||||
/* If deinit triggered, no need to proceed. */
|
/* If deinit triggered, no need to proceed. */
|
||||||
if (syncpt->fence_release)
|
if (syncpt->fence_release) {
|
||||||
|
mutex_unlock(&syncpt->lock);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (syncpt->fence) {
|
if (syncpt->fence) {
|
||||||
dma_fence_put(syncpt->fence);
|
dma_fence_put(syncpt->fence);
|
||||||
@@ -1041,7 +1044,6 @@ fence_do_work(struct syncpt_t *syncpt)
|
|||||||
|
|
||||||
ret = allocate_fence(syncpt);
|
ret = allocate_fence(syncpt);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
mutex_unlock(&syncpt->lock);
|
|
||||||
pr_err("allocate_fence failed with: %d\n", ret);
|
pr_err("allocate_fence failed with: %d\n", ret);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1119,15 +1121,15 @@ static int tvnet_ep_poll(struct napi_struct *napi, int budget)
|
|||||||
{
|
{
|
||||||
struct pci_epf_tvnet *tvnet = container_of(napi, struct pci_epf_tvnet,
|
struct pci_epf_tvnet *tvnet = container_of(napi, struct pci_epf_tvnet,
|
||||||
napi);
|
napi);
|
||||||
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0))
|
||||||
struct irqsp_data *data_irqsp = tvnet->data_irqsp;
|
struct irqsp_data *data_irqsp = tvnet->data_irqsp;
|
||||||
|
#endif
|
||||||
int work_done;
|
int work_done;
|
||||||
|
|
||||||
work_done = tvnet_ep_process_h2ep_msg(tvnet);
|
work_done = tvnet_ep_process_h2ep_msg(tvnet);
|
||||||
if (work_done < budget) {
|
if (work_done < budget) {
|
||||||
napi_complete(napi);
|
napi_complete(napi);
|
||||||
#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0))
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0))
|
||||||
schedule_work(&data_irqsp->syncpt.work);
|
|
||||||
#else
|
|
||||||
schedule_work(&data_irqsp->reprime_work);
|
schedule_work(&data_irqsp->reprime_work);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1281,8 +1283,8 @@ static int tvnet_ep_pci_epf_setup_irqsp(struct pci_epf_tvnet *tvnet)
|
|||||||
|
|
||||||
#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0))
|
#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0))
|
||||||
syncpt_addr = get_syncpt_shim_offset(data_irqsp->syncpt.id);
|
syncpt_addr = get_syncpt_shim_offset(data_irqsp->syncpt.id);
|
||||||
ctrl_irqsp->syncpt.phy_addr = syncpt_addr;
|
data_irqsp->syncpt.phy_addr = syncpt_addr;
|
||||||
ctrl_irqsp->syncpt.size = PAGE_SIZE;
|
data_irqsp->syncpt.size = PAGE_SIZE;
|
||||||
#else
|
#else
|
||||||
syncpt_addr = nvhost_interrupt_syncpt_get_syncpt_addr(data_irqsp->is);
|
syncpt_addr = nvhost_interrupt_syncpt_get_syncpt_addr(data_irqsp->is);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user