From patchwork Tue Dec 3 16:19:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11271543 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CED62930 for ; Tue, 3 Dec 2019 16:19:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B787B20848 for ; Tue, 3 Dec 2019 16:19:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B787B20848 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 17AD66E842; Tue, 3 Dec 2019 16:19:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by gabe.freedesktop.org (Postfix) with ESMTPS id BE2476E842 for ; Tue, 3 Dec 2019 16:19:23 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id p17so4164444wmi.3 for ; Tue, 03 Dec 2019 08:19:23 -0800 (PST) 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=13dFyRuLsyW17L3u2HAbZCErRk1PbJ6inYhyuChxpmg=; b=JhAYJvE4iZGO0d0Cbn7pJQI9L+sSupNvQtlOsu4h5SrcFTCG9QdwTqhl5wvBabzuW9 tYGbrx5dS83zydVthgQSh1MpBCvuQtuP43T6W6g+bK9aMemzUnteF1ZLo0TBwG6xyOco OQ/CDj33bBxO600PzSXUrAdhySovydEaN4xci2eWZQ5BLTUDvBnfBoK2uICYOrwPFOrl NxXQlQbDtnQKVwhjvS6YlePrNirsFg8PHThOMu2z5rQGXCQ3LG3FS+PF+MHIWNLp86VW MYhELfaZAff95AyycoDbzJnCh4SesEohUn2xj0VDKdBuSmkZ5OXiAssk2uvoi2K+rg0f Ldjw== X-Gm-Message-State: APjAAAXOcBuyffW0O5HPJTE9Z/r5pCEPbXWk/j7zz/tmJnDNpo2WQIpB q+OAY9d6PjCRY2Ut3XRYQ2U= X-Google-Smtp-Source: APXvYqz/z7cWbhRIA/RS2LVcKFh88eK0TxN7IMSGMD/oby9NvGZZmwhcOQvVZi+xjZ4n9c13I9N4Rw== X-Received: by 2002:a1c:1f56:: with SMTP id f83mr36446287wmf.93.1575389962291; Tue, 03 Dec 2019 08:19:22 -0800 (PST) Received: from localhost (pD9E518ED.dip0.t-ipconnect.de. [217.229.24.237]) by smtp.gmail.com with ESMTPSA id z13sm3619750wmi.18.2019.12.03.08.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 08:19:20 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH v2 3/9] drm/tegra: gem: Remove premature import restrictions Date: Tue, 3 Dec 2019 17:19:08 +0100 Message-Id: <20191203161914.1312555-3-thierry.reding@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191203161914.1312555-1-thierry.reding@gmail.com> References: <20191203161914.1312555-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=13dFyRuLsyW17L3u2HAbZCErRk1PbJ6inYhyuChxpmg=; b=vb9/WSWv8RFWMt8ae7K+046gviWArn2nCvSELxg/IJxynNXa3TtXmebq1XvZbHPCP1 jLXCrm5krgUzUg+7uBVkbRisQdlgOvUof2Kp5S6k3EYLs0INzTFzvXtnib953Ux1OF9q 6gQ6JYKRnB/RJxRRBbDdjMDDfWdT4EOEM0gznGBHwV+7uYsZXUUFlG+vPJXUnsRh7alD mOS5PxV1j8UbhhcocaSLNnHSSPAlcMUe5cgadKt8exOK+T2J3acdj2JbofI4zapdJmVy w35Oc6R+jWs+H2GtnizeznUQxFmLtopdWeCE9FQNm1YF4wBFfEqXIWvo6hkO5AZYdyMU UVsw== 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: linux-tegra@vger.kernel.org, Daniel Vetter , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Thierry Reding All the display related blocks on Tegra require contiguous memory. Using the DMA API, there is no knowing at import time which device will end up using the buffer, so it's not known whether or not an IOMMU will be used to map the buffer. Move the check for non-contiguous buffers/mappings to the tegra_dc_pin() function which is now the earliest point where it is known if a DMA BUF can be used by the given device or not. v2: add check for contiguous buffer/mapping in tegra_dc_pin() Reviewed-by: Daniel Vetter Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/gem.c | 7 ------- drivers/gpu/drm/tegra/plane.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c index 6dfad56eee2b..bc15b430156d 100644 --- a/drivers/gpu/drm/tegra/gem.c +++ b/drivers/gpu/drm/tegra/gem.c @@ -440,13 +440,6 @@ static struct tegra_bo *tegra_bo_import(struct drm_device *drm, err = tegra_bo_iommu_map(tegra, bo); if (err < 0) goto detach; - } else { - if (bo->sgt->nents > 1) { - err = -EINVAL; - goto detach; - } - - bo->iova = sg_dma_address(bo->sgt->sgl); } bo->gem.import_attach = attach; diff --git a/drivers/gpu/drm/tegra/plane.c b/drivers/gpu/drm/tegra/plane.c index 163b590be224..cadcdd9ea427 100644 --- a/drivers/gpu/drm/tegra/plane.c +++ b/drivers/gpu/drm/tegra/plane.c @@ -129,6 +129,17 @@ static int tegra_dc_pin(struct tegra_dc *dc, struct tegra_plane_state *state) goto unpin; } + /* + * The display controller needs contiguous memory, so + * fail if the buffer is discontiguous and we fail to + * map its SG table to a single contiguous chunk of + * I/O virtual memory. + */ + if (err > 1) { + err = -EINVAL; + goto unpin; + } + state->iova[i] = sg_dma_address(sgt->sgl); state->sgt[i] = sgt; } else {