From mboxrd@z Thu Jan 1 00:00:00 1970 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 848DCC4332F for ; Fri, 25 Nov 2022 14:56:00 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6oDqTxinHBfmcSSGynIr8Jr8Wu1sjY+tvqoq9MPX6K0=; b=vyRoCmSsSJ66Z6 Q1+R2yEwm/wpItEG5wb7Gb9aiOlL5b4frvr8NZOqvsUawyMY/ogaX0whhT++RZwbKPZAz2/keFdrX t4zkr79u0syQm0+5x2ncO0nOWtsQ4+1raHtjojyaYitWxGtgSB3RsvDL7j8g6yMDoydfDQRv9NTrC gQv10bTiFqkjDuVzyQ1XJ9LIH0u1So6H1WZYsq5/NfA+bC3A7G8VNcsTofcJOV/X8asrhFA8FSCw1 UdjKw4B4awmkLA4ZcKSp67MO/bIQqHbhsO/QbkjOgxXjdK2+wliRFajZgTBTXRSKjMShVVa6YuH0X 0tWJEmjHWnXnvQ5Z49PA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oya6I-00HEfd-Cs; Fri, 25 Nov 2022 14:54:47 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oyZwI-00H9hD-Gk for linux-arm-kernel@lists.infradead.org; Fri, 25 Nov 2022 14:44:28 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3186E6240E; Fri, 25 Nov 2022 14:44:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8978BC433D6; Fri, 25 Nov 2022 14:44:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669387464; bh=MuAwpha+qj7ypes7vfXT4oKy6o8DH33QwZ2K7CESjKA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RtMjx0KGVzlDUNKm+iMxXswVni2hxX+w+hhhpGHCT+Cq9vtG2la0i8kZdrgDcrKre l7YNHyUJopFpdtCU/SylE/gHjsuBb+Y+37fMtJioOR+i1itWiCp2OR2HKNqZoJgYlQ Moww0jEGsfFQQWAiQUcA5XkaMB7TIpgjN2kwWZJs8BkfEDkXlSAywj1wBxzGsT7nHU J/p97AVBmXrTL49HkwK6b12SxQWq3QNdel2QZbgqxXD5QU01m0WZl/ah0L9u5SdVWX xPqTeZGTQef9M5ffcumt42YtbCt+VrPmEb7n8pWuIJRhwE5IPB1pKwxtgN48H03SH3 9s2eEDi3UAp/w== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oyZvr-0005Sz-98; Fri, 25 Nov 2022 15:44:00 +0100 Date: Fri, 25 Nov 2022 15:43:59 +0100 From: Johan Hovold To: Manivannan Sadhasivam Cc: Johan Hovold , Bjorn Andersson , Andy Gross , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Will Deacon , Robin Murphy , Christoph Hellwig , Ard Biesheuvel , Catalin Marinas , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64: dts: qcom: sc8280xp: fix PCIe DMA coherency Message-ID: References: <20221124142501.29314-1-johan+linaro@kernel.org> <20221125142625.GA9892@thinkpad> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221125142625.GA9892@thinkpad> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221125_064426_671357_90C07384 X-CRM114-Status: GOOD ( 30.42 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Nov 25, 2022 at 07:56:25PM +0530, Manivannan Sadhasivam wrote: > On Thu, Nov 24, 2022 at 03:25:01PM +0100, Johan Hovold wrote: > > The devices on the SC8280XP PCIe buses are cache coherent and must be > > marked as such to avoid data corruption. > > > > A coherent device can, for example, end up snooping stale data from the > > caches instead of using data written by the CPU through the > > non-cacheable mapping which is used for consistent DMA buffers for > > non-coherent devices. > > > > Also, the device may write into the L2 cache (or whatever cache that is > accessible) if there is an entry and the CPU may invalidate it before reading > from the DMA buffer. This will end up in a data loss. I mentioned the above as an example, but clearly it can affect also the other direction (e.g. as described below). > > Note that this is much more likely to happen since commit c44094eee32f > > ("arm64: dma: Drop cache invalidation from arch_dma_prep_coherent()") > > that was added in 6.1 and which removed the cache invalidation when > > setting up the non-cacheable mapping. > > > > Marking the PCIe devices as coherent specifically fixes the intermittent > > NVMe probe failures observed on the Thinkpad X13s, which was due to > > corruption of the submission and completion queues. This was typically > > observed as corruption of the admin submission queue (with well-formed > > completion): > > > > could not locate request for tag 0x0 > > nvme nvme0: invalid id 0 completed on queue 0 > > > > or corruption of the admin or I/O completion queues (malformed > > completion): > > > > could not locate request for tag 0x45f > > nvme nvme0: invalid id 25695 completed on queue 25965 > > > > presumably as these queues are small enough to not be allocated using > > CMA which in turn make them more likely to be cached (e.g. due to > > accesses to nearby pages through the cacheable linear map). Increasing > > the buffer sizes to two pages to force CMA allocation also appears to > > make the problem go away. > > > > I don't think the problem will go away if the allocation happens from CMA > region. It may just decrease the chances of cache hit but it could always > happen due to the existence of linear mapping with cacheable attribute. I never claimed it would fix the problem, I explicitly wrote that it made it less likely to occur (to the point where my reproducer no longer triggers). Johan _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel