Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1376638pxb; Thu, 24 Mar 2022 19:10:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxoPSGUsY8DQzzMLBrdQeoO/UmHg2hc3YAqXPVGCDR/9X6ueerx4FT3u3XlcbNKDCN5R18 X-Received: by 2002:a05:6402:2748:b0:419:25fd:1197 with SMTP id z8-20020a056402274800b0041925fd1197mr10408799edd.170.1648174253459; Thu, 24 Mar 2022 19:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648174253; cv=none; d=google.com; s=arc-20160816; b=eihh4AsQP1fLj9Y8hWtA4biJ901YzpqxUhIYbIZ3CdkmHphV/aXyeZa+kpjrWqnLr9 mJlG3sC/znACBPAwFWoCy8d7Jqql1424zfvF4TxmHoqH7rBTb0dYtifZzcVy/mza+xC1 NKhyJKd0yB+0EEIVNDVTSP4qAcP9Dd5/4U1X26jaS9JOXPHgqbw4t64Uzsse3/I5qjg7 4/94PZj0QdALtM47tfrVm6KuoJ/BuYgyHQxbEnqSVwvw3UVHEZpLnq5Bw8mxnXxP3G2D 80FHAOS/r5jA8EC1Y9i7g6I5jPRpGD8DJSzQQ45VmdOGfSzqplYwI3m8D8rnQ9OgDqgh IqxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :from; bh=10YpchtIHtcZ8NSl6ZT7uwLuFlfFgJXa9Oolkv8NtQg=; b=qnK2Kwfaqibw+thOo/LpKWJb9IJfFVTz/N+jdLaUc6dFkUd5Vl0eSv0+PZdNh+x7aU Y3cFteXjSVSarEawBT/WfM0Qi2RpNZBk6coU2bqTAYCNPZJoOG73rv0yqN8M82qC2it5 8KpBvApiOXkPSrjJciHn1nXDm7Em9COgDs/1nyPFH2MyCEdYsi2G1GVvG9H2omcZ3VEG kRdJ96uw8SViHtA7O9xJkg4MsJjVpSbruzfVTXNOgt0njjeGz7Ku7RTQwkmJIQ6SM8F3 xWFNYe1jtumVMzHDi4q0Zl5L5vCaB5PMyR/J82nYqljpWKQhm6+3TgOLKLjEZtZM6tEz qpzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toke.dk header.s=20161023 header.b=bgzPaBmG; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=toke.dk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z22-20020aa7c656000000b004190b6bd098si1398274edr.234.2022.03.24.19.10.30; Thu, 24 Mar 2022 19:10:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@toke.dk header.s=20161023 header.b=bgzPaBmG; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=toke.dk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354067AbiCXVQI (ORCPT + 70 others); Thu, 24 Mar 2022 17:16:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349749AbiCXVQE (ORCPT ); Thu, 24 Mar 2022 17:16:04 -0400 X-Greylist: delayed 24396 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 24 Mar 2022 14:14:30 PDT Received: from mail.toke.dk (mail.toke.dk [IPv6:2a0c:4d80:42:2001::664]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 125CF2898C; Thu, 24 Mar 2022 14:14:29 -0700 (PDT) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=toke.dk; s=20161023; t=1648156468; bh=10YpchtIHtcZ8NSl6ZT7uwLuFlfFgJXa9Oolkv8NtQg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=bgzPaBmGHN+bnivn53/b7ZIz9/UwYFmY03s5yT9g1LzfZvAJ3uIC7ce11QS/c9gDk R+EyTlbehDyeBvELCV6f+pU+CmP91zr7lx482udUYxg9jrlR/ovTm9K8oIjoB/rEha koK3I9RsZ9nIP/hbajSqIVn+Bk0NpwJEeSXvuQ3T1G3hO5g+mSdwUwK93gKKp92h+F OmmTJoRUd4/LgjWY01urisinyN5elIPMT5iEkPrjHSSPHnq9iwLcPxdf+NOnHNHk0j L5ovl1Ohbmz8Q5MEpZ3NdLlM2L2Qx85IIHFm9o24PgoAXbuYmLr7yHvHkB7jVoVtj+ eFDzUyYMP1/pw== To: Linus Torvalds Cc: Robin Murphy , Christoph Hellwig , Maxime Bizon , Oleksandr Natalenko , Halil Pasic , Marek Szyprowski , Kalle Valo , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Olha Cherevyk , iommu , linux-wireless , Netdev , Linux Kernel Mailing List , Greg Kroah-Hartman , stable Subject: Re: [REGRESSION] Recent swiotlb DMA_FROM_DEVICE fixes break ath9k-based AP In-Reply-To: References: <1812355.tdWV9SEqCh@natalenko.name> <20220324055732.GB12078@lst.de> <4386660.LvFx2qVVIh@natalenko.name> <81ffc753-72aa-6327-b87b-3f11915f2549@arm.com> <878rsza0ih.fsf@toke.dk> <4be26f5d8725cdb016c6fdd9d05cfeb69cdd9e09.camel@freebox.fr> <20220324163132.GB26098@lst.de> <871qyr9t4e.fsf@toke.dk> Date: Thu, 24 Mar 2022 22:14:28 +0100 X-Clacks-Overhead: GNU Terry Pratchett Message-ID: <87r16r834b.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Linus Torvalds writes: > On Thu, Mar 24, 2022 at 10:07 AM Toke H=C3=B8iland-J=C3=B8rgensen wrote: >> >> Right, but is that sync_for_device call really needed? > > Well, imagine that you have a non-cache-coherent DMA (not bounce > buffers - just bad hardware)... > > So the driver first does that dma_sync_single_for_cpu() for the CPU > see the current state (for the non-cache-coherent case it would just > invalidate caches). > > The driver then examines the command buffer state, sees that it's > still in progress, and does that return -EINPROGRESS. > > It's actually very natural in that situation to flush the caches from > the CPU side again. And so dma_sync_single_for_device() is a fairly > reasonable thing to do in that situation. > > But it doesn't seem *required*, no. The CPU caches only have a copy of > the data in them, no writeback needed (and writeback wouldn't work > since DMA from the device may be in progress). > > So I don't think the dma_sync_single_for_device() is *wrong* per se, > because the CPU didn't actually do any modifications. > > But yes, I think it's unnecessary - because any later CPU accesses > would need that dma_sync_single_for_cpu() anyway, which should > invalidate any stale caches. OK, the above was basically how I understood it. Thank you for confirming! > And it clearly doesn't work in a bounce-buffer situation, but honestly > I don't think a "CPU modified buffers concurrently with DMA" can > *ever* work in that situation, so I think it's wrong for a bounce > buffer model to ever do anything in the dma_sync_single_for_device() > situation. Right. > Does removing that dma_sync_single_for_device() actually fix the > problem for the ath driver? I am hoping Oleksandr can help answer that since my own ath9k hardware is currently on strike :( -Toke