From patchwork Wed Jun 14 23:59:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13280578 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 71A98EB64D8 for ; Thu, 15 Jun 2023 00:00:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=M6eP62iRspAmhuSZ+Q8TkSo4yo6iPcrjHIHMuCUoydw=; b=N10bbn6ACOHRxt D/w8usdGRSHAePO6W8bSFvuyhqd7AvMNbrcryDOun/9pcgRkj9UfH41rOIkSaXwGzBfRh0QcgJOBP E10ax/Zjjr9tvo8wNmrY+Ixseh2pbgSKJ9pDEsm8U7B3Qp2UqYsth63awW5Zsdp+W7Os67UE6qT59 BvrEy0p71c21lf5WY7edPvNd0fTT8r4Y+VcAE54Z77DqO/ieLF3poXWUWDkwZPW+FQGtV7B1VJfp0 skuq1IdpfJJk3g1SBt8EvAnFhNl/nUMxfAXOyz4Ha9eJ2gQ24RcrxCkavLf71FHJfJFRvlTLC9Paq cMVTh2hSuHKpRHgIro4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q9aPM-00D614-1q; Thu, 15 Jun 2023 00:00:12 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q9aPJ-00D602-0K for linux-arm-kernel@lists.infradead.org; Thu, 15 Jun 2023 00:00:10 +0000 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-666520247f8so1190554b3a.2 for ; Wed, 14 Jun 2023 17:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686787207; x=1689379207; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=12VwvcrgEKdN8aqMI+IAU5PLbg9wZ07LVlbgBSIhCA4=; b=SupkW8CAI0Bw7NvXheRZO8CdV4l6XkZ7DQMfPL8I5BHIGivTFzK6TWvOGUZkkOLiz3 dfpnYOLk53Hcih6Thqe8/pCrKhYwQhLkNTAbS5OIrZlPgmFrVdJ+mqMPRt9YQVl92Bwk 3OCU/mgml8Ah/VXldLJREy9N9ldu3u8c/2Am0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686787207; x=1689379207; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=12VwvcrgEKdN8aqMI+IAU5PLbg9wZ07LVlbgBSIhCA4=; b=VNRSsaelrCKUZ0uBTyby0kpAXZPb6byjQxEY29HNePRnmHR9JFc7urKkkwRaGBszdy wTij19U9/zBouzW0eWMjGBQDvGe0AjFvynlbbESUnxYC62EwD/epBIWEBYmWVba9diPv 6tV09Vm6BS662X76xad1sg4cyILLmOk9wMAtgxph32seMAdhZC0HOSpqkCdfXt3LWQVD pv2E9oETgaxiLVzZrUmL+cHhMfdoeNKwqS+AuZhQrYshiQf6pznlCSUPdEm8X40GBrGo A7fPltLu1wbzseymLDwcli92/fEEoCs/XqviZZUohQ8S6KSEGZYbwCCMLWKxrJgeGFbZ 18vg== X-Gm-Message-State: AC+VfDwD4pXp47gopsijCa39f93MsfKTNVXbgm2tNDWhuVIuSASD1xbO cmNPdEIWtdEboK4tNoRGeYGEdg== X-Google-Smtp-Source: ACHHUZ7IDFd9vR4zkugOrFreU36PRCwfKzB3S7DOadFjidUUwSKtsg+FoAfmsv5OaByHRCuS5nrCag== X-Received: by 2002:a05:6a20:4b8a:b0:f8:1101:c074 with SMTP id fu10-20020a056a204b8a00b000f81101c074mr2310815pzb.54.1686787207415; Wed, 14 Jun 2023 17:00:07 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:2e78:108:bcc:767d]) by smtp.gmail.com with ESMTPSA id z10-20020a170903018a00b001b1f991a4d0sm12766209plg.108.2023.06.14.17.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 17:00:06 -0700 (PDT) From: Douglas Anderson To: Will Deacon Cc: andersson@kernel.org, amit.pundir@linaro.org, linux-arm-msm@vger.kernel.org, konrad.dybcio@somainline.org, Sibi Sankar , Manivannan Sadhasivam , sumit.semwal@linaro.org, Stephen Boyd , Douglas Anderson , Catalin Marinas , Manivannan Sadhasivam , Marc Zyngier , Robin Murphy , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] Revert "Revert "Revert "arm64: dma: Drop cache invalidation from arch_dma_prep_coherent()""" Date: Wed, 14 Jun 2023 16:59:09 -0700 Message-ID: <20230614165904.1.I279773c37e2c1ed8fbb622ca6d1397aea0023526@changeid> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230614_170009_191252_2EDF39CD X-CRM114-Status: GOOD ( 16.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This reverts commit 7bd6680b47fa4cd53ee1047693c09825e212a6f5. When booting a sc7180-trogdor based device on mainline, I see errors that look like this: qcom_scm firmware:scm: Assign memory protection call failed -22 qcom_rmtfs_mem 94600000.memory: assign memory failed qcom_rmtfs_mem: probe of 94600000.memory failed with error -22 The device still boots OK, but WiFi doesn't work. The failure only seems to happen when CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y. When I don't have that set then everything is peachy. Presumably something about the extra initialization disagrees with the change to drop cache invalidation. Fixes: 7bd6680b47fa ("Revert "Revert "arm64: dma: Drop cache invalidation from arch_dma_prep_coherent()""") Signed-off-by: Douglas Anderson --- arch/arm64/mm/dma-mapping.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index 3cb101e8cb29..5240f6acad64 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -36,7 +36,22 @@ void arch_dma_prep_coherent(struct page *page, size_t size) { unsigned long start = (unsigned long)page_address(page); - dcache_clean_poc(start, start + size); + /* + * The architecture only requires a clean to the PoC here in order to + * meet the requirements of the DMA API. However, some vendors (i.e. + * Qualcomm) abuse the DMA API for transferring buffers from the + * non-secure to the secure world, resetting the system if a non-secure + * access shows up after the buffer has been transferred: + * + * https://lore.kernel.org/r/20221114110329.68413-1-manivannan.sadhasivam@linaro.org + * + * Using clean+invalidate appears to make this issue less likely, but + * the drivers themselves still need fixing as the CPU could issue a + * speculative read from the buffer via the linear mapping irrespective + * of the cache maintenance we use. Once the drivers are fixed, we can + * relax this to a clean operation. + */ + dcache_clean_inval_poc(start, start + size); } #ifdef CONFIG_IOMMU_DMA