From patchwork Thu Jul 25 01:10:00 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: 169660 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp10935020ilk; Wed, 24 Jul 2019 18:10:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOG0tJvtMlzTB5tKozD+hP+bGJNfUuhps0TcVLP61w8n32Grw3tvBITEe33sjm6/+0PrUH X-Received: by 2002:a63:3fc9:: with SMTP id m192mr85504766pga.429.1564017019369; Wed, 24 Jul 2019 18:10:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564017019; cv=none; d=google.com; s=arc-20160816; b=kvNx800SzZM/azNE6W/A22oG2YAW/3ulknl7gGgk5vdTP+4zRa3uHX+rV9HQfG2lLR kEMLMTNBSE+ZtMyFCnYIPKFTNRbLvTSjORXuV05sfHLa98OX9qU9+mMrIQTl5qNCD43c gjU7dsdt7ct4ro9gwzUC06ao4lwiZgLg0/w9d6uIfWVF7y4DhX5cyiZHxCaCbOMUNes9 c3jXi/L06c/Dre2RMS716DRLci0ROf+C2VWEAeWh0rXrgi8Qc6gMoszKueTOXkgEX+Dy MggtFQXiDEMHJESo6igGWfj/4OcY+PBkNDwoFd0xIMfsKmPDrwWnLywDPZUIRqtNdXgG eFFQ== 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=KNl57wjsHSYUZbBywNEzn7NIKR5Ar+yvCQQALIn62AQ=; b=NpyRB1HPJYNUVoqLkFpqJceRC5Axppj0vY7T8r61UmUY3rWVG1oKi1Z/FQNdyO+b/7 o+ZmWomLwYdsUWBpJl3BcoExgRN3BKgh/ijlHyj0iIX6JijIdUmLc22idFoTyBMwyrWx Rc2agD1FS83d0cOCefBJHqUJbXMY/F3Xky+udvjyTc59DLQkXFtELelQKfP3riPsnLAc 2ObHii4J1sMnhfiMI7D3uDoUztBFPVjX2u9M0osyOOueTulBz4ZSHUmT2JsmVop8jYOJ zLNRe3mnO5WM9RqHmh1psR4wZykJO2tZe/uoj52bPQnAj7SYssiZUoam6AfGt7zyVKwG Vdog== 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 131.252.210.177 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. [131.252.210.177]) by mx.google.com with ESMTPS id w9si14226632pjv.67.2019.07.24.18.10.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Jul 2019 18:10:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 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 2244B6E386; Thu, 25 Jul 2019 01:10:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id 150996E2D1 for ; Thu, 25 Jul 2019 01:10:12 +0000 (UTC) Received: by mail-io1-f66.google.com with SMTP id i10so93582806iol.13 for ; Wed, 24 Jul 2019 18:10:12 -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=Vtjr2+2ofsw45xyTHE3FvXFioIOLEbSTpIy61lySGK0=; b=twLRZTWrT4vFrN996zPkX3YRS/mDlNSuha7ZQ57gJeBAuZBu97bnu2BYYZcFhQidn6 ao/xZOCHzKugWEAJUfz9j7JQ56u/wsmLVpyrpBFayX3FBtL9VCLaukc3clODYQnWWwnw CQWU/41ak33xA+Mixl8TvwTjYBl+gp+vzXRMdXxy3+aZsRCVEeDb4IHAK6yrmJIybT6j iqRbkV7Djz99tRFxjFgUiSsIUH2d1ZpcS9hd/YeWnV0Q0DAKX/2nM27ZABCmtsq3MaJh OSgDOjVP8iTs5ACyKvrq9y+S1ggWDFhqxhEacm6ObJ8TJjYYAO8ly3jKB7N7Po9yGNVZ UIBw== X-Gm-Message-State: APjAAAVYSLVkHaFlWxSPLH57M8ytbTAW2KPTE+rtfEtiOlPt8rPJcUx/ 548S2/QpVcJWdttDr3C2ErrK81k= X-Received: by 2002:a5d:8411:: with SMTP id i17mr49770529ion.83.1564017011013; Wed, 24 Jul 2019 18:10:11 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.254]) by smtp.googlemail.com with ESMTPSA id o7sm40675924ioo.81.2019.07.24.18.10.09 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 18:10:10 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 4/7] drm/panfrost: Split panfrost_mmu_map SG list mapping to its own function Date: Wed, 24 Jul 2019 19:10:00 -0600 Message-Id: <20190725011003.30837-5-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190725011003.30837-1-robh@kernel.org> References: <20190725011003.30837-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 , Sean Paul , Steven Price , David Airlie , Boris Brezillon , Alyssa Rosenzweig , Robin Murphy 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: Alyssa Rosenzweig Reviewed-by: Steven Price 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;