From patchwork Tue Oct 3 15:27:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 9983105 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2D5F4602B8 for ; Tue, 3 Oct 2017 15:27:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D620289BE for ; Tue, 3 Oct 2017 15:27:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 104B5289B1; Tue, 3 Oct 2017 15:27:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A7F84289B1 for ; Tue, 3 Oct 2017 15:27:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 53E0B6E533; Tue, 3 Oct 2017 15:27:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp.codeaurora.org (smtp.codeaurora.org [198.145.29.96]) by gabe.freedesktop.org (Postfix) with ESMTPS id ADBA16E53D; Tue, 3 Oct 2017 15:27:13 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8D04A60D3A; Tue, 3 Oct 2017 15:27:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1507044433; bh=JN5njsL6DpwBJcevqsVqA1ARg83+ZZqtIur85dTuax8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pJuUrX8EPJ7c8+bsb5GYmb8ilQolPOcAfBwZFWm0RCjfciBjdHCcSVhTJuuWSMxDO qBQPj9FLBLbmz+6mfQ9RmeojbY17z5V7aCxkU+81exDtnXz35uM0PEYbkuWyykHbnn ukXFbuFfIA5zvzRRspkE2E8w0AK6Bc5nC3ImnqhQ= Received: from jcrouse-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jcrouse@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 5F47960C52; Tue, 3 Oct 2017 15:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1507044432; bh=JN5njsL6DpwBJcevqsVqA1ARg83+ZZqtIur85dTuax8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SxuoGtsjKeiaZ0+ehIOxE41BQTCofe5/VCLVk/mLpez7x6TETTMbuTEQXAOnTIM1k rwOkinv2jHucNckqpXkzCDnTl2roGcz1ubtctnRcMyWlUevhbQsApuQ6TNTlvuKZ77 ftK6Bj5l7JSEUDIceYd1iibrENCpT6n4y+0prQok= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5F47960C52 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jcrouse@codeaurora.org From: Jordan Crouse To: freedreno@lists.freedesktop.org Subject: [PATCH 4/6] drm/msm: Map buffers on demand on the submit path Date: Tue, 3 Oct 2017 09:27:04 -0600 Message-Id: <1507044426-4042-5-git-send-email-jcrouse@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507044426-4042-1-git-send-email-jcrouse@codeaurora.org> References: <1507044426-4042-1-git-send-email-jcrouse@codeaurora.org> Cc: Sushmita Susheelendra , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Sushmita Susheelendra Map and pin buffers on demand on the submission path. This ensures that we only map buffers whose iova are actually needed for submission as opposed to all buffers in the buffer list. For instance, the command buffers, and the reloc buffers for processing relocs. Also remove unused member valid from the struct msm_gem_submit. Signed-off-by: Sushmita Susheelendra Signed-off-by: Jordan Crouse --- drivers/gpu/drm/msm/msm_gem_submit.c | 58 +++++++++++++++++------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index 2d2aa65..47a9e87 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c @@ -256,41 +256,38 @@ static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit) return ret; } -static int submit_pin_objects(struct msm_gem_submit *submit) +static int submit_pin_object(struct msm_gem_submit *submit, int i) { - int i, ret = 0; - - submit->valid = true; - - for (i = 0; i < submit->nr_bos; i++) { - struct msm_gem_object *msm_obj = submit->bos[i].obj; - uint64_t iova; + struct msm_gem_object *msm_obj = submit->bos[i].obj; + uint64_t iova; + int ret; - /* if locking succeeded, pin bo: */ - ret = msm_gem_get_iova(&msm_obj->base, - submit->gpu->aspace, &iova); + if (submit->bos[i].flags & BO_PINNED) + return 0; - if (ret) - break; + /* if locking succeeded, pin bo: */ + ret = msm_gem_get_iova(&msm_obj->base, submit->gpu->aspace, &iova); + if (ret) + return ret; - submit->bos[i].flags |= BO_PINNED; + submit->bos[i].flags |= BO_PINNED; - if (iova == submit->bos[i].iova) { - submit->bos[i].flags |= BO_VALID; - } else { - submit->bos[i].iova = iova; - /* iova changed, so address in cmdstream is not valid: */ - submit->bos[i].flags &= ~BO_VALID; - submit->valid = false; - } + if (iova == submit->bos[i].iova) { + submit->bos[i].flags |= BO_VALID; + } else { + submit->bos[i].iova = iova; + /* iova changed, so address in cmdstream is not valid: */ + submit->bos[i].flags &= ~BO_VALID; } - return ret; + return 0; } static int submit_bo(struct msm_gem_submit *submit, uint32_t idx, struct msm_gem_object **obj, uint64_t *iova, bool *valid) { + int ret; + if (idx >= submit->nr_bos) { DRM_ERROR("invalid buffer index: %u (out of %u)\n", idx, submit->nr_bos); @@ -299,6 +296,14 @@ static int submit_bo(struct msm_gem_submit *submit, uint32_t idx, if (obj) *obj = submit->bos[idx].obj; + + if (!iova && !valid) + return 0; + + ret = submit_pin_object(submit, idx); + if (ret) + return ret; + if (iova) *iova = submit->bos[idx].iova; if (valid) @@ -482,10 +487,6 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, if (ret) goto out; - ret = submit_pin_objects(submit); - if (ret) - goto out; - for (i = 0; i < args->nr_cmds; i++) { struct drm_msm_gem_submit_cmd submit_cmd; void __user *userptr = @@ -536,9 +537,6 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, submit->cmd[i].iova = iova + submit_cmd.submit_offset; submit->cmd[i].idx = submit_cmd.submit_idx; - if (submit->valid) - continue; - ret = submit_reloc(submit, msm_obj, submit_cmd.submit_offset, submit_cmd.nr_relocs, submit_cmd.relocs); if (ret)