Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1271200pxb; Thu, 24 Mar 2022 16:34:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBZT4qGgrneDFw3XOw58L0Cm+K+6ZnTHyiayjcc7pRoz6Ltkk+iwMBUApmAHCQhB145Ua6 X-Received: by 2002:a17:90b:4f41:b0:1c7:928d:196e with SMTP id pj1-20020a17090b4f4100b001c7928d196emr12634868pjb.47.1648164859435; Thu, 24 Mar 2022 16:34:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648164859; cv=none; d=google.com; s=arc-20160816; b=uo7txrokGkhaj4ZhPckWOvxcnmDYPRzApqSo2GGGxeCWKVLeubGURjOTIQ3IxpnVmj d/YgtJpTAbUt/1/15wlut/mHew9dpu5mUvIWIi/1q1hxI0LjTplcv5DdYzXbWxMecS7C zsPgI0iE9q0wkPNp4PI7WcbMi4m2YLAuxIztJaj9T5e3bwnt4TXwv1/nEOVb8OBItfDE ir1bD9QMelSTP3mZzsa1lEMhBWuKB9uuLBiVp3bBLEnWMNAOrhBmcHZIfeYFC5ZNNn5h Vry1Yg73XCKPp9E2BO0wQMLb+ZfA6kvdsnk3CdKiEaTyQTIVpA9z+1KbR0byGjyRYzsw HvZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=FCYr0+bvCg5eUux/Umz+oFozxSqCh9juyavq6gqQTTU=; b=vjiHMZBsflg4OxIBvysplXvhgJrnF5+4p6MDCKjQ3WQlcUnJZxN5JRPof6SADzxJw3 9EXCeUjEDPydmTRQY4AoSH3AyVazkAMPMeis1VFg8+J9HISbUzehYsZs+g0INnhsGcKh Ii0E8ivcKueQXauuSP/KEzJMYI6NJzAgCovaFWLBDMdCjJ36BEihPFP7YMKIM3AUNgbo JDipM5bWxysRy7hf9Y+V81TrgQIlNlUYis0lljjDuUe42d7e4NdS4ic2+ltZI8e2lz9O l/9MApvS3PcqQGzwXwE7LKn7U7vtE+4+M97Ojx+wc5iHwAiv1dBjr7Wv2ZZLvbJXQnRs NDyw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w13-20020a170902a70d00b00153b2d16449si702539plq.81.2022.03.24.16.34.01; Thu, 24 Mar 2022 16:34:19 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352038AbiCXQ4N (ORCPT + 70 others); Thu, 24 Mar 2022 12:56:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352043AbiCXQzq (ORCPT ); Thu, 24 Mar 2022 12:55:46 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AAB55B7156; Thu, 24 Mar 2022 09:52:38 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 39B06D6E; Thu, 24 Mar 2022 09:52:38 -0700 (PDT) Received: from [10.57.41.19] (unknown [10.57.41.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6D3993F73B; Thu, 24 Mar 2022 09:52:35 -0700 (PDT) Message-ID: Date: Thu, 24 Mar 2022 16:52:31 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [REGRESSION] Recent swiotlb DMA_FROM_DEVICE fixes break ath9k-based AP Content-Language: en-GB To: Christoph Hellwig , Maxime Bizon Cc: =?UTF-8?Q?Toke_H=c3=b8iland-J=c3=b8rgensen?= , Oleksandr Natalenko , 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 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> From: Robin Murphy In-Reply-To: <20220324163132.GB26098@lst.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,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 On 2022-03-24 16:31, Christoph Hellwig wrote: > On Thu, Mar 24, 2022 at 05:29:12PM +0100, Maxime Bizon wrote: >>> 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 :) >> >> This looks fishy: >> >> ath9k/recv.c >> >> /* We will now give hardware our shiny new allocated skb */ >> new_buf_addr = dma_map_single(sc->dev, requeue_skb->data, >> common->rx_bufsize, dma_type); >> if (unlikely(dma_mapping_error(sc->dev, new_buf_addr))) { >> dev_kfree_skb_any(requeue_skb); >> goto requeue_drop_frag; >> } >> >> /* Unmap the frame */ >> dma_unmap_single(sc->dev, bf->bf_buf_addr, >> common->rx_bufsize, dma_type); >> >> bf->bf_mpdu = requeue_skb; >> bf->bf_buf_addr = new_buf_addr; > > Creating a new mapping for the same buffer before unmapping the > previous one does looks rather bogus. But it does not fit the > pattern where revering the sync_single changes make the driver > work again. OK, you made me look :) Now that it's obvious what to look for, I can only conclude that during the stanza in ath_edma_get_buffers(), the device is still writing to the buffer while ownership has been transferred to the CPU, and whatever got written while ath9k_hw_process_rxdesc_edma() was running then gets wiped out by the subsequent sync_for_device, which currently resets the SWIOTLB slot to the state that sync_for_cpu copied out. By the letter of the DMA API that's not allowed, but on the other hand I'm not sure if we even have a good idiom for "I can't tell if the device has finished with this buffer or not unless I look at it" :/ Robin.