Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3658690pxb; Sun, 27 Mar 2022 02:24:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9i/cNLFgJ8jtPYcNLKo7kTP16hEwllMZO7v/l+OAKeeWbCfXIDcQhULJpIZ81ns+Yza3/ X-Received: by 2002:a17:90b:3a84:b0:1c7:bc91:a870 with SMTP id om4-20020a17090b3a8400b001c7bc91a870mr20335590pjb.155.1648373067625; Sun, 27 Mar 2022 02:24:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648373067; cv=none; d=google.com; s=arc-20160816; b=pn/uhQkS5zthBh/aToaO4xXNTAFOO/tUyxkIxKWStQlXw+498kNMol+V517EIsz1Kj v3cWpoVy7uBIGUxY1CCB2VWS1nngER0tSy2bS0NKs2yl7aDtMBDgGuYEaJdZ1Ef0QGGC mFHaP1eiB/xfRYG5K1Y71UdZ/L/C79hHA+fqpVM0Lw2ioFySuMsfEVOgzmlyF+pFw/bV mjrkqnPpBU0NvuQYVfr0uFM0FCkTl2mNMR6CAjaxARZGf7v/voM2eZSIl86qUc+hMImd f10Ue7iKOf/wYr0AHt/i3p5gl1oDPZ1TFMNIbx9h6RdnR4Udx3+Vl2doNiG/w520Pu79 V3lQ== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=+mfoRcCmFT0JS6zf2eRI3+Pi12WB0EBK81p1P9sU4gs=; b=Z2g5H6OOlGNXZYOvGcXrA/tDR1Lw9jXea726msbbcpEagCsVJkIngvidrjHti0exYj hFfsaQrL1RGk014mtL91bIckGKGj2wKxWlSO2P3WjD83z6vzJ1/cfwrJEcqQOOe1ibs2 P8NA3s5VmwrSPKfeZGu92TLqyawogcfzOIEGayh0mStRZjNKxwMlwsLJxiY6ip0cYrEH 6DTRFQ880tWk9Avpm90ZY0s9xHrUB5eotcw6vrpjqSmtgYnGLJopNCgN2DXxRv6KPBlS xnDNvCnXDso2vZT+UW1+7C0MwOAsVVkvwtndiZ1CZsxCpPJRCmD+SCOx/EPmCRAquvI8 SwUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Zbdrt0LI; 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=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b1-20020a170903228100b00155d6fbf4e3si7675642plh.405.2022.03.27.02.24.06; Sun, 27 Mar 2022 02:24:27 -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=@ibm.com header.s=pp1 header.b=Zbdrt0LI; 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=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233794AbiC0DvJ (ORCPT + 69 others); Sat, 26 Mar 2022 23:51:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230234AbiC0DvG (ORCPT ); Sat, 26 Mar 2022 23:51:06 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E678562FD; Sat, 26 Mar 2022 20:49:27 -0700 (PDT) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22QNHv8G010618; Sun, 27 Mar 2022 03:48:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=+mfoRcCmFT0JS6zf2eRI3+Pi12WB0EBK81p1P9sU4gs=; b=Zbdrt0LI2EXiVBh5IRuPJS9IKj/qkBF+X7vXMaAYHvsx+9s536+scpooWYSil3E+pNf+ vI98T8t6SBBkOsSdOnO1nqG8abatud3Z8aVbRynfYBK93q3ne50KDOopgDvRr83x1TVj 3+g4vls3PiElzKU+HENeNpjU2X3wieLEnmxHg6+U9eynM1t6NWnGD5aGvj/kg6OhrXur 91Wdcs7ceWvkdAbQoSVzjKIpil8d+3/nIJK94k0TkR+FeP5REEcv5CmmD82g0DV5hyRS FHp3/IwrQQKvaCs2R6JGTu/GnGkW5EqFy+admvvd9RHAzdW5Qs294jHf2VS7I3ahs6nc NA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f2ccrjf5m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 27 Mar 2022 03:48:57 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 22R3muqC030615; Sun, 27 Mar 2022 03:48:56 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f2ccrjf5d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 27 Mar 2022 03:48:56 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 22R3mjgQ008417; Sun, 27 Mar 2022 03:48:54 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03ams.nl.ibm.com with ESMTP id 3f1tf99fpk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 27 Mar 2022 03:48:53 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 22R3mujE45089254 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 27 Mar 2022 03:48:56 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A40D8A404D; Sun, 27 Mar 2022 03:48:51 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B88A0A4040; Sun, 27 Mar 2022 03:48:50 +0000 (GMT) Received: from li-e979b1cc-23ba-11b2-a85c-dfd230f6cf82 (unknown [9.171.73.54]) by d06av23.portsmouth.uk.ibm.com (Postfix) with SMTP; Sun, 27 Mar 2022 03:48:50 +0000 (GMT) Date: Sun, 27 Mar 2022 05:48:48 +0200 From: Halil Pasic To: Linus Torvalds Cc: Toke =?UTF-8?B?SMO4aWxhbmQtSsO4cmdlbnNlbg==?= , Robin Murphy , Christoph Hellwig , Maxime Bizon , Oleksandr Natalenko , 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 , Halil Pasic Subject: Re: [REGRESSION] Recent swiotlb DMA_FROM_DEVICE fixes break ath9k-based AP Message-ID: <20220327054848.1a545b12.pasic@linux.ibm.com> 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> Organization: IBM X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: aU2QkfNNjgUjQGcm0JFsF5Yd0bFRyEZx X-Proofpoint-GUID: ewoGDMbOZ3Cbe29feLOTEoCrihOk2PUz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-27_01,2022-03-24_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=739 clxscore=1015 suspectscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 adultscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203270020 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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 Thu, 24 Mar 2022 12:26:53 -0700 Linus Torvalds wrote: > 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. > > 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. I agree it CPU modified buffers *concurrently* with DMA can never work, and I believe the ownership model was conceived to prevent this situation. But a CPU can modify the buffer *after* DMA has written to it, while the mapping is still alive. For example one could do one partial read from the device, *after* the DMA is done, sync_for_cpu(DMA_FROM_DEVICE), examine, then zero out the entire buffer, sync_for_device(DMA_FROM_DEVICE), make the device do partial DMA, do dma_unmap and expect no residue from the fist DMA. That is expect that the zeroing out was effective. The point I'm trying to make is: if concurrent is even permitted (it isn't because of ownership) swiotlb woudn't know if we are dealing with the *concurrent* case, which is completely bogous, or with the *sequential* case, which at least in theory could work. And if we don't do anyting on the sync_for_device(DMA_FROM_DEVICE) we render that zeroing out the entire buffer form my example ineffective, because it would not reach the bounce buffer, and on dma_unmap we would overwrite the original buffer with the content of the bounce buffer. Regards, Halil