Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp433831rwl; Thu, 6 Apr 2023 22:56:32 -0700 (PDT) X-Google-Smtp-Source: AKy350bm0CWBqpadfytk+qBlpDaPafwMQUo465hyz4jt5bOb9U/RF1QrwYnauziXkWCp5gIo5DXg X-Received: by 2002:a05:6a20:671a:b0:da:8ee4:5b9 with SMTP id q26-20020a056a20671a00b000da8ee405b9mr1930228pzh.7.1680846992115; Thu, 06 Apr 2023 22:56:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680846992; cv=none; d=google.com; s=arc-20160816; b=saUqwcMWcTgEbJU7hmrbXCG1gc+gwr4aCzwfLhJZg+mYUcAvdtIMsramUHLr5haoDh sKDjobVLbM//WjdxlOy3zL77LW9jB7U5OAehXlNG44gAJ4H123R0XOXzowrGfwciiESu Pb/SLlNJ/P15a48zMAZ01R8tz5tAi1bLcYfbmx+FfwyD67ptwCBuAUeDXTAkpvPxGALR Q0iv/gitOrqWF/vGufSoMQMcS2PDNLsgimvH8TlcM6xPCty2GGTKi53Y9VvFdFK0eOa/ KA3+kQ3xyEWzV396u4Lm59eLMYPjkqBTk/4tAz0glZcriUru5gabztqcjs8Taw1PRtxb PwZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=yphI+Ry6+ko/fwqRXO9c6UFB++YVGVDdaWMYt1kNthQ=; b=rA5U4Tt2fPpXNJrwlKVt+pAx1cDD6v/9L8Lyo2H6biWuB8BO6vAzkq15uhBolaiKQ0 jleZVWhIjB3nOOwfzb556tYNWqpcEhF7wtRmWv3RGenDWviOXACwZuTwECQ5UkNDg9l6 nFS2NgVbWONEUX+JGP69igiRiHI2V902CLuqQyawvWty6qm2f4EH5GlvgvLOZ7ozd264 nSddgcp8gwSu47SRE1VBdPEH1EZxbV8eG8OFZ1+bJOFReLAlu5O0Z779v2fQ7oFO5CRp 0OVj91kl7M10ILStBADXRo02vTYMhr170QObaOPJNRsGh+ULHbli2EWlzqMpd8IHE7cR 0udA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t184-20020a625fc1000000b0062811fe3da7si2928566pfb.157.2023.04.06.22.56.20; Thu, 06 Apr 2023 22:56:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232316AbjDGFzz (ORCPT + 99 others); Fri, 7 Apr 2023 01:55:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231210AbjDGFzy (ORCPT ); Fri, 7 Apr 2023 01:55:54 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EAA8C5; Thu, 6 Apr 2023 22:55:53 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id 9128F68AA6; Fri, 7 Apr 2023 07:55:48 +0200 (CEST) Date: Fri, 7 Apr 2023 07:55:48 +0200 From: Christoph Hellwig To: Petr Tesarik Cc: Christoph Hellwig , Jonathan Corbet , Marek Szyprowski , Robin Murphy , Borislav Petkov , "Paul E. McKenney" , Andrew Morton , Randy Dunlap , Damien Le Moal , Kim Phillips , "Steven Rostedt (Google)" , "open list:DOCUMENTATION" , open list , "open list:DMA MAPPING HELPERS" , Roberto Sassu , petr@tesarici.cz, Alexander Graf Subject: Re: [RFC v1 3/4] swiotlb: Allow dynamic allocation of bounce buffers Message-ID: <20230407055548.GC6803@lst.de> References: <0334a54332ab75312c9de825548b616439dcc9f5.1679309810.git.petr.tesarik.ext@huawei.com> <20230328040724.GB25506@lst.de> <4268fa4e-4f0f-a2f6-a2a5-5b78ca4a073d@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4268fa4e-4f0f-a2f6-a2a5-5b78ca4a073d@huaweicloud.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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-kernel@vger.kernel.org On Tue, Mar 28, 2023 at 09:54:35AM +0200, Petr Tesarik wrote: > I tend to agree here. However, it's the DMABUF design itself that causes > some trouble. The buffer is allocated by the v3d driver, which does not > have the restriction, so the DMA API typically allocates an address > somewhere near the 4G boundary. Userspace then exports the buffer, sends > it to another process as a file descriptor and imports it into the vc4 > driver, which requires DMA below 1G. In the beginning, v3d had no idea > that the buffer would be exported to userspace, much less that it would > be later imported into vc4. Then we need to either: a) figure out a way to communicate these addressing limitations b) find a way to migrate a buffer into other memory, similar to how page migration works for page cache > BTW my testing also suggests that the streaming DMA API is quite > inefficient, because UAS performance _improved_ with swiotlb=force. > Sure, this should probably be addressed in the UAS and/or xHCI driver, > but what I mean is that moving away from swiotlb may even cause > performance regressions, which is counter-intuitive. At least I would > _not_ have expected it. That is indeed very odd. Are you running with a very slow iommu driver there? Or what is the actual use case there in general? > >> + gfp = (attrs & DMA_ATTR_MAY_SLEEP) ? GFP_KERNEL : GFP_NOWAIT; > >> + slot = kmalloc(sizeof(*slot), gfp | __GFP_NOWARN); > >> + if (!slot) > >> + goto err; > >> + > >> + slot->orig_addr = orig_addr; > >> + slot->alloc_size = alloc_size; > >> + slot->page = dma_direct_alloc_pages(dev, PAGE_ALIGN(alloc_size), > >> + &slot->dma_addr, dir, > >> + gfp | __GFP_NOWARN); > >> + if (!slot->page) > >> + goto err_free_slot; > > > > Without GFP_NOIO allocations this will deadlock eventually. > > Ah, that would affect the non-sleeping case (GFP_KERNEL), right? Yes.