From patchwork Tue Nov 6 21:32:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10671457 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 882E713AD for ; Tue, 6 Nov 2018 21:32:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 799FD2AFF5 for ; Tue, 6 Nov 2018 21:32:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DC742AFFC; Tue, 6 Nov 2018 21:32:44 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7B5B2AFF5 for ; Tue, 6 Nov 2018 21:32:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725951AbeKGG74 (ORCPT ); Wed, 7 Nov 2018 01:59:56 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:41502 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726069AbeKGG74 (ORCPT ); Wed, 7 Nov 2018 01:59:56 -0500 Received: by mail-qt1-f196.google.com with SMTP id d18so4417712qto.8 for ; Tue, 06 Nov 2018 13:32:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=heK/0pobd64fxFpvUWidhnPq+hXQWYWpecWeoc739Ls=; b=Di6KMFmh5429xD9dlHRO1vs7klTOzl0K7QdenVP+HT3FYW9FYJUq2MS0PLX97gkoOV ort9n6i/XVsu0utULwwDLmhtxk7VEsUs5YnV4zOf8d0OYFmaB9ZPtP9LUbgehjHgtDJr sDWRg5HTd+uu6u8nfLWnLHGg9BU1fCZ8luXRT8efAXL+Rv/TucAfoGm2FxESpy9gRR4l i4Y43qSfxvbURH5yUp1hTYe7Az4liA5bq/SQLKAKAC0PxIVGiaUoTMFZ++k4WNx6LQ+y LFqPvKHw5jObkkl5FM3FNx23oA7LI+Q2lfkKs7pEFjiTEbJQkF2TOyCatLQMwcPY0/oO HmsA== 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:mime-version :content-transfer-encoding; bh=heK/0pobd64fxFpvUWidhnPq+hXQWYWpecWeoc739Ls=; b=B2FdMCYBKK3fRpx97NhVsoMdaYEKF87sEzJdYCN7eEdLwl/gv+gyDNiF9N1YJETDnZ HMX+eHAIvNpeo3Slkdn1YfT8yZnE3yh+zgvHLnKijOyDdZHxZyUdt1wkNUvdQM1rYdN2 ZN1vET27V8eY2FEmpD3aRPlx+QdJJ3/+Y5E3x63VonI6DUn5dOX3D+O3qKgrbj2ygXY9 KsYsw8RBlgNlPQOeILYoVDqhr1lFp+ad4xg8Wk3WBP1cITUjlgn9QsOMlb4lJ6alqVC2 FfXS20d9tPYZ1NXdMb8R27fVbVl6U07UUI9WQJiHnwCumXw/8BQomw8lN0EOGzKfUNvR lnNw== X-Gm-Message-State: AGRZ1gLu1N8H2LhZJguEtVCU/AAjrVNOA2VsUfNi775Je5Dwi6WhEJCH lGFhdbWxFvEDtnXlv4tjPdVBtg== X-Google-Smtp-Source: AJdET5eLSHrvglbOL9zGINZX6cK/aTArEPgYCBGkSuCapCMC8pl76h4tGrFGaF86OB6uxttSmFhwag== X-Received: by 2002:aed:21d7:: with SMTP id m23-v6mr27630310qtc.121.1541539960886; Tue, 06 Nov 2018 13:32:40 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:ad55:b1db:adfe:3b9f]) by smtp.gmail.com with ESMTPSA id q62sm11153122qke.67.2018.11.06.13.32.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:32:40 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Cc: robdclark@gmail.com, Sean Paul , Stephen Boyd Subject: [PATCH] drm/msm: Set dma maximum segment size for mdss Date: Tue, 6 Nov 2018 16:32:32 -0500 Message-Id: <20181106213239.52133-1-sean@poorly.run> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Paul Turning on CONFIG_DMA_API_DEBUG_SG results in the following error: [ 12.078665] msm ae00000.mdss: DMA-API: mapping sg segment longer than device claims to support [len=3526656] [max=65536] [ 12.089870] WARNING: CPU: 6 PID: 334 at /mnt/host/source/src/third_party/kernel/v4.19/kernel/dma/debug.c:1301 debug_dma_map_sg+0x1dc/0x318 [ 12.102655] Modules linked in: joydev [ 12.106442] CPU: 6 PID: 334 Comm: frecon Not tainted 4.19.0 #2 [ 12.112450] Hardware name: Google Cheza (rev3+) (DT) [ 12.117566] pstate: 60400009 (nZCv daif +PAN -UAO) [ 12.122506] pc : debug_dma_map_sg+0x1dc/0x318 [ 12.126995] lr : debug_dma_map_sg+0x1dc/0x318 [ 12.131487] sp : ffffff800cc3ba80 [ 12.134913] x29: ffffff800cc3ba80 x28: 0000000000000000 [ 12.140395] x27: 0000000000000004 x26: 0000000000000004 [ 12.145868] x25: ffffff8008e55b18 x24: 0000000000000000 [ 12.151337] x23: 00000000ffffffff x22: ffffff800921c000 [ 12.156809] x21: ffffffc0fa75b080 x20: ffffffc0f7195090 [ 12.162280] x19: ffffffc0f1c53280 x18: 0000000000000000 [ 12.167749] x17: 0000000000000000 x16: 0000000000000000 [ 12.173218] x15: 0000000000000000 x14: 0720072007200720 [ 12.178689] x13: 0720072007200720 x12: 0720072007200720 [ 12.184161] x11: 0720072007200720 x10: 0720072007200720 [ 12.189641] x9 : ffffffc0f1fc6b60 x8 : 0000000000000000 [ 12.195110] x7 : ffffff8008132ce0 x6 : 0000000000000000 [ 12.200585] x5 : 0000000000000000 x4 : ffffff8008134734 [ 12.206058] x3 : ffffff800cc3b830 x2 : ffffffc0f1fc6240 [ 12.211532] x1 : 25045a74f48a7400 x0 : 25045a74f48a7400 [ 12.217006] Call trace: [ 12.219535] debug_dma_map_sg+0x1dc/0x318 [ 12.223671] get_pages+0x19c/0x20c [ 12.227177] msm_gem_fault+0x64/0xfc [ 12.230874] __do_fault+0x3c/0x140 [ 12.234383] __handle_mm_fault+0x70c/0xdb8 [ 12.238603] handle_mm_fault+0xac/0xc4 [ 12.242473] do_page_fault+0x1bc/0x3d4 [ 12.246342] do_translation_fault+0x54/0x88 [ 12.250652] do_mem_abort+0x60/0xf0 [ 12.254250] el0_da+0x20/0x24 [ 12.257317] irq event stamp: 67260 [ 12.260828] hardirqs last enabled at (67259): [] console_unlock+0x214/0x608 [ 12.269693] hardirqs last disabled at (67260): [] do_debug_exception+0x5c/0x178 [ 12.278820] softirqs last enabled at (67256): [] __do_softirq+0x4d4/0x520 [ 12.287510] softirqs last disabled at (67249): [] irq_exit+0xa8/0x100 [ 12.295742] ---[ end trace e63cfc40c313ffab ]--- The root of the problem is that the default segment size for sgt is (UINT_MAX & PAGE_MASK), and the default segment size for device dma is 64K. As such, if you compare the 2, you would deduce that the sg segment will overflow the device's capacity. In reality, the hardware can accommodate the larger sg segments, it's just not initializing its max segment properly. This patch initializes the max segment size for the mdss device, which gets rid of that pesky warning. Reported-by: Stephen Boyd Signed-off-by: Sean Paul Tested-by: Stephen Boyd --- drivers/gpu/drm/msm/msm_drv.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 9c9f7ff6960b..ea74542d08e4 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -492,6 +492,14 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) if (ret) goto err_msm_uninit; + if (!dev->dma_parms) { + dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms), + GFP_KERNEL); + if (!dev->dma_parms) + return -ENOMEM; + } + dma_set_max_seg_size(dev, DMA_BIT_MASK(32)); + msm_gem_shrinker_init(ddev); switch (get_mdp_ver(pdev)) {