Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp576928rdb; Thu, 22 Feb 2024 12:29:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXG4JsAMXiB5/5TFJHUB/DeJrs3/aGg7Rom/RdV5zrdT6z2ZflgRSX+KvyAgUVEY45AuFfjYMy7rTPb1DIUm5xhoSCb20ILnk201J2l/w== X-Google-Smtp-Source: AGHT+IHYBqG3Zwctyp3Bp3I91yv7PBJcfRgRbbmFmkonzt6xuTtl1MYfIfLBCXvYLAfgsoCsmhNV X-Received: by 2002:a05:6a21:3489:b0:1a0:d0d1:8e97 with SMTP id yo9-20020a056a21348900b001a0d0d18e97mr3894264pzb.18.1708633774562; Thu, 22 Feb 2024 12:29:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708633774; cv=pass; d=google.com; s=arc-20160816; b=CuV6m07FaroX8rcYtx8f69xWEWxfMeUCm7n7BJ5ZWGBwpPaXWc1sPzCYNtuu00M6V2 KPHxJLuhDaCK/ClKBMKqHvy/jpRqGzaq2wEvu8+tTdVmv1jXJPM9QJdUgtdW+g5xw65I /km/MUN8xsJQ8bNT92dG1Id0KMq4Oyt2icU2rjPv2yXVFixnA3a/CP3HUIeVqU1ZSrBf bqumSzBj1YWFjNkf+pp4SiVtWvYaVZe86OkNmiHT7WyaRbmI0oo60+pFRDKOl/MfF30B F9mVNq2Uzzx4YrOM4k0kqGSTW36+eSoKaKqLcpA+mzOrC9uGz1m8FO6BTy6f/tY+m/uw 6kbg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=g9U/SuU7EoZOYs84Oq+NGNW63wWSqGFV+44C2eP5B4o=; fh=4sd3JFq/aTplxPrF+hWFJN1hHtT2HY3QETt1d262qX4=; b=jwQUsOdr6VRdPtLKkm7jH7PxYVu0WTYlxZvN3vakuvzC1XWumU2T1hTOF1o/uXq6NI VwegbPS/NxvAbr3qGB2lz81GHTewOSuh33BxuWE8ndZNcI0S1rZ1oQ6F19UGJnxgBqd9 qDrndOY6NjnspDybTHe8qIPMC1ymo2hN94tnXQMg18D76zhlQ3ab1D0uxnUXkRRDbiYf +W05/Pibei/eAZO8NNDKIkhs3P/r7tqCdnkNfsVsgeQLTzD7ahXZYx2hb3SUzSzoB6GG X7StD1sQgJsWIbcDq6oj41wSNYIYvlDPg3LjPgYyn/7UVdRW6aXxeO3pMC4OBNepR8HS s6Ig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GnNp+y7l; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-77318-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77318-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id fd12-20020a056a002e8c00b006e05b7bfcffsi11220800pfb.52.2024.02.22.12.29.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:29:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77318-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GnNp+y7l; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-77318-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77318-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 44D492830EB for ; Thu, 22 Feb 2024 20:29:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 65B2A6E615; Thu, 22 Feb 2024 20:29:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GnNp+y7l" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C81054903 for ; Thu, 22 Feb 2024 20:29:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708633764; cv=none; b=hkwzrCVZv/lpKPZIWX1B+sjSrBuQguha8Bksqb9g7UFyHzEDyf0QrSwz0VXRVMndygh0+BK6Dcrc13LOAYHvXXc0MADoCIi7DrQj9hF6YS5fYf+YkkR1CCWgU9sH0aV84+Cl+EqnnDN6Qd6mBnNewegIkaxvBSX196vwX0P0NMg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708633764; c=relaxed/simple; bh=EIRl5JmeNnsCCCvrzAJOkSjYNmO/xKRIFAlKwErah0Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=m4xe2vV2XEgSSPzZ30ydqcL9twCJUlKhlT/XZzIrWPxj5lmTSZKmOqcdOK4pIQyBsPKluEeOwb5vm1g6bPL5yG/bY7Y7ZnEgXnuNJvyrCy92wh/b6ONXcGrbXQeBzk0PVNB9G0GKlRldHJW6gurN9vBcIQqPOK/QV3sZcAUjq/A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=GnNp+y7l; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708633761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=g9U/SuU7EoZOYs84Oq+NGNW63wWSqGFV+44C2eP5B4o=; b=GnNp+y7lj4fd3KSHBNXjRXfvxWZpSAun8XEqx+eF+sThOLU74VNzJq0Sc6z93c3hMKNkMb q/Ib3fWMAE79AAIoHFoHm+L2298umJz3f1dVUPaAe17A4EWyf+UHaYB8p2pu9ZADKuWzVw WUctRIWIYT2sV9jlJLxsg/MKxwjAblM= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-48-iyyrkQUbOh2tq3JT8S6XPQ-1; Thu, 22 Feb 2024 15:29:20 -0500 X-MC-Unique: iyyrkQUbOh2tq3JT8S6XPQ-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-33d308b0c76so599225f8f.0 for ; Thu, 22 Feb 2024 12:29:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708633759; x=1709238559; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=g9U/SuU7EoZOYs84Oq+NGNW63wWSqGFV+44C2eP5B4o=; b=g7xYPbNNtUNaaj4qoJAZYO/t3lij6aVg59/ZI6+4uYn6w4DrHTHGJHWXHZqVtYapiU FmIF4e0cBCLULxA8Uf+lhWz8dNWfCaEfOkf7fxGqXBYuEHUw7O38vBWvQjj1aJm7N8ct LLiRx9hm2kKetSqPz6fVFWPIF6cpEZU80wroNSWzrvolJRtF8YBiLowQD88VTSPrEd8V rp9YZnPBBbTalOsIz6Gk47bemlhM1XoYquyBmTooXd4ozAwBjv12iVARGovB0XVbDJuG Q4I5VKSN8+MLm938SRlEDrLW+8r0ErpiXZyUUXeG4yir51+ULXSUKvcO9Br0jSTcds6k b7Iw== X-Forwarded-Encrypted: i=1; AJvYcCW6pl1oKfhPjiN6091Vn/cBtBZKgwZ1a+1xbKoKOVmDLmkYarkIE4ylexl3wXq0L+8r/ldI/m4hQsxNJY5X4uk8qbDQfbFRpQQc5g8v X-Gm-Message-State: AOJu0YwhG1BFo7wcRwfibTSWVqfznwNbir43W8c+OFIHNDT6giJavYbV k1NIRb7bxvFDQ6BQu233eYnSoiU+306K9NUCIMXriu4AqLxpfp0EcVNwZ2xpUX07eqh4Y4iKF4x 49QFeum4gV3Iby8CuJKv28Ctw4OdNOoNUibvIspLgH6XnAO4eBSNKWSKTUF/S7A== X-Received: by 2002:a5d:490b:0:b0:33d:513a:9248 with SMTP id x11-20020a5d490b000000b0033d513a9248mr3036120wrq.15.1708633758954; Thu, 22 Feb 2024 12:29:18 -0800 (PST) X-Received: by 2002:a5d:490b:0:b0:33d:513a:9248 with SMTP id x11-20020a5d490b000000b0033d513a9248mr3036108wrq.15.1708633758639; Thu, 22 Feb 2024 12:29:18 -0800 (PST) Received: from redhat.com ([172.93.237.99]) by smtp.gmail.com with ESMTPSA id h15-20020a05600004cf00b0033b1c321070sm142852wri.31.2024.02.22.12.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:29:18 -0800 (PST) Date: Thu, 22 Feb 2024 15:29:10 -0500 From: "Michael S. Tsirkin" To: Christoph Hellwig Cc: Maxime Coquelin , jasowang@redhat.com, xuanzhuo@linux.alibaba.com, xieyongji@bytedance.com, axboe@kernel.dk, gregkh@linuxfoundation.org, brauner@kernel.org, lstoakes@gmail.com, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, david.marchand@redhat.com Subject: Re: [PATCH] vduse: implement DMA sync callbacks Message-ID: <20240222152541-mutt-send-email-mst@kernel.org> References: <20240219170606.587290-1-maxime.coquelin@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Feb 20, 2024 at 01:01:36AM -0800, Christoph Hellwig wrote: > On Mon, Feb 19, 2024 at 06:06:06PM +0100, Maxime Coquelin wrote: > > Since commit 295525e29a5b ("virtio_net: merge dma > > operations when filling mergeable buffers"), VDUSE device > > require support for DMA's .sync_single_for_cpu() operation > > as the memory is non-coherent between the device and CPU > > because of the use of a bounce buffer. > > > > This patch implements both .sync_single_for_cpu() and > > sync_single_for_device() callbacks, and also skip bounce > > buffer copies during DMA map and unmap operations if the > > DMA_ATTR_SKIP_CPU_SYNC attribute is set to avoid extra > > copies of the same buffer. > > vduse really needs to get out of implementing fake DMA operations for > something that is not DMA. In a sense ... but on the other hand, the "fake DMA" metaphor seems to work surprisingly well, like in this instance - internal bounce buffer looks a bit like non-coherent DMA. A way to make this all prettier would I guess be to actually wrap all of DMA with virtio wrappers which would all go if () dma_... else vduse_...; or something to this end. A lot of work for sure, and is it really worth it? if the only crazy driver is vduse I'd maybe rather keep the crazy hacks local there ... -- MST