From patchwork Thu Apr 2 19:13:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 228247 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64075C2BA16 for ; Thu, 2 Apr 2020 19:13:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A84520737 for ; Thu, 2 Apr 2020 19:13:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jDq/750X" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731823AbgDBTND (ORCPT ); Thu, 2 Apr 2020 15:13:03 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:46032 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388499AbgDBTND (ORCPT ); Thu, 2 Apr 2020 15:13:03 -0400 Received: by mail-wr1-f67.google.com with SMTP id t7so5538438wrw.12 for ; Thu, 02 Apr 2020 12:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5S9qZQTMAjcrILXN8SNfaJ0AgqIsT1BdR29FTtqKpB8=; b=jDq/750X3O3gh3kIp0dHwRk3Fyi0deowUgdzPpNmcN6Q498mIkIGP/4ZiqRaIgpgW6 9WawTnBzrhh1bR+dvx3WDdIKQzi9mbDbTSpC9cuIqp9oMdz4JvKfeQXdiO6QGo3yzrpB 8B2CZ5QTAubcyNeiZP3N9c6hTQI5++MlbIh2FoTuxHuhyWubRLfBlTF4FcpqQq6k85uF upMoeg10p7qzloWhTc1YiVV9TvUsYVJEXzS0K5Ul9M2ax7Pw0zAhZkTW59ugdeJK+bSs SamRU4D9p0pywneLJVzLMr13HWN6LZJCWdSjSIJtlbjx8GqGRXbrQ2XmBeEw1L6PuGP9 9rzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5S9qZQTMAjcrILXN8SNfaJ0AgqIsT1BdR29FTtqKpB8=; b=kFHQwIv2gP/R6SLcb9Op8MY0q37jTQ46AhF4g8sDKdCG4AkgAJpO/sX1Vrw+wlf0EV WnmMV9ixVYcRsfjiAUKnn6Sp/Ih60E8rCPbWFpEIHfIFSvcDq9/5jTY4IMQDV5FTzOJo X8GITeKV2ANkX5JN5ccs6BUghnrFRR9xHdg7f0armUxM4PRnv5Tw7FbLw7IBi9hD6Rhs EWHjg92Qr3WjtRg09qOTaIf/1QFLGmSSBYh4zJEKP1wOKszKIeA69CzVzkOC7nGlcmSG nNoYQUAQeoq4Pr/TZ0c5ZRQam6dO48Pe+d53EvKit5XeAjn0UMEuBoHp5Lz4zIxb0RQF SV6g== X-Gm-Message-State: AGi0PuamhVy8JbgQb2CAXuzhSchmwrxSQDi22z+5Opt6iSwSVPChcpAU 7PtV4k2wTaQzAmkNOt++wlyfoy5SWzuToQ== X-Google-Smtp-Source: APiQypIaEV1vbLVlqbuW7Bh3LwoSnIJBYCFt9RPxBqvS7Bz5vs5DYE29Nvl1kpxLErViMlrvqcgPzw== X-Received: by 2002:adf:b258:: with SMTP id y24mr4896104wra.318.1585854781222; Thu, 02 Apr 2020 12:13:01 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.95]) by smtp.gmail.com with ESMTPSA id y12sm5511514wrn.55.2020.04.02.12.13.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 12:13:00 -0700 (PDT) From: Lee Jones To: stable@vger.kernel.org Subject: [PATCH 4.14 02/33] drm/msm: stop abusing dma_map/unmap for cache Date: Thu, 2 Apr 2020 20:13:22 +0100 Message-Id: <20200402191353.787836-2-lee.jones@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200402191353.787836-1-lee.jones@linaro.org> References: <20200402191353.787836-1-lee.jones@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Rob Clark [ Upstream commit 0036bc73ccbe7e600a3468bf8e8879b122252274 ] Recently splats like this started showing up: WARNING: CPU: 4 PID: 251 at drivers/iommu/dma-iommu.c:451 __iommu_dma_unmap+0xb8/0xc0 Modules linked in: ath10k_snoc ath10k_core fuse msm ath mac80211 uvcvideo cfg80211 videobuf2_vmalloc videobuf2_memops vide CPU: 4 PID: 251 Comm: kworker/u16:4 Tainted: G W 5.2.0-rc5-next-20190619+ #2317 Hardware name: LENOVO 81JL/LNVNB161216, BIOS 9UCN23WW(V1.06) 10/25/2018 Workqueue: msm msm_gem_free_work [msm] pstate: 80c00005 (Nzcv daif +PAN +UAO) pc : __iommu_dma_unmap+0xb8/0xc0 lr : __iommu_dma_unmap+0x54/0xc0 sp : ffff0000119abce0 x29: ffff0000119abce0 x28: 0000000000000000 x27: ffff8001f9946648 x26: ffff8001ec271068 x25: 0000000000000000 x24: ffff8001ea3580a8 x23: ffff8001f95ba010 x22: ffff80018e83ba88 x21: ffff8001e548f000 x20: fffffffffffff000 x19: 0000000000001000 x18: 00000000c00001fe x17: 0000000000000000 x16: 0000000000000000 x15: ffff000015b70068 x14: 0000000000000005 x13: 0003142cc1be1768 x12: 0000000000000001 x11: ffff8001f6de9100 x10: 0000000000000009 x9 : ffff000015b78000 x8 : 0000000000000000 x7 : 0000000000000001 x6 : fffffffffffff000 x5 : 0000000000000fff x4 : ffff00001065dbc8 x3 : 000000000000000d x2 : 0000000000001000 x1 : fffffffffffff000 x0 : 0000000000000000 Call trace: __iommu_dma_unmap+0xb8/0xc0 iommu_dma_unmap_sg+0x98/0xb8 put_pages+0x5c/0xf0 [msm] msm_gem_free_work+0x10c/0x150 [msm] process_one_work+0x1e0/0x330 worker_thread+0x40/0x438 kthread+0x12c/0x130 ret_from_fork+0x10/0x18 ---[ end trace afc0dc5ab81a06bf ]--- Not quite sure what triggered that, but we really shouldn't be abusing dma_{map,unmap}_sg() for cache maint. Cc: Stephen Boyd Tested-by: Stephen Boyd Reviewed-by: Jordan Crouse Signed-off-by: Rob Clark Signed-off-by: Sean Paul Link: https://patchwork.freedesktop.org/patch/msgid/20190630124735.27786-1-robdclark@gmail.com Signed-off-by: Lee Jones --- drivers/gpu/drm/msm/msm_gem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index f2df718af370d..3a91ccd92c473 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -108,7 +108,7 @@ static struct page **get_pages(struct drm_gem_object *obj) * because display controller, GPU, etc. are not coherent: */ if (msm_obj->flags & (MSM_BO_WC|MSM_BO_UNCACHED)) - dma_map_sg(dev->dev, msm_obj->sgt->sgl, + dma_sync_sg_for_device(dev->dev, msm_obj->sgt->sgl, msm_obj->sgt->nents, DMA_BIDIRECTIONAL); } @@ -138,7 +138,7 @@ static void put_pages(struct drm_gem_object *obj) * GPU, etc. are not coherent: */ if (msm_obj->flags & (MSM_BO_WC|MSM_BO_UNCACHED)) - dma_unmap_sg(obj->dev->dev, msm_obj->sgt->sgl, + dma_sync_sg_for_cpu(obj->dev->dev, msm_obj->sgt->sgl, msm_obj->sgt->nents, DMA_BIDIRECTIONAL);