Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1279618pxb; Thu, 24 Mar 2022 16:46:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpPANAF4sbQZY0T9zmwakzsGScqosp+7ZG1vYsnduzwkYeJLp2IAvGwIMBxLrX5jtIz16S X-Received: by 2002:a17:906:7706:b0:6d6:e521:5471 with SMTP id q6-20020a170906770600b006d6e5215471mr8394557ejm.387.1648165573323; Thu, 24 Mar 2022 16:46:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648165573; cv=none; d=google.com; s=arc-20160816; b=yajyeEXDSgL1wgUlIwtD9CC36MgsRkk41DfIq56jVEm/PTLyBdMhn2CwPm8hQeFVKS WXMT8Ut9D3EghANrTl69G+nlThe05T6B3CuTZLIv3MUOX5KWxi6lngzZbQyP+HNAyVJx 2TBq++fXHStKchUk9H7pYdspwWRLgRvNICGFla+JaYHwqRTCeloXJpCj6mTbOofzPdDC prepIYJjupMWZWH2Ux9eFMxSBn8OG2WQQxxK8O8KvAFAkxNQpELxS8BYP3HSGcKDruZp +UcjHm1h5kl+2LRdf3Bm9JUHnm2dqzU2vwgBj5xwYMTWgfzmVxEWJyblB8DZ3UCOGG1s BRLQ== 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=IBADUMlp8+7+M13hOF7mx4qCmodEu64n0r+Uxu9OJg0=; b=DqJpkUb+bnB6JhXsRtyeSb8T0vWvxhZx57TVpXNaUEMAOjvIUdIsSJgtLFRzkCKA1C 29kTv/z9WxJoJ9cwfMXFm538z+ODXg0DmDnjotXCNQ2p6jHDgeMmf3xWiI2/cXxLPzzW Gt2ynhdX3SbH64gU697s4+3tFixrvGGx5ABcsh7CcXxt00SVlRu9EGfteO353p5NvW6f ewvcSTgvTBJkNAG4+HSvav9e8VsqLtXq7ycMFL1zBsoeWudN09CAytK8q9ZaOgWw9PS8 nc/6MkUEoFMCvYFndFlgS1BCGAU6IfR9ZQYK7qs+mzrV0uD+s6g7uN5FMtul2XY4lXKr 8rtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toke.dk header.s=20161023 header.b=Nl31SHkG; 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 u1-20020a170906780100b006df76385ee2si733036ejm.898.2022.03.24.16.45.56; Thu, 24 Mar 2022 16:46:13 -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=Nl31SHkG; 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 S1350928AbiCXO3d (ORCPT + 70 others); Thu, 24 Mar 2022 10:29:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350902AbiCXO32 (ORCPT ); Thu, 24 Mar 2022 10:29:28 -0400 Received: from mail.toke.dk (mail.toke.dk [IPv6:2a0c:4d80:42:2001::664]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FEF67B105; Thu, 24 Mar 2022 07:27:54 -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=1648132071; bh=tnWUB/odmMKWGyF8he0G98tAGrRwpBch0DMAenM1KqE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Nl31SHkGEOpmzbhGTx/T436+jfkG7FgLD/mSjYD7BSj0K+POWTP/XdxPCiodxbxQl fs/0XEz6ZSEqIigCk9/SGOf78e9BBUztwbBZDzqH/ljmF35/Ft7SaJ2tb+ZfJ3B82v 5Ds6VCknje0VtdskIGdvIYT2IP30ry+Tg++Nwx0V4+GwyeAIHvqo5gXJBHda6FCGFN qWMkQGe87jzEr6SAA82toe9moP0NlIgQE7lxYyU93qrPdMDq9NoRbCop8YAlmyRwBG DCvoBiDd0G923RpGwr8v+jV+hGB48XSTTIsaeMsKUjkspEaeCquR+2Qwv8L3tLcNxb xaKx373cf/cWw== To: Robin Murphy , Oleksandr Natalenko , Christoph Hellwig Cc: Linus Torvalds , 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: <81ffc753-72aa-6327-b87b-3f11915f2549@arm.com> References: <1812355.tdWV9SEqCh@natalenko.name> <20220324055732.GB12078@lst.de> <4386660.LvFx2qVVIh@natalenko.name> <81ffc753-72aa-6327-b87b-3f11915f2549@arm.com> Date: Thu, 24 Mar 2022 15:27:50 +0100 X-Clacks-Overhead: GNU Terry Pratchett Message-ID: <878rsza0ih.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 Robin Murphy writes: > On 2022-03-24 10:25, Oleksandr Natalenko wrote: >> Hello. >>=20 >> On =C4=8Dtvrtek 24. b=C5=99ezna 2022 6:57:32 CET Christoph Hellwig wrote: >>> On Wed, Mar 23, 2022 at 08:54:08PM +0000, Robin Murphy wrote: >>>> I'll admit I still never quite grasped the reason for also adding the >>>> override to swiotlb_sync_single_for_device() in aa6f8dcbab47, but I th= ink >>>> by that point we were increasingly tired and confused and starting to >>>> second-guess ourselves (well, I was, at least). I don't think it's wro= ng >>>> per se, but as I said I do think it can bite anyone who's been doing >>>> dma_sync_*() wrong but getting away with it until now. If ddbd89deb7d3 >>>> alone turns out to work OK then I'd be inclined to try a partial rever= t of >>>> just that one hunk. >>> >>> Agreed. Let's try that first. >>> >>> Oleksandr, can you try the patch below: >>> >>> >>> diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c >>> index 6db1c475ec827..6c350555e5a1c 100644 >>> --- a/kernel/dma/swiotlb.c >>> +++ b/kernel/dma/swiotlb.c >>> @@ -701,13 +701,10 @@ void swiotlb_tbl_unmap_single(struct device *dev,= phys_addr_t tlb_addr, >>> void swiotlb_sync_single_for_device(struct device *dev, phys_addr_t t= lb_addr, >>> size_t size, enum dma_data_direction dir) >>> { >>> - /* >>> - * Unconditional bounce is necessary to avoid corruption on >>> - * sync_*_for_cpu or dma_ummap_* when the device didn't overwrite >>> - * the whole lengt of the bounce buffer. >>> - */ >>> - swiotlb_bounce(dev, tlb_addr, size, DMA_TO_DEVICE); >>> - BUG_ON(!valid_dma_direction(dir)); >>> + if (dir =3D=3D DMA_TO_DEVICE || dir =3D=3D DMA_BIDIRECTIONAL) >>> + swiotlb_bounce(dev, tlb_addr, size, DMA_TO_DEVICE); >>> + else >>> + BUG_ON(dir !=3D DMA_FROM_DEVICE); >>> } >>>=20=20=20 >>> void swiotlb_sync_single_for_cpu(struct device *dev, phys_addr_t tlb_= addr, >>> >>=20 >> With this patch the AP works for me. > > Cool, thanks for confirming. So I think ath9k probably is doing=20 > something dodgy with dma_sync_*(), but if Linus prefers to make the=20 > above change rather than wait for that to get figured out, I believe=20 > that should be fine. I'm looking into this; but in the interest of a speedy resolution of the regression I would be in favour of merging that partial revert and reinstating it if/when we identify (and fix) any bugs in ath9k :) -Toke