From patchwork Fri Aug 31 08:26:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 145599 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp504537ljw; Fri, 31 Aug 2018 01:26:24 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYZobS7eXEBxHy475t6oEyciI77YS/Ssv66gtLxOqEJFNI50pjLWfA0cVUlLsWomQnYPaZK X-Received: by 2002:a17:902:d706:: with SMTP id w6-v6mr14399325ply.158.1535703983961; Fri, 31 Aug 2018 01:26:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535703983; cv=none; d=google.com; s=arc-20160816; b=hGL96qPyqM5ZKqDlZHwHYWGGg1S8yQj1SAgPNKGA36F9i6GgcXAnt0X7H0v3UC2oNz mt7VPHz4OucYZaZxYpmylFDIfMnjz+VXmAEBHIpDgxGB3zOYzTbPfoZes4sFzazo0qNW 1nkRvE2+8awQbtbWJ+ELGeJbrVENeCJLeu2O3fLKkSeyrFwHUUse+EhZ1lXRxBM+K/0Z t3uLdQDqpS2BbuV09MlELQcI97c/+Wv6pTo3qgHZzaAoeE7mvq/pmzYeSM1jejY4vjqR ePTBkeQ/zxZdIKhdW6B7YH27tGweMnXJToK9IpYZXrSRyUTm2P+k7DwvQYw6zqpRaTRj R8Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:message-id:date:subject:to:from:delivered-to :arc-authentication-results; bh=/acstdwJ3TlAUKUJeRs/5L4XqwoZ4kQL3MNgQXI3vLA=; b=A8rOC+KCOsjH0X6J9txrD4DrraA8zkqCgoWWJfjypmO6zaalVcZJQ0mFauCenrj6+o AI3vHPzOSv0lX/tqvagQNRvsi368GCYEx6xVfahkKmxs8kT63BPKMWnyNJI/f0EKzKU6 6JXW24Q9i2O75kclMVycyKj2b/1XIfNJJhK/vBJYm9egI/m9URuqs1nXNyW4q8pDnLeb q0w09J3TAzmSA9641sZaeHfQjrucGKJ50Gf/jZjwUQLsFwHmr/Piwko2ZOU/FmZBm8n3 SJFxVQl9r+fXSX2g1a9eZjHyyyNTpef42as8FZ1+6YrB6oPyN5g4+HTKgi6/BJxlfRDo NCHQ== 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=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id y67-v6si9019016pfa.47.2018.08.31.01.26.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 31 Aug 2018 01:26:23 -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=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EA8D76E844; Fri, 31 Aug 2018 08:26:22 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id B35376E845 for ; Fri, 31 Aug 2018 08:26:21 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id p6-v6so9434073ljc.5 for ; Fri, 31 Aug 2018 01:26:21 -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; bh=84oJzrs2kQfRhNmsJ38bSw1z0BvMAvQZRgTLnz2b3X8=; b=iXAY7LLq6QLUU6PIb5g5RyigmVAB9+OsgZpSQ5YWwENg2By41jDo4AswlCoN9UwKGC dQtR4swVuaI4jU670+AQI1DvJL0QomFf3KXm6hLYuGyv+GztmWfnJwN1VJxZjN8W5kfL tMxRY3CATfUJQBKrgmUC3UZ49Mk+J5bwWsdcFyuJYqlGQHYiS7NlpByvEWyt/uLW2ZqV BF+2gb54KZZjudS9NaSm3ixrmqsIuyddvpImHei+ELq38SU801EmUdVT2cR5Z+DLz1te 9XoeHV8H+ST4DHKEte/OvBxzGNOUGSmquGLjOBcVs10hwOOWJY7LrELMInO7mGjpfmAU 7wcQ== X-Gm-Message-State: APzg51BGnnMglmpZi/LERfM/WYKPsFr4mjgBx1irRE96sAB/V5l4cL8b 3TbDeDLgsRJNJqrD69bwnuyO3A== X-Received: by 2002:a2e:9448:: with SMTP id o8-v6mr9386541ljh.34.1535703980120; Fri, 31 Aug 2018 01:26:20 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id y23-v6sm1666207ljk.28.2018.08.31.01.26.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 31 Aug 2018 01:26:19 -0700 (PDT) From: Linus Walleij To: Christoph Hellwig , Marek Szyprowski , Robin Murphy , Russell King Subject: [PATCH v2] of/platform: initialise AMBA default DMA masks Date: Fri, 31 Aug 2018 10:26:14 +0200 Message-Id: <20180831082614.27455-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.1 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: iommu@lists.linux-foundation.org, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This addresses a v4.19-rc1 regression in the PL111 DRM driver in drivers/gpu/pl111/* The driver uses the CMA KMS helpers and will thus at some point call down to dma_alloc_attrs() to allocate a chunk of contigous DMA memory for the framebuffer. It appears that in v4.18, it was OK that this (and other DMA mastering AMBA devices) left dev->coherent_dma_mask blank (zero). In v4.19-rc1 the WARN_ON_ONCE(dev && !dev->coherent_dma_mask) in dma_alloc_attrs() in include/linux/dma-mapping.h is triggered. The allocation later fails when get_coherent_dma_mask() is called from __dma_alloc() and __dma_alloc() returns NULL: drm-clcd-pl111 dev:20: coherent DMA mask is unset drm-clcd-pl111 dev:20: [drm:drm_fb_helper_fbdev_setup] *ERROR* Failed to set fbdev configuration I have not been able to properly bisect down to the actual committ causing it beacuse the kernel simply fails to build at to many bisection points, pushing the bisect back to places like the merge of entire subsystem trees, where things have likely been resolved while merging them. I found that Robin Murphy solved a similar problem in a5516219b102 ("of/platform: Initialise default DMA masks") by simply assigning dev.coherent_dma_mask and the dev.dma_mask to point to the same when creating devices from the device tree, and introducing the same code into the code path creating AMBA/PrimeCell devices solved my problem, graphics now come up. The code simply assumes that the device can access all of the system memory by setting the coherent DMA mask to 0xffffffff when creating a device from the device tree, which is crude, but seems to be what kernel v4.18 assumed. Cc: Russell King Cc: Christoph Hellwig Cc: Robin Murphy Signed-off-by: Linus Walleij --- Russell, Christoph: this is probably not the last patch. But it has a more accurate description of the problem. I still do not know what change to the kernel made it start triggering this, whether in the DMA API or in DRM :( I am looking into Russell's suggestion to use the DMA ranges, and thusly patch all device trees with DMA mastering devices adding DMA ranges to them and parsing that in the device tree AMBA/PrimeCell population code. Possibly that is the right path forward. --- drivers/of/platform.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 7ba90c290a42..6c59673933e9 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -241,6 +241,10 @@ static struct amba_device *of_amba_device_create(struct device_node *node, if (!dev) goto err_clear_flag; + /* AMBA devices only support a single DMA mask */ + dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); + dev->dev.dma_mask = &dev->dev.coherent_dma_mask; + /* setup generic device info */ dev->dev.of_node = of_node_get(node); dev->dev.fwnode = &node->fwnode;