From patchwork Fri Aug 31 14:13:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 145656 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp834868ljw; Fri, 31 Aug 2018 07:13:50 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYB5kaNtmU3et+Qo6ywmiJYclfRzakgyIMr/NUZT/x/FhX1lfCL1YsOU936csOdAZn6bjfr X-Received: by 2002:a17:902:654b:: with SMTP id d11-v6mr15594683pln.8.1535724830334; Fri, 31 Aug 2018 07:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535724830; cv=none; d=google.com; s=arc-20160816; b=bG/FsUc3BnPfeP00S0C4gAbpiNbmAKgrqnkKk2xw0drmDrwfLuuq0WLQRpKKD4kRq7 Vs9St63tQYHzQDDl4uB+J8HsbcW4peiM5NTAovGcdzRcCP2xdMY+MFrUyojXxLORrqum PBreMAAUVO1MP3QLFVU2Bimjcgunyq+5nlbYyXIMDC0yw1LoKgI1mA0kASYNyL+3BBQT 84ixEwxpUXQlKU1LlP3lACcusGDGzoGDnZyEH7/jkdAVANQ2tNl0gIZgM6NK8F3ctB7P aky9hDGGJ63cHQ1R1BKgVkfC/+WqYMc8JQJvxEzLMRTvESv6Tz9umeOMOC3Hko5C7mEG esQg== 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=20dd/yS5TnbVJ5vdY+TI0aazIS/AACzBTdLCMjmwf28=; b=C60Ab6t4X4kIboeneAy6d0O0OyuljMHovfIDDQcBjgUWJThG9HYgITJWI+8b4WZ7Ft uzJRxc4hrbQJYT5PzcyfJlzpsFD9A0fa14B6I8fXfbKSK5WUiLbMKF/eo+PfAsky4LpZ P/wwrAW7z3KSsnMWtP6QmyfETw6DLlmP3J8V9aHnMLLMYVUwZspOsJPB9YewWxByC3da x+rBUukPcpXbNsCdIRXSOIOZMRhzpEn0T3ChbgdJMMmR8jt707323jwc+1k10LlWC6RB 2N7ixqEUsrfn65OuW/d1UQnlERNsmR1CAQQQNF9p6b67uFoLPMi/6cBp/5awK56OYTao Ffcg== 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 d6-v6si9651062pgi.506.2018.08.31.07.13.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 31 Aug 2018 07:13:50 -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 44C346E106; Fri, 31 Aug 2018 14:13:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6407E6E106 for ; Fri, 31 Aug 2018 14:13:17 +0000 (UTC) Received: by mail-lf1-x144.google.com with SMTP id h64-v6so10075479lfi.10 for ; Fri, 31 Aug 2018 07:13:17 -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=MPcKXq+sJKw1DzSt4olA9dZSQBRDj+izZI+S4O7k/oQ=; b=Zvb99PSrk8Oiqwg1EBUdugTV/SjoKs6cTjFJTXT7Fot1NKBHDOL7KL6aDjUyWNH7Jz Obey6/BGRxOsF+vWpccOWwnHnE1oSG4XiE/LxXiHudtiax7NvLjEO3XwtH6GFfNWYVEt 81l71MRXWT0G9IJitf/1MA19BeSZJlW/KSIyssKn73pL/AnZPjXjoMgCFCdm2NOxa1Ap pS2kum/wKn2hXj/yANfq9mm2qRngS1WuzlWe5Gp8jbo8F39WX06+ELJEZ5D1CUnlaetw BGoCm77eA/8qVY0UeaNbwq+qDgecJsMcu1SEXB5Xs+iZy0f9sPj59ZpF9LkLwWCQITp9 nkDw== X-Gm-Message-State: APzg51B1Um4ymgOGHNDXWsAvr8cN2c7f5cRBG5nx64eLfZaVUpL4k8LK m2x19BU5njxDr6c2lbd98OGVAw== X-Received: by 2002:a19:d105:: with SMTP id i5-v6mr11078805lfg.31.1535724795687; Fri, 31 Aug 2018 07:13:15 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id b15-v6sm1902052lfg.18.2018.08.31.07.13.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 31 Aug 2018 07:13:14 -0700 (PDT) From: Linus Walleij To: Christoph Hellwig , Marek Szyprowski , Robin Murphy , Russell King Subject: [PATCH v3] of/platform: initialise AMBA default DMA masks Date: Fri, 31 Aug 2018 16:13:07 +0200 Message-Id: <20180831141307.9053-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 It turns out that in commit 4d8bde883bfb ("OF: Don't set default coherent DMA mask") the OF core stops setting the default DMA mask on new devices, especially those lines of the patch: - if (!dev->coherent_dma_mask) - dev->coherent_dma_mask = DMA_BIT_MASK(32); 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. The AMBA PrimeCells do not differ between coherent and streaming DMA so we can just assign the same to any DMA mask. Possibly drivers should augment their coherent DMA mask in accordance with "dma-ranges" from the device tree if more finegranular masking is needed. Reported-by: Russell King Fixes: 4d8bde883bfb ("OF: Don't set default coherent DMA mask") Cc: Russell King Cc: Christoph Hellwig Cc: Robin Murphy Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Provide proper root cause analysis, point to the right offending commit with Fixes: - Make even more elaborate description of what is causing this. ChangeLog v1->v2: - Provide a better description for the change. --- 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;