From patchwork Fri Aug 2 19:51:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 170448 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp1223146ile; Fri, 2 Aug 2019 12:52:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQJJgEuyvO07yXg45tdI/WFZYWI+khMxpd9TDIJLvPlQGdEzwE9U/D9FtnARtFmTXCYCXq X-Received: by 2002:a62:fb18:: with SMTP id x24mr59920928pfm.231.1564775524838; Fri, 02 Aug 2019 12:52:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564775524; cv=none; d=google.com; s=arc-20160816; b=KKsAF0aqf+AsC/8Eraa02G5Ck+6Tc3Zo5a4nlRi8m/SlRFSz9k7Ina07ygY7BrXK5+ iWq2/a49y19IvAGPR89MMuwHM+aVv7AoVrelmIYrRqqOA2F9gu+yeWLnpFESdLFCNh0f IHo00PVqyEhtdoR5T2PGNBuHUSVMowbT4gLJp/rpmEdXUfT2laGkf4IJpFlMYdK1XZhu fFp/F3davdfhehW1ojrb+lcfOmTmUBLAKVeuNnESDH9M8bLMmUK+KELPuhWl7rBk+f9H WD2Vz8Nl0GccPnC8B6U21Nc1m8I6A07WMg2UxFcm2yC/SryLZPI+yYtVZfpNU06xpMvI ovWg== 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=nEwBkDz5OdxwyI/pRV4kWJbsrPIunm4+1m68xc+eLfQ=; b=qH3C4d2V/nocHWoBjN8aic66HpsoFyPPxO7dv9u21LgAMi4YJZNyEy0RKwQFaDHCb4 L7PUJnJKCZGgdhyXZf2uuP+Oa0cZBItQ38iRYavPt1YkUyEA0FTh5j8I7lz0Nf8CGlkM oKFpqapL2qG5dUf4kTUY902LsGwTMrZFijaC2tdumSYOSvITQrnURI8SoHQXLmBNh7hc TKoXoPyaAX8Unxmgrm0To12oGMYY9vBBu4zV/dsTAjgU5AfaUrXAhaNyL0Rcux3DGIzx mPc2iuSn9Kn774BFiJ2RpV/LiEd5QFEv0sz4fqIMs3s8lMfVDuc95g1F/npWCqRD3jfq W4nA== 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 bx21si7043923pjb.21.2019.08.02.12.52.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Aug 2019 12:52:04 -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 0609A6EDD0; Fri, 2 Aug 2019 19:52:01 +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 778916ED77 for ; Fri, 2 Aug 2019 19:51:58 +0000 (UTC) Received: by mail-io1-f65.google.com with SMTP id j6so34879387ioa.5 for ; Fri, 02 Aug 2019 12:51:58 -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=l6R0Kh/pwj1cRdwpfVM4GshO3ikYF6B47tkVOltQGdk=; b=jFM8LRNIH4Gc5BfOXxA1YdRltwTXgYZlI2Tuo5VX7Oof6kSnO//FDauzyHSo3JQmtu Hj19iTKBA0FLtfHrRCGr9mFgMZQeapLvwGj36AJN+wm8ZMGny8Z8K+CxxQbaDljAMRsp 00OqNSDPFtWaY9tuVAfVjwV0ideZVlLMgH2GWNcTUiSHOLpqJLJLxXmvW19wKJwgMyll lSKqGEbRnfjlnqukZixvOBJYjM1VxY2eFBtexJruA2krlJzDSIw8MCrn2HJuGDeDmKtr 5zilxVMPHB2xQQlL1AG0WPTkd1R+XOky5/N1Dugh9oiBR3gMxGiJUReO0Si9H6lliujt 3JuQ== X-Gm-Message-State: APjAAAWt0nkONM5msL59/tKj6r7bcU/bqyUaoWC5nZ+JvhiT8Ca/4/Oa 9EK0MCPwx1WgU0OsbbqUFI8KnHk= X-Received: by 2002:a6b:7311:: with SMTP id e17mr82855629ioh.112.1564775517465; Fri, 02 Aug 2019 12:51:57 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.254]) by smtp.googlemail.com with ESMTPSA id s4sm98419934iop.25.2019.08.02.12.51.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 12:51:57 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 4/8] drm/panfrost: Split panfrost_mmu_map SG list mapping to its own function Date: Fri, 2 Aug 2019 13:51:46 -0600 Message-Id: <20190802195150.23207-5-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190802195150.23207-1-robh@kernel.org> References: <20190802195150.23207-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: Steven Price Acked-by: 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 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;