Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3577971imm; Sun, 10 Jun 2018 20:31:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLqdByp433CFJXs1EDj0+wcJ1y4JV7FE+004yAZNH7M5vMmFfRFL6z5MAdjbOUep0XGCUUZ X-Received: by 2002:a62:1282:: with SMTP id 2-v6mr15814889pfs.243.1528687890851; Sun, 10 Jun 2018 20:31:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528687890; cv=none; d=google.com; s=arc-20160816; b=IXB7TlCA46QOgAXB954C/iOo4lvmoHO2Lyy9DfB/bb08QLeAkWZ1k3BT0tHNZhkQn/ Jz9X2Xm9TVEiJM9VMUjclcoOW3zrdxY5ZvzFIt5aBbLpCLH18PwuxeFX9vIffpUaYlzB Kv2Z+BwcV3998gZUCiuyT7fmuuIqAWHHAYglJ9DsVR+RkHLBenBf9hcvKEuItig8gxoM uR6cLO0uCiypRi8NcHxiplm1XwoQXln9HkTLHtEr5zw05IYmv4GsERXm+NiFs3F7fFvQ qfTR9o6OQLSysrvKaqszWI+k20FbzWoKo7osdjI3AxBYdGWGgmZbBNTFZ3VEDfoxuSab ZWNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=8DB8/yi/NaURfkvZpdFpo8SWY3aH217F/pv2o5H19GU=; b=WYxNvxDFa0TDh5FMX1ZoQv2CVoXNwl2RDCStPOrcuuvaDaVblg8YvbUn0or55j/Y6c /z1qmqA9hesW6Ym+qVJNZlSrEu5x1t1wMBrgdiMVYJlJj0P8y0stbA3mQnUvNmaU/NWQ Fu4xCCt8UPkO3HGqQK//rjruNwmPDdUQD1KS36VSVgD9K4/u4aPvanbNOkLk5OOKmZ2t fcItduyP9t1ENFT5jmfym1z2x5OMoHYhnD1WPDAIsUo/oZQGaCGvhCySohMXzUookQBm woV09l+yrL72oIAln553HDkaqBBLLO1nTrwJc9ZVJBQWADak13QxtzhQcARAE7xKHjgc WrhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k74-v6si20762739pgc.304.2018.06.10.20.31.16; Sun, 10 Jun 2018 20:31:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932591AbeFKDao (ORCPT + 99 others); Sun, 10 Jun 2018 23:30:44 -0400 Received: from gate.crashing.org ([63.228.1.57]:47585 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932328AbeFKDam (ORCPT ); Sun, 10 Jun 2018 23:30:42 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id w5B3TIbr013800; Sun, 10 Jun 2018 22:29:20 -0500 Message-ID: <07b804fccd7373c650be79ac9fa77ae7f2375ced.camel@kernel.crashing.org> Subject: Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices From: Benjamin Herrenschmidt To: Ram Pai , "Michael S. Tsirkin" Cc: Christoph Hellwig , robh@kernel.org, pawel.moll@arm.com, Tom Lendacky , aik@ozlabs.ru, jasowang@redhat.com, cohuck@redhat.com, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, joe@perches.com, "Rustad, Mark D" , david@gibson.dropbear.id.au, linuxppc-dev@lists.ozlabs.org, elfring@users.sourceforge.net, Anshuman Khandual Date: Mon, 11 Jun 2018 13:29:18 +1000 In-Reply-To: <20180611023909.GA5726@ram.oc3035372033.ibm.com> References: <20180522063317.20956-1-khandual@linux.vnet.ibm.com> <20180523213703-mutt-send-email-mst@kernel.org> <20180524072104.GD6139@ram.oc3035372033.ibm.com> <0c508eb2-08df-3f76-c260-90cf7137af80@linux.vnet.ibm.com> <20180531204320-mutt-send-email-mst@kernel.org> <20180607052306.GA1532@infradead.org> <20180607185234-mutt-send-email-mst@kernel.org> <20180611023909.GA5726@ram.oc3035372033.ibm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1 (3.28.1-2.fc28) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2018-06-10 at 19:39 -0700, Ram Pai wrote: > > However if the administrator > ignores/forgets/deliberatey-decides/is-constrained to NOT enable the > flag, virtio will not be able to pass control to the DMA ops associated > with the virtio devices. Which means, we have no opportunity to share > the I/O buffers with the hypervisor/qemu. > > How do you suggest, we handle this case? At the risk of repeating myself, let's just do the first pass which is to switch virtio over to always using the DMA API in the actual data flow code, with a hook at initialization time that replaces the DMA ops with some home cooked "direct" ops in the case where the IOMMU flag isn't set. This will be equivalent to what we have today but avoids having 2 separate code path all over the driver. Then a second stage, I think, is to replace this "hook" so that the architecture gets a say in the matter. Basically, something like: arch_virtio_update_dma_ops(pci_dev, qemu_direct_mode). IE, virtio would tell the arch whether the "other side" is in fact QEMU in a mode that bypasses the IOMMU and is cache coherent with the guest. This is our legacy "qemu special" mode. If the performance is sufficient we may want to deprecate it over time and have qemu enable the iommu by default but we still need it. A weak implementation of the above will be provied that just puts in the direct ops when qemu_direct_mode is set, and thus provides today's behaviour on any arch that doesn't override it. If the flag is not set, the ops are left to whatever the arch PCI layer already set. This will provide the opportunity for architectures that want to do something special, such as in our case, when we want to force even the "qemu_direct_mode" to go via bounce buffers, to put our own ops in there, while retaining the legacy behaviour otherwise. It also means that the "gunk" is entirely localized in that one function, the rest of virtio just uses the DMA API normally. Christoph, are you actually hacking "stage 1" above already or should we produce patches ? Cheers, Ben.