From patchwork Wed Jul 17 18:33:49 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: 169154 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1320406ilk; Wed, 17 Jul 2019 11:34:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUT5CzYGxysGcOPqXTXhWQikimmIXhckp6SwoVdrNmNV/aFPcsiftn5qVnQJCeAoOPTGAL X-Received: by 2002:a17:90a:cb18:: with SMTP id z24mr44494655pjt.108.1563388440893; Wed, 17 Jul 2019 11:34:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563388440; cv=none; d=google.com; s=arc-20160816; b=QzI3C1pyeyORlAPrNQ2PDvMk5Qr2EwRbag8T+spEE2sRIQtuBmzn1j1D0C/7kx2Htc rkgpMhoH2EWDp1LZAJwf4XKQtVdqa1fNxGl/7KizNdM+jOEaR2DAf+FDXagT+MbwFNf6 cNCNgD4QDFALWwbPVq7m3os2DEjZag+L2FoBBkgGSWB0Kp6Hmr+8RKod/YyB6bTmNqa5 Os7xzkhX/EmNDGZmPzFo8Q8ltgIQAyRnEp3I/j2T9SY3fPW1KcM8yZoPXI1pZZJUKpes OIPpZaYmXCGZr1mt+/aCqttuPOlcZyo4Otw4mcmaphYHsf7FM8A70HZVsUC5dLiQD1wt slfA== 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=KbVdILdci8JbBcfapsBRU2n/d6cDbzS7lNJlMhuxag8=; b=Lg19TUO2aIo453BOY5uWM3VqUddjr9PhuKYhs7WPuK9rSlqaPKkVNQ10L+0Wy/KvBq ngY4Ttzjw3yCDtuXfkYN/stfU5Epf1hYJuzAa10pTsgKWAnUXSpO7LuhGlsPd0JTxSkz LoPhdyo+KWypNoIRfp8Jl0xubCER5GjZiyzyg7RbR5Vfdyjx0fsc+TzpDun+G2WvJr6t C/UcXSwhGceeUua1QWfDFo2oK19SxozCRQpzc9iXxrz+chavLkuaemtLafiVj29YFyaw mLJIlA4cjzhSOfAH6X+Sn+bGig5BQO2jzyzRslYDOkzG/xpyzXYVADMUlFYCE+Ctm9tR QmSQ== 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 193si12234817pfz.124.2019.07.17.11.34.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jul 2019 11:34:00 -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 6C57B6E299; Wed, 17 Jul 2019 18:33:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-io1-f65.google.com (mail-io1-f65.google.com [209.85.166.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0A0AF6E299 for ; Wed, 17 Jul 2019 18:33:57 +0000 (UTC) Received: by mail-io1-f65.google.com with SMTP id k8so47416957iot.1 for ; Wed, 17 Jul 2019 11:33:57 -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=1UIlM7SqWsgXXGozfeMCqufFvDydJKnsrEypmQVIzCo=; b=NSAij7v2lJegyqYqz+tlXfL1JKMNnsA/NhaoCgJU3GxFjeIpflVPBxBFvQywRnz9VA N0+IJOXH1MLT82VY1SM9VWBvaL4pDjvOa8Ki18aeBZFIGIIyQItFvw8sunkamx/Lv2tD RvUi1zbtQlhq54BKf9XaHdg2wFckTbx4LTt27fcVY6io2AyLIwqREz7c2ab8xrNzowFV MBVehfK/THZzA4rzCA+sIM8QPqDMiRgEp+X8GFp7DtTt1SLW4R1RxjgAwrypA2HWrG9t T2PdNH1H/ch5v9jGOnDtmMn8mdXXkiSXLetLNCroyHSVdvEhsg2KHRgBtARP4vsf+cJx VF6A== X-Gm-Message-State: APjAAAWJrxEqaDd/GbCNZStAwQN+Pe4gCTnhBg7boH+Qa6rqPTSYW7CF HrlMOqZNVxlgQg8ytsvUuYpfiX8= X-Received: by 2002:a05:6602:220a:: with SMTP id n10mr38905737ion.205.1563388436085; Wed, 17 Jul 2019 11:33:56 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.255]) by smtp.googlemail.com with ESMTPSA id v10sm22109472iob.43.2019.07.17.11.33.54 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 17 Jul 2019 11:33:54 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/5] drm/panfrost: Split panfrost_mmu_map SG list mapping to its own function Date: Wed, 17 Jul 2019 12:33:49 -0600 Message-Id: <20190717183352.22519-2-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190717183352.22519-1-robh@kernel.org> References: <20190717183352.22519-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: Boris Brezillon , Robin Murphy , Alyssa Rosenzweig , Tomeu Vizoso , Steven Price 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 Cc: Steven Price Cc: Alyssa Rosenzweig Signed-off-by: Rob Herring Reviewed-by: Steven Price --- 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 f502e91be42a..5383b837f04b 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -167,27 +167,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); @@ -200,18 +186,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;