Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2010093pxb; Fri, 25 Mar 2022 09:31:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBu1gnIE+d9PTUts4gMzUNYq5oICSZWx/46igPK+Bu9WLTUIuBPInUvmobX5r40TTY6gwM X-Received: by 2002:a50:ec0c:0:b0:418:f415:6bfe with SMTP id g12-20020a50ec0c000000b00418f4156bfemr14090605edr.15.1648225864677; Fri, 25 Mar 2022 09:31:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648225864; cv=none; d=google.com; s=arc-20160816; b=U+kTfN7GPTv6EiDNlGbN+YZqtupgmKs+fRR67+7VTlRa7mnTLMOgK9oENRYXRUDLy7 YcvCyteF53/uGUC8UbCto4FSwOZIEfUuY10zrL26cHLIPxtDKsJxlX2cykSgOt05/OD8 OkCojgD9lMSjAu4j16gLBDBbi6wb1thR6Y3d3xeITzsl2PWOCG9fljk7H1YYWfO3soNX rxcpdx9wIABHJi7O4hhtUiukw3r0Y4ktSAfzycswlNb6gpgzjQB3ONH127sgCudknrKv d5jvqJxhBH6TC2CeIBCgX+V2nQpRkA7X2PxJQOJmnb1AAlKlmwTtqlb6zuTbp5b9237r 3QPw== 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=vWpPS0c7fjeoW36ZabpNcZXVoKl5smK0ZIIaLkXNAOk=; b=IvESKynF2W/pP/Vr1qskG+WDJer3H/jsF3fQKNvZuP7OX6SM6UFXb1Z84mGgaS21yN zDHvCJPxlJ+70AQVIlMzMRFtsC257OenRCHQ1wubvC0v1Vz3EgZMeQqxQoRgj4pF2KOu A0V5RvPiXJtyNUOh23TT091HwRlq0p2KNfvrbv9zdAW2m5ZSuxE7zq6imfjOLhduN0O/ 06Lg0O0frrN4ix07V/d5B9iKlBEtA8kpQ+AF7u0ek4ygzFqlQeoDjlwMRi3kj/JYhCZU Hsa4GaIJLxeMVPTHR4HDkG3wDYlD6fHaePS0c7EHUevkynHquJI6oWCDzwssI8Q0qjP9 0Ktg== 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 v26-20020a50d09a000000b00418c2b5beb3si2780993edd.405.2022.03.25.09.30.39; Fri, 25 Mar 2022 09:31:04 -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 S1376592AbiCYQZS (ORCPT + 70 others); Fri, 25 Mar 2022 12:25:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354899AbiCYQZR (ORCPT ); Fri, 25 Mar 2022 12:25:17 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E27AD5EBF7; Fri, 25 Mar 2022 09:23:41 -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 8E0F1D6E; Fri, 25 Mar 2022 09:23:40 -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 E48393F73D; Fri, 25 Mar 2022 09:23:37 -0700 (PDT) Message-ID: <11d4c863-5bee-aa98-526c-ac7170296485@arm.com> Date: Fri, 25 Mar 2022 16:23:34 +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: Halil Pasic Cc: Linus Torvalds , Oleksandr Natalenko , Christoph Hellwig , Marek Szyprowski , =?UTF-8?Q?Toke_H=c3=b8iland-J=c3=b8rgensen?= , 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> <27b5a287-7a33-9a8b-ad6d-04746735fb0c@arm.com> <20220324190216.0efa067f.pasic@linux.ibm.com> <20220325162508.3273e0db.pasic@linux.ibm.com> From: Robin Murphy In-Reply-To: <20220325162508.3273e0db.pasic@linux.ibm.com> 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-25 15:25, Halil Pasic wrote: > On Thu, 24 Mar 2022 19:02:16 +0100 > Halil Pasic 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 >>> think by that point we were increasingly tired and confused and starting >>> to second-guess ourselves (well, I was, at least). >> >> I raised the question, do we need to do the same for >> swiotlb_sync_single_for_device(). Did that based on my understanding of the >> DMA API documentation. I had the following scenario in mind >> >> SWIOTLB without the snyc_single: >> Memory Bounce buffer Owner >> -------------------------------------------------------------------------- >> start 12345678 xxxxxxxx C >> dma_map(DMA_FROM_DEVICE) 12345678 -> 12345678 C->D >> device writes partial data 12345678 12ABC678 <- ABC D >> sync_for_cpu(DMA_FROM_DEVICE) 12ABC678 <- 12ABC678 D->C >> cpu modifies buffer 66666666 12ABC678 C >> sync_for_device(DMA_FROM_DEVICE) 66666666 12ABC678 C->D >> device writes partial data 66666666 1EFGC678 <-EFG D >> dma_unmap(DMA_FROM_DEVICE) 1EFGC678 <- 1EFGC678 D->C >> >> Legend: in Owner column C stands for cpu and D for device. >> >> Without swiotlb, I believe we should have arrived at 6EFG6666. To get the >> same result, IMHO, we need to do a sync in sync_for_device(). >> And aa6f8dcbab47 is an imperfect solution to that (because of size). >> > > @Robin, Christoph: Do we consider this a valid scenario? Aha, I see it now (turns out diagrams really do help!) - so essentially the original situation but with buffer recycling thrown into the mix as well... I think it's technically valid, but do we know if anything's actually doing that in a way which ends up affected? For sure it would be nice to know that we had all bases covered without having to audit whether we need to, but if it's fundamentally incompatible with what other code expects, that we know *is* being widely used, and however questionable it may be we don't have an easy fix for, then we're in a bit of a tough spot :( Thanks, Robin.