From patchwork Tue Dec 3 16:19:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11271541 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 0840C138D for ; Tue, 3 Dec 2019 16:19:23 +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 E552C2080A for ; Tue, 3 Dec 2019 16:19:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E552C2080A 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 C2EE36E83F; Tue, 3 Dec 2019 16:19:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id B76B16E83F for ; Tue, 3 Dec 2019 16:19:20 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id j42so4344722wrj.12 for ; Tue, 03 Dec 2019 08:19:20 -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=ak02DWSi16xtOh2ECFAWgXweAP5WExvaHVwWZOvyNnw=; b=dbHZz7SgehlCcyxyW3CzS+N9we4F3QbrIcLBfyIb0yrXVp7DYyDu9xK9+cF3LKPI6v 2BhrAHQIAFpyU9MnVj9mFSKqP0qvEQpqB/+O9RpvY5dqHr3T/ZQwRJKbGCH7X+jGeYJ6 uYIOR2n+lQeua8wjrkKsRvn5o2XZRmUS29pxG9mSheJ+c0jW/otDx+DeE7IoVys0N5gv JtBKXr05+c1/Mro+dO8l4y/XF5p6fkmwqfT9ey36yXLj8MFC/rzqDKHTZP+JAYDEJdYm 4t01aQjBIfUkQhlxATG7XurzeqLSOwJbIWHeRNZsTzhNKpKy8dfxKXVnbvHYv/JYufWV tHvg== X-Gm-Message-State: APjAAAXyjWbqvt/0LjIY196Nu6e4WqZ6iMweN2v+rlDNoDRbV5GNVJDT DvwnMIqEYtSUTo/bGk4pyUw= X-Google-Smtp-Source: APXvYqxX2J/L0HA0d2WUetE0tWp+6QJNxQ50KMEFOyZXtSl+Lp5vT6IUI4TcSqgDC50CFxE2aJTYvw== X-Received: by 2002:a05:6000:12c9:: with SMTP id l9mr6434660wrx.304.1575389959171; Tue, 03 Dec 2019 08:19:19 -0800 (PST) Received: from localhost (pD9E518ED.dip0.t-ipconnect.de. [217.229.24.237]) by smtp.gmail.com with ESMTPSA id h2sm4386670wrt.45.2019.12.03.08.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 08:19:18 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH v2 2/9] drm/tegra: gem: Properly pin imported buffers Date: Tue, 3 Dec 2019 17:19:07 +0100 Message-Id: <20191203161914.1312555-2-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=ak02DWSi16xtOh2ECFAWgXweAP5WExvaHVwWZOvyNnw=; b=RL3vCTki5+cR7UoU49Qhs4YMV6dygSXVkmjcJrGmlyiUJg7I40PArNtHDdaed3Idsp jqhgLSdkixx8XnwBSZnJBed9WhVY8qumrBkEf771dmfwvNKAlqBseA1KyW/3io7flDmX ylaS17NtXPPiCC45yXaVsWKHcYhofEuygZQ5BH1a+SN+ekT+ttVeQ9V159fDpN+Zw7Lx sHcJ/QPG4K/Lb6Tnkpm6EVre2n0cf96UTeXShV5FhWjBPZCahz5RfM9RgNjJXaIfJpWr 4t09araZKxkwBgt8EB6H4p1ADwfkSsSbtC6yvhDkM2IRriGGs5LBDDNkObPp2it7sCb1 Apyw== 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, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Thierry Reding Buffers that are imported from a DMA-BUF don't have pages allocated with them. At the same time an SG table for them can't be derived using the DMA API helpers because the necessary information doesn't exist. However there's already an SG table that was created during import, so this can simply be duplicated. Signed-off-by: Thierry Reding --- Note that for proper DMA-BUF usage, the display controllers should each attach to the DMA-BUF for imported buffers. That's a fairly large change and will be sent out as a follow-up, targetting v5.6. This patch is a fix for a recent regression in v5.5-rc1. drivers/gpu/drm/tegra/gem.c | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c index 746dae32c484..6dfad56eee2b 100644 --- a/drivers/gpu/drm/tegra/gem.c +++ b/drivers/gpu/drm/tegra/gem.c @@ -27,6 +27,29 @@ static void tegra_bo_put(struct host1x_bo *bo) drm_gem_object_put_unlocked(&obj->gem); } +/* XXX move this into lib/scatterlist.c? */ +static int sg_alloc_table_from_sg(struct sg_table *sgt, struct scatterlist *sg, + unsigned int nents, gfp_t gfp_mask) +{ + struct scatterlist *dst; + unsigned int i; + int err; + + err = sg_alloc_table(sgt, nents, gfp_mask); + if (err < 0) + return err; + + dst = sgt->sgl; + + for (i = 0; i < nents; i++) { + sg_set_page(dst, sg_page(sg), sg->length, 0); + dst = sg_next(dst); + sg = sg_next(sg); + } + + return 0; +} + static struct sg_table *tegra_bo_pin(struct device *dev, struct host1x_bo *bo, dma_addr_t *phys) { @@ -52,11 +75,31 @@ static struct sg_table *tegra_bo_pin(struct device *dev, struct host1x_bo *bo, return ERR_PTR(-ENOMEM); if (obj->pages) { + /* + * If the buffer object was allocated from the explicit IOMMU + * API code paths, construct an SG table from the pages. + */ err = sg_alloc_table_from_pages(sgt, obj->pages, obj->num_pages, 0, obj->gem.size, GFP_KERNEL); if (err < 0) goto free; + } else if (obj->sgt) { + /* + * If the buffer object already has an SG table but no pages + * were allocated for it, it means the buffer was imported and + * the SG table needs to be copied to avoid overwriting any + * other potential users of the original SG table. + */ + err = sg_alloc_table_from_sg(sgt, obj->sgt->sgl, obj->sgt->nents, + GFP_KERNEL); + if (err < 0) + goto free; } else { + /* + * If the buffer object had no pages allocated and if it was + * not imported, it had to be allocated with the DMA API, so + * the DMA API helper can be used. + */ err = dma_get_sgtable(dev, sgt, obj->vaddr, obj->iova, obj->gem.size); if (err < 0) 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 { From patchwork Tue Dec 3 16:19:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11271547 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 162EE1805 for ; Tue, 3 Dec 2019 16:19:28 +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 F30D420833 for ; Tue, 3 Dec 2019 16:19:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F30D420833 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 0C0796E843; Tue, 3 Dec 2019 16:19:27 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by gabe.freedesktop.org (Postfix) with ESMTPS id CEA026E844 for ; Tue, 3 Dec 2019 16:19:25 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id f129so4185949wmf.2 for ; Tue, 03 Dec 2019 08:19:25 -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=ukbAySjSNMI0S+s3PZZPFOl6pszLEQLlgBTJCxk93hE=; b=O1DIvOI+SfzeO0QTZ7svFdKGU3mJAUXxOiMIJ3Eg6iJABepsVj60Az0JSIqonwGcH2 czJVATijjt7aeb7JW6RbnCsG3N+gJ8aWDT4XMydDldvFeZgx/Y8jGZlFATy2Y6PJnAoZ 5C1/CwHcxiAWeWluE6wVZdmepHYY5JYdUN6v40RWC5q70TfvmC/+m57F1LRdJKWQlpnZ fee4BZ3vleSCSAIgYXqFjdWFL8JfdZMjuJVU3V8ZPjlfIS9wymLPF+uAfIHnEE+5+lKm beN9mC8hFS+QoPG4vdfC+/rX9WzoLhd2foF6shtQC5CCDrXWeb42XfWQJZEPx9+s6g+a zdyg== X-Gm-Message-State: APjAAAU57jzOjvO6PSJDam/kwFsAbmfmf6ZYIPyps9FpWG/m+bwe3bo5 EZsXMCHcoUO/3OoDZqBMJS2vC9vfwtU= X-Google-Smtp-Source: APXvYqzjma23PNGKsrRHGJ52wpi75A2EWA8HJoQhYk9dTPg/yLs/spOEQa0hVHdrIR9GSKVKKEQGJg== X-Received: by 2002:a1c:4b0d:: with SMTP id y13mr28421590wma.134.1575389964363; Tue, 03 Dec 2019 08:19:24 -0800 (PST) Received: from localhost (pD9E518ED.dip0.t-ipconnect.de. [217.229.24.237]) by smtp.gmail.com with ESMTPSA id d186sm3725722wmf.7.2019.12.03.08.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 08:19:23 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH v2 4/9] drm/tegra: Use proper IOVA address for cursor image Date: Tue, 3 Dec 2019 17:19:09 +0100 Message-Id: <20191203161914.1312555-4-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=ukbAySjSNMI0S+s3PZZPFOl6pszLEQLlgBTJCxk93hE=; b=p8AImqUvKPe7RcRTdaqBUPvOw2AwuTZBJifHfoT71eipePQVF3elFSVEDEDXXAxN8/ lDYaDj555Vo2HTypIdFGy+G6zgIKRTJ4SNPgqNIhbEhWqgIZ9cgh/i8AEWy2C1W0mQJ9 HRjmripn4yKt2iy9qUQ/67kL7m4Ia4TD6SndkgnxupanzaXqDQKppe6c82C8Sl7OffJk 7jMKDcchpMUqcCY+etP2sS+R6ZFB+T7mMkgjXwTm9DmEA8J+UShOa3wMr3WmKvCaQIi4 gKP5dd4ORA6mdc3TuZAp0kgiQ+G73ZQpiXCAJg8I6i18wD+6lKtdcfviGLW0p3JJisW2 YGnA== 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 The IOVA address for the cursor is the result of mapping the buffer object for the given display controller. Make sure to use the proper IOVA address as stored in the cursor's plane state. Reviewed-by: Daniel Vetter Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/dc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c index d03b33c3b114..0a5f86b61fda 100644 --- a/drivers/gpu/drm/tegra/dc.c +++ b/drivers/gpu/drm/tegra/dc.c @@ -847,16 +847,15 @@ static int tegra_cursor_atomic_check(struct drm_plane *plane, static void tegra_cursor_atomic_update(struct drm_plane *plane, struct drm_plane_state *old_state) { - struct tegra_bo *bo = tegra_fb_get_plane(plane->state->fb, 0); + struct tegra_plane_state *state = to_tegra_plane_state(plane->state); struct tegra_dc *dc = to_tegra_dc(plane->state->crtc); - struct drm_plane_state *state = plane->state; u32 value = CURSOR_CLIP_DISPLAY; /* rien ne va plus */ if (!plane->state->crtc || !plane->state->fb) return; - switch (state->crtc_w) { + switch (plane->state->crtc_w) { case 32: value |= CURSOR_SIZE_32x32; break; @@ -874,16 +873,16 @@ static void tegra_cursor_atomic_update(struct drm_plane *plane, break; default: - WARN(1, "cursor size %ux%u not supported\n", state->crtc_w, - state->crtc_h); + WARN(1, "cursor size %ux%u not supported\n", + plane->state->crtc_w, plane->state->crtc_h); return; } - value |= (bo->iova >> 10) & 0x3fffff; + value |= (state->iova[0] >> 10) & 0x3fffff; tegra_dc_writel(dc, value, DC_DISP_CURSOR_START_ADDR); #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT - value = (bo->iova >> 32) & 0x3; + value = (state->iova[0] >> 32) & 0x3; tegra_dc_writel(dc, value, DC_DISP_CURSOR_START_ADDR_HI); #endif @@ -902,7 +901,8 @@ static void tegra_cursor_atomic_update(struct drm_plane *plane, tegra_dc_writel(dc, value, DC_DISP_BLEND_CURSOR_CONTROL); /* position the cursor */ - value = (state->crtc_y & 0x3fff) << 16 | (state->crtc_x & 0x3fff); + value = (plane->state->crtc_y & 0x3fff) << 16 | + (plane->state->crtc_x & 0x3fff); tegra_dc_writel(dc, value, DC_DISP_CURSOR_POSITION); } From patchwork Tue Dec 3 16:19:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11271549 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 31A05138C for ; Tue, 3 Dec 2019 16:19:31 +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 1AA8D2084F for ; Tue, 3 Dec 2019 16:19:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1AA8D2084F 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 60BA06E845; Tue, 3 Dec 2019 16:19:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0DD3C6E844 for ; Tue, 3 Dec 2019 16:19:28 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id j42so4345238wrj.12 for ; Tue, 03 Dec 2019 08:19:27 -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=pvQehkVTnZhXOtbF2Az2asg2sLoVMRuQyXqH7URMAHM=; b=iHp+nlc9kwcyK0LA6sKK/RF7Y4lXxqbN+lH+Q1UMbsDsF+lHrNlgrvZt8Qr665wfM3 EvUPsKgATyPN/44UOXE6IVjdfxC1EdnQDest1FiQRQz6/h/vwMNAc2WNElzZKr7Q0HK2 o0GFzFkiZAyuiTiDrC1y1hQ2+M7NDWr/gjH+LPu3YNoUX55tiHdPakFMSyvOgG/1RlFM 3zs5AcNgtVRNfyFXnqDzFALs3cD7YgSdcyXFW66zLO/HDfr/eslSfch/QWUewHy2DG5f ulj3cWljEzAh7j7ZNXNxt5xO7+93kvCKeAkIoda+cuQPBRBtEHtOUBLVQRUocXvrfNwF oeRw== X-Gm-Message-State: APjAAAWUngpEZVs+gqIE1s3Cdao/xpvHBkLgZizwEh1G8mT0LRrGq5RK UkuQgSD8sslvBb0CKPyqUwFSSOp8Tbc= X-Google-Smtp-Source: APXvYqy+DcGAlAhe1ldzMVwN7qNiMU9+r376sbkbfD9Fshi4/avfLvvX5mcOke2PpX86Q3t2S3JqHg== X-Received: by 2002:adf:814c:: with SMTP id 70mr5814983wrm.157.1575389966593; Tue, 03 Dec 2019 08:19:26 -0800 (PST) Received: from localhost (pD9E518ED.dip0.t-ipconnect.de. [217.229.24.237]) by smtp.gmail.com with ESMTPSA id k13sm2901194wrx.59.2019.12.03.08.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 08:19:25 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH v2 5/9] drm/tegra: sor: Implement system suspend/resume Date: Tue, 3 Dec 2019 17:19:10 +0100 Message-Id: <20191203161914.1312555-5-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=pvQehkVTnZhXOtbF2Az2asg2sLoVMRuQyXqH7URMAHM=; b=Mrhr+/Wn9ZoXUAeQh0b/8qtNuL4ue3b/8nabr8jiNHIXLbo3hN56imCCyjJOfDdzab IdiNTZEbydnQGfTNkmNJiRIyzZTxNiHICvxxdFq1i150uGN6O3ykVwVIBfEyneDxUQJ3 WIiTKS1oVmcY2dms0mmP9oeDNk32JgdtgjkE0ia75P/RpIalqMjUHzPuBmtNyNRRWP4a 2ZF4p0+bMrSbzS2hM0jJxe35/kpTM8NEnnvj69tsr4BzpmDHNYPFE/YG5MV7WeEhb4Fk EGwc7Hx0XPciwFIYbT+cMt9uAhXkEKLDBJglbKNQa5HFD11oKRJ0pgpCbCLl1UxzxXOM cSpw== 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 Upon system suspend, make sure the +5V HDMI regulator is disabled. This avoids potentially leaking current to the HDMI connector. This also makes sure that upon resume the regulator is enabled again, which in some cases is necessary to properly restore the state of the supply on resume. Reviewed-by: Daniel Vetter Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/sor.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c index 615cb319fa8b..2200f4cd397a 100644 --- a/drivers/gpu/drm/tegra/sor.c +++ b/drivers/gpu/drm/tegra/sor.c @@ -3912,8 +3912,7 @@ static int tegra_sor_remove(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM -static int tegra_sor_suspend(struct device *dev) +static int tegra_sor_runtime_suspend(struct device *dev) { struct tegra_sor *sor = dev_get_drvdata(dev); int err; @@ -3935,7 +3934,7 @@ static int tegra_sor_suspend(struct device *dev) return 0; } -static int tegra_sor_resume(struct device *dev) +static int tegra_sor_runtime_resume(struct device *dev) { struct tegra_sor *sor = dev_get_drvdata(dev); int err; @@ -3967,10 +3966,25 @@ static int tegra_sor_resume(struct device *dev) return 0; } -#endif + +static int tegra_sor_suspend(struct device *dev) +{ + struct tegra_sor *sor = dev_get_drvdata(dev); + + return regulator_disable(sor->hdmi_supply); +} + +static int tegra_sor_resume(struct device *dev) +{ + struct tegra_sor *sor = dev_get_drvdata(dev); + + return regulator_enable(sor->hdmi_supply); +} static const struct dev_pm_ops tegra_sor_pm_ops = { - SET_RUNTIME_PM_OPS(tegra_sor_suspend, tegra_sor_resume, NULL) + SET_RUNTIME_PM_OPS(tegra_sor_runtime_suspend, tegra_sor_runtime_resume, + NULL) + SET_SYSTEM_SLEEP_PM_OPS(tegra_sor_suspend, tegra_sor_resume) }; struct platform_driver tegra_sor_driver = { From patchwork Tue Dec 3 16:19:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11271551 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 7116E138D for ; Tue, 3 Dec 2019 16:19:33 +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 5A19920833 for ; Tue, 3 Dec 2019 16:19:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5A19920833 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 292FF6E847; Tue, 3 Dec 2019 16:19:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0A8786E844 for ; Tue, 3 Dec 2019 16:19:30 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id y17so4407337wrh.5 for ; Tue, 03 Dec 2019 08:19:29 -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=qux6awnp95L6xNm3T6+oYkp3AFsi3QUxGHXoIt7wf6k=; b=QTRd8T2abcROz65BYuoFDUtt+sMx+yCWOYrhMk31w1H8KF5uU1ija8YoJxS6tkDyRY XsLVhSWX+1Em4PZqPP54Ksa00+Tv/bvumjGqsmQSlSfUD6T164O/VS1YaXzClugthF36 7/rh9zECUkKW7hz5u7rQaxIeXoVXgFIH2QsVyfe8WpdiLAAqV/5XPy48KExgI9aY/iZg HxM3GoJBkBtu4i9feNqiy9qhtcPQCWR47er2pLHiixS59Mq7AiQLSntUcnCSSFfps5O5 LYndhGAs5C14R4kJ3JzAAFYnqap6Vfycf9c8/K/Ym0yTFn6wxGThaJNMyCFqR+3WLGHZ BVvQ== X-Gm-Message-State: APjAAAUaH+OmQeysMaWW3H/1J6AGMURtM360nPdEICWNLb73l+wXdwwH WkIOLzc3qfF+OwTWN5GhBHOHER7vBPw= X-Google-Smtp-Source: APXvYqwaplyrvpWZla0pN+4IoaFpU0BdHYNiurx7esWjyDLcNYfr98Ii/Vaq3gdyCmy8OwMNXYlJAA== X-Received: by 2002:adf:d848:: with SMTP id k8mr5905794wrl.328.1575389968528; Tue, 03 Dec 2019 08:19:28 -0800 (PST) Received: from localhost (pD9E518ED.dip0.t-ipconnect.de. [217.229.24.237]) by smtp.gmail.com with ESMTPSA id l7sm4141691wrq.61.2019.12.03.08.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 08:19:27 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH v2 6/9] drm/tegra: vic: Export module device table Date: Tue, 3 Dec 2019 17:19:11 +0100 Message-Id: <20191203161914.1312555-6-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=qux6awnp95L6xNm3T6+oYkp3AFsi3QUxGHXoIt7wf6k=; b=UqCeb9VgVsi5yo+3k3wpc86dDAXTjZtAMQHpnCQwMLRJRXbjR/WSS4//0jL9gWcZaI i80WwGIoVyhi+MG1ezE5sWd9+NiUgjqlhT8OUOTh8HGdHTe7r+4b6pK185xGAqcae9nA 5+bD13qEOOJlkB5OKOnD++hQPX6poKgLFef1xobqD2y3vKpfj9mW/pdDxy1bbq08CbeP IsepQaNIAOl5M4I1GuQhNiOKPQiI1Zzk969+JbcRTObhGM2KJV5PtRdoeBoWk5OIz1dc zI3bFc/YBkF5DKOc8NWsPmecYbJcRRo47HmMqhEQQ5MjIrnLyAKE9bgsXKDrI1lNONQH PQeg== 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 Export the module device table to ensure the VIC compatible strings are listed in the module's aliases table. This in turn causes the driver to be automatically loaded on boot if VIC is the only enabled subdevice of the logical host1x DRM device. Reviewed-by: Daniel Vetter Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/vic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tegra/vic.c b/drivers/gpu/drm/tegra/vic.c index 9444ba183990..c4d82b8b3065 100644 --- a/drivers/gpu/drm/tegra/vic.c +++ b/drivers/gpu/drm/tegra/vic.c @@ -386,13 +386,14 @@ static const struct vic_config vic_t194_config = { .supports_sid = true, }; -static const struct of_device_id vic_match[] = { +static const struct of_device_id tegra_vic_of_match[] = { { .compatible = "nvidia,tegra124-vic", .data = &vic_t124_config }, { .compatible = "nvidia,tegra210-vic", .data = &vic_t210_config }, { .compatible = "nvidia,tegra186-vic", .data = &vic_t186_config }, { .compatible = "nvidia,tegra194-vic", .data = &vic_t194_config }, { }, }; +MODULE_DEVICE_TABLE(of, tegra_vic_of_match); static int vic_probe(struct platform_device *pdev) { @@ -516,7 +517,7 @@ static const struct dev_pm_ops vic_pm_ops = { struct platform_driver tegra_vic_driver = { .driver = { .name = "tegra-vic", - .of_match_table = vic_match, + .of_match_table = tegra_vic_of_match, .pm = &vic_pm_ops }, .probe = vic_probe, From patchwork Tue Dec 3 16:19:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11271553 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 9BCF8930 for ; Tue, 3 Dec 2019 16:19:35 +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 84FDE20833 for ; Tue, 3 Dec 2019 16:19:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 84FDE20833 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 5415E6E848; Tue, 3 Dec 2019 16:19:34 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1E1AE6E846 for ; Tue, 3 Dec 2019 16:19:32 +0000 (UTC) Received: by mail-wm1-x32a.google.com with SMTP id s14so4165047wmh.4 for ; Tue, 03 Dec 2019 08:19:31 -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=pyzOe2qMdvVwhl1mEyFjGx3TYlIMn6F7cP5QiE14+H4=; b=lbZk/yVE0c1B3qpBZj6GgbF3XcnW/mo3WufgTPxM3V7i174i2bTyPFpjt7lwnqhonc ixx1kc9Ywi7bUS0k7kRujb4kKdBPobgaIl1gJXKPKOvuDBhg1w7duc+29sENGT44POLp zGVomU9fTR5t0yCwxBE0iryVWxL4w60xhnrUyUx1yFn8WNxR2Snr5nGKcD6bAK4dxS3Q zRZDduJ+WJ4DPtppwUsIW8A6FjGJnGVFwMR7lqs+MjZB62PkpeiclmLUfol/yNZlkeUV j5VIu7iP2MeUjZ3UsWJXdi8LEb8uHIOyr1PfwcrTPPeW0aYJrnTU55RAsZ2acfm+8Ppv fR4w== X-Gm-Message-State: APjAAAX1QOjBO7qDuhIBzsRMRzJSYif+SlZILs0R+qa6IB5WFmn/cZwl wruYkXwILP1CASX4dCeYEKM= X-Google-Smtp-Source: APXvYqwT/wJuzWWV2RPfPnQ7sxDm7cPpS+KNP3aqUMF36DKBCbFhDzv97wNKTeSIru/mQVG2PMmFrw== X-Received: by 2002:a05:600c:24d1:: with SMTP id 17mr25491563wmu.151.1575389970584; Tue, 03 Dec 2019 08:19:30 -0800 (PST) Received: from localhost (pD9E518ED.dip0.t-ipconnect.de. [217.229.24.237]) by smtp.gmail.com with ESMTPSA id x18sm4081958wrr.75.2019.12.03.08.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 08:19:29 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH v2 7/9] drm/tegra: Silence expected errors on IOMMU attach Date: Tue, 3 Dec 2019 17:19:12 +0100 Message-Id: <20191203161914.1312555-7-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=pyzOe2qMdvVwhl1mEyFjGx3TYlIMn6F7cP5QiE14+H4=; b=qValVkF8/qyIg3bVfigaMdP6d1f9SDnhBW4ha4pbI66ZuSwMV0obJpRDLk2/GxQEyY 2DduUn4hNVmBCC7I/hq1TRg/7u7mZFbldSHl68BQYaqgzYpTsCDwFiHOKjs+qytDW5P0 SpwSOQJ3ejVxwVlzENpY3it2ox6AC4z+HhThEO5mSMlXNLD/hCwhPcolWmkOohQpLWJW BTZpMKbfTz8HxSEPNuqalfNVU0ppveFHwVcX4LvxFBu7OCIFsZyVprYJAv1gE/S75urs kxc1+uLaOk5ifq8HqdnzVuZkstGUVPGGZ0p9EdeXJFdS7SCUXmvRqUFiKSOqHO62Gfu2 /4qA== 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 Subdevices may not be hooked up to an IOMMU via device tree. Detect such situations and avoid confusing users by not emitting an error message. Reviewed-by: Daniel Vetter Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/dc.c | 2 +- drivers/gpu/drm/tegra/drm.c | 4 +--- drivers/gpu/drm/tegra/vic.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c index 0a5f86b61fda..2b9a25c977c0 100644 --- a/drivers/gpu/drm/tegra/dc.c +++ b/drivers/gpu/drm/tegra/dc.c @@ -2027,7 +2027,7 @@ static int tegra_dc_init(struct host1x_client *client) dev_warn(dc->dev, "failed to allocate syncpoint\n"); err = host1x_client_iommu_attach(client); - if (err < 0) { + if (err < 0 && err != -ENODEV) { dev_err(client->dev, "failed to attach to domain: %d\n", err); return err; } diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 56e5e7a5c108..7a16b51eaa2d 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -920,10 +920,8 @@ int host1x_client_iommu_attach(struct host1x_client *client) if (tegra->domain) { group = iommu_group_get(client->dev); - if (!group) { - dev_err(client->dev, "failed to get IOMMU group\n"); + if (!group) return -ENODEV; - } if (domain != tegra->domain) { err = iommu_attach_group(tegra->domain, group); diff --git a/drivers/gpu/drm/tegra/vic.c b/drivers/gpu/drm/tegra/vic.c index c4d82b8b3065..3526c2892ddb 100644 --- a/drivers/gpu/drm/tegra/vic.c +++ b/drivers/gpu/drm/tegra/vic.c @@ -167,7 +167,7 @@ static int vic_init(struct host1x_client *client) int err; err = host1x_client_iommu_attach(client); - if (err < 0) { + if (err < 0 && err != -ENODEV) { dev_err(vic->dev, "failed to attach to domain: %d\n", err); return err; } From patchwork Tue Dec 3 16:19:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11271555 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 CC892138D for ; Tue, 3 Dec 2019 16:19:37 +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 B571920848 for ; Tue, 3 Dec 2019 16:19:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B571920848 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 741106E849; Tue, 3 Dec 2019 16:19:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4B0946E846 for ; Tue, 3 Dec 2019 16:19:34 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id b18so4383483wrj.8 for ; Tue, 03 Dec 2019 08:19:34 -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=9ZUbS0TeYBzQ9xk9jMtykFneTa+bnz9xud3h/IgQhWg=; b=l5mpN46KKeBqpFhHlsExhRBkDieygfkdWSEBkdo50FEM7snWixl73xxcfxWvx4x2EX 8E5tiPYJGkkLlpAXl6rgEsdwJQAdhsCRi4AHaKV9vqiCYMdBq+lmnBj1PUuimvQcQkoJ iUjYc//HdsnUo+XW2LNAkfA4C87Q8z50U2MKNNy7dBtL7sUGRA1mIPu1z89Kv8R0GXue AkOjBzDvJoEuM26WrkFuRD1eZE0o1qcX0RoxBjkbF7UoQIuf5QQsbnAjPICneKwN63uo RA8q6IekURfr2akPh/Vs8hnfhcF6sWouKsuVteyRNWDMpxMsGyC34BJxxas7yZfuWdc4 xIGg== X-Gm-Message-State: APjAAAUxxbEoBse1pLo0+sOCNSuNwldWcFbiJOxl0AdnwbO7QM8xdPAc 8pjFWjoq7DHouKX4dsxU1ek= X-Google-Smtp-Source: APXvYqzWo0gREb/Y/VCXKo/0ClOxouv66LLO/irvpmA8yTiFb7RYnplsoFlnrS0PpVvJEFD65Slbsg== X-Received: by 2002:a5d:630c:: with SMTP id i12mr5980329wru.350.1575389972842; Tue, 03 Dec 2019 08:19:32 -0800 (PST) Received: from localhost (pD9E518ED.dip0.t-ipconnect.de. [217.229.24.237]) by smtp.gmail.com with ESMTPSA id b67sm3523453wmc.38.2019.12.03.08.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 08:19:32 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH v2 8/9] drm/tegra: sor: Make the +5V HDMI supply optional Date: Tue, 3 Dec 2019 17:19:13 +0100 Message-Id: <20191203161914.1312555-8-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=9ZUbS0TeYBzQ9xk9jMtykFneTa+bnz9xud3h/IgQhWg=; b=eN5IzUQCemF0bgf3FTV4edwXbi6ykbiMEJouleU81zoKuGgtGnVQLIKdjE6tEhRorq rInLv03umG3yQQHl1hiEEn0XyXvu6qwyF9IhnG8Js7Dj+dOTxir8buiq+YjlmBtrOZ1T uWXnRYPjvJYmAV9/UPpB3/P4ehCmkfhOVUbV1JK18P7ACMMH2HtYpxBT8uCpdccOiFdc 5wd5HHR6BnP9yGXBfADW9dBbzzL5ctgWGcPsGKu8odsuuMk49/Ok3EXsQUdMzo1Ml55X me5sY71lOEJiGjgQ0dU91sIXl743A/0sfOoHYRv+FPYrbXXf11Kue3L/ehZRy6ccyC36 9oMw== 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 The SOR supports multiple display modes, but only when driving an HDMI monitor does it make sense to control the +5V power supply. eDP and DP don't need this, so make it optional. This fixes a crash observed during system suspend/resume. Reviewed-by: Daniel Vetter Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/sor.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c index 2200f4cd397a..a68d3b36b972 100644 --- a/drivers/gpu/drm/tegra/sor.c +++ b/drivers/gpu/drm/tegra/sor.c @@ -3970,15 +3970,29 @@ static int tegra_sor_runtime_resume(struct device *dev) static int tegra_sor_suspend(struct device *dev) { struct tegra_sor *sor = dev_get_drvdata(dev); + int err; + + if (sor->hdmi_supply) { + err = regulator_disable(sor->hdmi_supply); + if (err < 0) + return err; + } - return regulator_disable(sor->hdmi_supply); + return 0; } static int tegra_sor_resume(struct device *dev) { struct tegra_sor *sor = dev_get_drvdata(dev); + int err; + + if (sor->hdmi_supply) { + err = regulator_enable(sor->hdmi_supply); + if (err < 0) + return err; + } - return regulator_enable(sor->hdmi_supply); + return 0; } static const struct dev_pm_ops tegra_sor_pm_ops = { From patchwork Tue Dec 3 16:19:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11271557 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 D4E5F1805 for ; Tue, 3 Dec 2019 16:19:39 +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 BDD2D2080A for ; Tue, 3 Dec 2019 16:19:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BDD2D2080A 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 DA2DE6E84A; Tue, 3 Dec 2019 16:19:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4E75F6E846 for ; Tue, 3 Dec 2019 16:19:36 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id t14so4155824wmi.5 for ; Tue, 03 Dec 2019 08:19:36 -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=8PwWQma+5Pqkctg0DzIuMrwRQe9FFZs9mcoeMD+RaeE=; b=QZ31CevArO+xRaMUNJ7ZNAed7yknB9faIw2Oafh5HEDPGuKAlvr5qm408OZjkI5AcD TMsXmZSlm3f5unZFYfiXpPQEafJO9F93sX3vWM/33pBLIGub8z+cjude/oWj4a8XKPrI nHh4wlOTf+xt4TffHFClwNqD7Ni7lj9E6jNTzJ8uARv0mkzSubvHu7mXYt67NGr+Pou1 yUE+A7GccpXDBrzHsNmW5e7f33gOPEz1YZgGu3QqUHPQi/q24TZGuCx5lwhdgJBknCzo jit3Poh+x5+yNbHzu1XYBQsMRsUx/JPHUW1SQAG+SLNzO98GHy4MxVF25DlDFhRkGy8m t2RQ== X-Gm-Message-State: APjAAAWHZn23F+SqHXyTlh+mn4OUOXCKePxDqzhu/kL8CAbeKr1La1s7 7AIyE4sJL/Fb9ZnH09jVoUk= X-Google-Smtp-Source: APXvYqxOisZqSvaS/kGDwfMGxj2Ecv3XXSg0r7See1EWGq29HYu3V+oJdlDy2Gj75UilxKxpChqpdQ== X-Received: by 2002:a1c:6207:: with SMTP id w7mr28616534wmb.16.1575389974756; Tue, 03 Dec 2019 08:19:34 -0800 (PST) Received: from localhost (pD9E518ED.dip0.t-ipconnect.de. [217.229.24.237]) by smtp.gmail.com with ESMTPSA id x11sm4401057wre.68.2019.12.03.08.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 08:19:34 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH v2 9/9] drm/tegra: Run hub cleanup on ->remove() Date: Tue, 3 Dec 2019 17:19:14 +0100 Message-Id: <20191203161914.1312555-9-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=8PwWQma+5Pqkctg0DzIuMrwRQe9FFZs9mcoeMD+RaeE=; b=nJrGvRP1wJU1oSWsRp5EnoobaFJ9zhQsNutzeCuPChjvEsRJdyhqa6k27WUpU7Ngeq oipxqLhPj2//BPhuh2AJWL+zxS9rIQ2e34yD4gvHjS47boCH3c1Kr7xAfp/dYM35Ig9l lPCFFSXnzoZz7TtHoGpiHixngXtc7171HVpuOLaZ28CwzMFitI1Ckxwz+QLipCnaHR0y qOwtofLBcgmENMSFPYqgRpARIGsPzG+wrpjvkk3SZNQFyc4o1cWs8SGbUQhYMdJITL+1 KgJ6cXYgVTtwbgTIgeyT871H2iP+ECFMdkm7AMHE4tHOmnUC5gk6oPB99Ae8h8pRbR/e mtrg== 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, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Thierry Reding The call to tegra_display_hub_cleanup() that takes care of disabling the window groups is missing from the driver's ->remove() callback. Call it to make sure the runtime PM reference counts for the display controllers are balanced. Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/drm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 7a16b51eaa2d..f455ce71e85d 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -1241,6 +1241,9 @@ static int host1x_drm_remove(struct host1x_device *dev) drm_atomic_helper_shutdown(drm); drm_mode_config_cleanup(drm); + if (tegra->hub) + tegra_display_hub_cleanup(tegra->hub); + err = host1x_device_exit(dev); if (err < 0) dev_err(&dev->dev, "host1x device cleanup failed: %d\n", err);