From patchwork Thu Aug 8 22:21:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 170868 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp9165263ile; Thu, 8 Aug 2019 15:22:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvHF7FFnDykTtvhMIgvFkol2y9wQP+En8DcBlbcmM30Wm/0oep1v6Yn0vved2ihVlHEags X-Received: by 2002:a17:90a:5887:: with SMTP id j7mr6180625pji.136.1565302933610; Thu, 08 Aug 2019 15:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565302933; cv=none; d=google.com; s=arc-20160816; b=iqUazJUbs9AjNL/wkGKgGoQpq5Ui0Nh7/bvEBRrLu0r2ehWoFgyjtK3hvo99jDHENJ KQu0e/+uyznUGb68yyNdyOC/UXLg7TZ1eIjj9Tj8hiQI3APZyOAYl6flMETyN44RfdPe kmdES0N4F55Iv3fC6aPqZyhSgdkbjeln1aSf/M4Jlp7PJqSVMoPHPRdfVAQsdOy5/1Gf +JpLU5sXfjlJYXbUlyKO0/rnjXFVAE5c6JyOh9YEE5i5Yqhm6mH7YM7svoZnyZ3IWiUG Ef5xLbwalNMqC+WqnrgTlvt/oO/p+pyzAQh8WPn4YYzmismdYYJkdq5shN2DxVqlO38P nDrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:delivered-to; bh=GFsKv0wBfr8OD7BLISnXA/qpQpURRmk/zOX6PaU/Z5I=; b=eKQWmhuvbD4h6Lsa/ffT0b6j9YpYTWbG+pxEJhviTfkJ1kc72Ur6Aoh1RgZuC0wzHS Mw1tHlFseNvF91FOtbUyYEzuJLnpQ9uTV4h5qp2qw1cjV8+EIk+ctMWWfkhyVmAqZd8v yGqZdiVUGi384MyHvvAebMdyy3BaK3/fG+8RqxLoubFbcXEhvSCQ2buD3Smtp2f4tlqG /QD+0S4qWPFwNajZ86Uw00v3Ae77MY5ZkMQ5pxdBUhmkOpKy7tif+zOlkEySezZIQaiK ATAmU1NtTuLO3do5XEaJEU79cwmaplY2v3UfMeLH5uSgUoKsB9uDJYQBu9JGVFi4nPgM zgtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id s11si51134616pgm.412.2019.08.08.15.22.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Aug 2019 15:22:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 56F886ECD0; Thu, 8 Aug 2019 22:22:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ot1-f68.google.com (mail-ot1-f68.google.com [209.85.210.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id 90CA76ECCE for ; Thu, 8 Aug 2019 22:22:08 +0000 (UTC) Received: by mail-ot1-f68.google.com with SMTP id b7so74845378otl.11 for ; Thu, 08 Aug 2019 15:22:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1fnUesRlbFn29wRcuFLexUuzLWRtNkSEYvkJw+HNGBY=; b=phziIbTi2qFlsanX42sfTeo9bWfxqMIaDmlMCSrFXk7g6fIHntDdXcRxwOEyOD2lJx DP4m+qgwFBKLe/dUfCl7jpBFjaqb8qvaSH5sqnvRWcMefGaVPguF1cyj5/ELQaaydzuC ohEBpjoNlbMhQo8377+xihX7vGoy1pK6yAO4yQh0qasB/PA9bhTUMlmEt4DvMnDd3VsP LuEjy9r+KOv4Fx7i8hD+LmIvoAhVza4fwn9Y9MzQ2O/gBwQaS2pa3bUPIDElALtGdYvc x5/9++Da6hnWGnfhzucv+6YhaQdYDLw6m+iVm405rz7weTPdDjroOwULehLZ0YNk7o1g cgSw== X-Gm-Message-State: APjAAAWbjGq9hZz9R99InZ//diBexNU8JHGmeQ5SMXg0O1WUP9eb0Z6i N2LjB5+Q/WWHWwI2s6TGnmefXWo= X-Received: by 2002:a6b:8ed7:: with SMTP id q206mr10306346iod.120.1565302927425; Thu, 08 Aug 2019 15:22:07 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.254]) by smtp.googlemail.com with ESMTPSA id i4sm118528553iog.31.2019.08.08.15.22.06 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 08 Aug 2019 15:22:06 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 4/9] drm/panfrost: Split panfrost_mmu_map SG list mapping to its own function Date: Thu, 8 Aug 2019 16:21:55 -0600 Message-Id: <20190808222200.13176-5-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190808222200.13176-1-robh@kernel.org> References: <20190808222200.13176-1-robh@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomeu Vizoso , Maxime Ripard , Robin Murphy , Steven Price , David Airlie , Boris Brezillon , Alyssa Rosenzweig , Sean Paul Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In preparation to create partial GPU mappings of BOs on page faults, split out the SG list handling of panfrost_mmu_map(). Cc: Tomeu Vizoso Cc: Boris Brezillon Cc: Robin Murphy Reviewed: Steven Price Acked-by: Alyssa Rosenzweig Signed-off-by: Rob Herring --- drivers/gpu/drm/panfrost/panfrost_mmu.c | 52 +++++++++++++++---------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c index 92ac995dd9c6..b4ac149b2399 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -145,27 +145,13 @@ static size_t get_pgsize(u64 addr, size_t size) return SZ_2M; } -int panfrost_mmu_map(struct panfrost_gem_object *bo) +static int mmu_map_sg(struct panfrost_device *pfdev, u64 iova, + int prot, struct sg_table *sgt) { - struct drm_gem_object *obj = &bo->base.base; - struct panfrost_device *pfdev = to_panfrost_device(obj->dev); - struct io_pgtable_ops *ops = pfdev->mmu->pgtbl_ops; - u64 iova = bo->node.start << PAGE_SHIFT; unsigned int count; struct scatterlist *sgl; - struct sg_table *sgt; - int ret; - - if (WARN_ON(bo->is_mapped)) - return 0; - - sgt = drm_gem_shmem_get_pages_sgt(obj); - if (WARN_ON(IS_ERR(sgt))) - return PTR_ERR(sgt); - - ret = pm_runtime_get_sync(pfdev->dev); - if (ret < 0) - return ret; + struct io_pgtable_ops *ops = pfdev->mmu->pgtbl_ops; + u64 start_iova = iova; mutex_lock(&pfdev->mmu->lock); @@ -178,18 +164,42 @@ int panfrost_mmu_map(struct panfrost_gem_object *bo) while (len) { size_t pgsize = get_pgsize(iova | paddr, len); - ops->map(ops, iova, paddr, pgsize, IOMMU_WRITE | IOMMU_READ); + ops->map(ops, iova, paddr, pgsize, prot); iova += pgsize; paddr += pgsize; len -= pgsize; } } - mmu_hw_do_operation(pfdev, 0, bo->node.start << PAGE_SHIFT, - bo->node.size << PAGE_SHIFT, AS_COMMAND_FLUSH_PT); + mmu_hw_do_operation(pfdev, 0, start_iova, iova - start_iova, + AS_COMMAND_FLUSH_PT); mutex_unlock(&pfdev->mmu->lock); + return 0; +} + +int panfrost_mmu_map(struct panfrost_gem_object *bo) +{ + struct drm_gem_object *obj = &bo->base.base; + struct panfrost_device *pfdev = to_panfrost_device(obj->dev); + struct sg_table *sgt; + int ret; + int prot = IOMMU_READ | IOMMU_WRITE; + + if (WARN_ON(bo->is_mapped)) + return 0; + + sgt = drm_gem_shmem_get_pages_sgt(obj); + if (WARN_ON(IS_ERR(sgt))) + return PTR_ERR(sgt); + + ret = pm_runtime_get_sync(pfdev->dev); + if (ret < 0) + return ret; + + mmu_map_sg(pfdev, bo->node.start << PAGE_SHIFT, prot, sgt); + pm_runtime_mark_last_busy(pfdev->dev); pm_runtime_put_autosuspend(pfdev->dev); bo->is_mapped = true;