[PATCH v1 05/12] gna: initialize mmu

From: Maciej Kwapulinski
Date: Tue Feb 16 2021 - 11:12:00 EST


From: Tomasz Jankowski <tomasz1.jankowski@xxxxxxxxx>

Setup mmu in the driver with a new memory component.

Signed-off-by: Tomasz Jankowski <tomasz1.jankowski@xxxxxxxxx>
Tested-by: Savo Novakovic <savox.novakovic@xxxxxxxxx>
Signed-off-by: Maciej Kwapulinski <maciej.kwapulinski@xxxxxxxxxxxxxxx>
---
drivers/misc/gna/gna_device.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/drivers/misc/gna/gna_device.c b/drivers/misc/gna/gna_device.c
index f962c7e1e5e9..d6a6d3cab570 100644
--- a/drivers/misc/gna/gna_device.c
+++ b/drivers/misc/gna/gna_device.c
@@ -23,6 +23,16 @@ static int gna_dev_init(struct gna_private *gna_priv, struct pci_dev *pcidev,
bld_reg = gna_reg_read(gna_priv->bar0.mem_addr, GNA_MMIO_IBUFFS);
gna_priv->hw_info.in_buf_s = bld_reg & GENMASK(7, 0);

+ if (gna_mmu_alloc(gna_priv)) {
+ dev_err(&gna_priv->dev, "gna mmu allocation failed\n");
+ return -EFAULT;
+ }
+ dev_dbg(&pcidev->dev, "maximum memory size %llu num pd %d\n",
+ gna_priv->info.max_hw_mem, gna_priv->info.num_pagetables);
+ dev_dbg(&pcidev->dev, "desc rsvd size %d mmu vamax size %d\n",
+ gna_priv->info.desc_info.rsvd_size,
+ gna_priv->info.desc_info.mmu_info.vamax_size);
+
mutex_init(&gna_priv->mmu_lock);

idr_init(&gna_priv->memory_idr);
@@ -35,6 +45,7 @@ static int gna_dev_init(struct gna_private *gna_priv, struct pci_dev *pcidev,
static void gna_dev_deinit(struct gna_private *gna_priv)
{
idr_destroy(&gna_priv->memory_idr);
+ gna_mmu_free(gna_priv);
pci_set_drvdata(gna_priv->pdev, NULL);
}

--
2.28.0