Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp618038pxf; Wed, 24 Mar 2021 11:40:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFf2wJGwvrqp+X7XujQhE1MqYt7bE1VJfKJQLrM0ZehmpXS99iGjRWINw/upzUHoiXylII X-Received: by 2002:a17:907:162b:: with SMTP id hb43mr5341012ejc.41.1616611220935; Wed, 24 Mar 2021 11:40:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616611220; cv=none; d=google.com; s=arc-20160816; b=w+p18vNLA/F5Jolv2flT+vZbOsT5QJMQt1vrBCpfVkK4VFoAsz2+MYeaP+f/4kbUQv 5gI7BOPzjrOOfJ36oICkA0smIrH0V/BqegthFiDOM4A2Rp1n2rov53BoeXjPVHlYCKA4 XKik4rUB/CN385IkVDGNG3jDOh5P0yxp+tWpIYpxIDHUTap+LtekEmr1BJwV8YC6mjeq eT6+X8IgVQbIpbO3xoU2faxLXLtQX7FKpk/UiNDZOMQzTXhBWQ6ygHxmSK14QOIXHVZy sTyLZeBFpa2wwtfK+loZASzAE2h8iYhDOSC/V7jVgk3gAmYvFbTSRlzuaUYa0dI3btjy V4ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=E0x4D4OgQaVhjeDwJFwU6Vfu0SChXtDli4mP9nQZIkQ=; b=V4wfFKVYySJ67Nmk1nNDkgRv4yJ+gAI5KtoXOXSpT7Yc/I9KbGCQChqw/bk0q74i0l IaZH+f3qBShiRm+7fy873HmNSAbgxdBfLIXgnofuMEnMPKhPhadjGTx8VdZydPpRAQWS RQiAMNz8jjDPTde7hT+h4xbTgtiEf+ly30Hr3m1tNe3gpRzqdxT/whulGH4DCTbVSoyl mPGqP9GlzHs9FZ45mXCWSJLnycvrRZ4h9ez7bf2eVvFW2LMaOQwhkSLQbIZHokATwXRv 3qgqjsACbeW/i3xMN3Qmct58bagPohTQF/8TGItr/jzYjm5CZbdwNorZPpSeVsLg/+ws 50PQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qc18si2460683ejb.574.2021.03.24.11.39.57; Wed, 24 Mar 2021 11:40:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237774AbhCXSjI (ORCPT + 99 others); Wed, 24 Mar 2021 14:39:08 -0400 Received: from mga09.intel.com ([134.134.136.24]:17739 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237643AbhCXSi3 (ORCPT ); Wed, 24 Mar 2021 14:38:29 -0400 IronPort-SDR: XlAG5BrE69rbM1RaGqBGN1cKxPTaWf/bgf5xBIwgqwIqRNX5/r5uX1AFvih92MMXcH4owk1KJP LrUDJ88vFoqA== X-IronPort-AV: E=McAfee;i="6000,8403,9933"; a="190859508" X-IronPort-AV: E=Sophos;i="5.81,275,1610438400"; d="scan'208";a="190859508" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2021 11:38:29 -0700 IronPort-SDR: um/LvL+gG9RzKP8mq3wM0U6H60hcBUDZQTXQAZpaESfMqf5RXGCTuXM16hjffM6OxaLYaWv6US fZVoY2wh9RNg== X-IronPort-AV: E=Sophos;i="5.81,275,1610438400"; d="scan'208";a="608203796" Received: from gna-dev.igk.intel.com ([10.102.80.34]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2021 11:38:26 -0700 From: Maciej Kwapulinski To: Greg Kroah-Hartman , Arnd Bergmann , Jonathan Corbet , Derek Kiernan , Dragan Cvetic , Andy Shevchenko Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maciej Kwapulinski , Tomasz Jankowski , Savo Novakovic Subject: [PATCH v2 05/13] intel_gna: initialize mmu Date: Wed, 24 Mar 2021 19:36:02 +0100 Message-Id: <20210324183610.4574-6-maciej.kwapulinski@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210324183610.4574-1-maciej.kwapulinski@linux.intel.com> References: <20210324183610.4574-1-maciej.kwapulinski@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tomasz Jankowski Setup mmu in the driver with a new memory component. Signed-off-by: Tomasz Jankowski Tested-by: Savo Novakovic Co-Developed-by: Maciej Kwapulinski Signed-off-by: Maciej Kwapulinski --- drivers/misc/intel/gna/gna_device.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/misc/intel/gna/gna_device.c b/drivers/misc/intel/gna/gna_device.c index 25137d0ac519..3d559f22ee93 100644 --- a/drivers/misc/intel/gna/gna_device.c +++ b/drivers/misc/intel/gna/gna_device.c @@ -9,10 +9,11 @@ #define GNA_BAR0 0 -static void gna_dev_init(struct gna_private *gna_priv, struct pci_dev *pcidev, +static int gna_dev_init(struct gna_private *gna_priv, struct pci_dev *pcidev, const struct pci_device_id *pci_id) { u32 bld_reg; + int ret; pci_set_drvdata(pcidev, gna_priv); @@ -24,10 +25,29 @@ static void gna_dev_init(struct gna_private *gna_priv, struct pci_dev *pcidev, bld_reg = gna_reg_read(gna_priv->bar0_base, GNA_MMIO_IBUFFS); gna_priv->hw_info.in_buf_s = bld_reg & GENMASK(7, 0); + if (gna_mmu_alloc(gna_priv)) { + dev_err(&pcidev->dev, "mmu allocation failed\n"); + ret = -EFAULT; + goto err_pci_drvdata_unset; + + } + 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); mutex_init(&gna_priv->memidr_lock); + + return 0; + +err_pci_drvdata_unset: + pci_set_drvdata(pcidev, NULL); + + return ret; } static void gna_dev_deinit(struct gna_private *gna_priv) @@ -84,7 +104,12 @@ int gna_probe(struct pci_dev *pcidev, const struct pci_device_id *pci_id) pci_set_master(pcidev); - gna_dev_init(gna_priv, pcidev, pci_id); + ret = gna_dev_init(gna_priv, pcidev, pci_id); + if (ret) { + dev_err(&pcidev->dev, "could not initialize %s device\n", GNA_DV_NAME); + return ret; + } + return 0; } -- 2.28.0