Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3737249imm; Mon, 30 Jul 2018 02:31:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf2QAoemh3BFKdhJATSTpUIN0hkQFeLwqpN14cO4DLGFrjQQ8CHYTekUQ6IMOTXD8ELvAUR X-Received: by 2002:a63:5fc1:: with SMTP id t184-v6mr15196932pgb.183.1532943095037; Mon, 30 Jul 2018 02:31:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532943095; cv=none; d=google.com; s=arc-20160816; b=VPb12J8ccxkYzag9qeBokJPI0GZeweY0ngb1TZJWqraXedyph1EhIFrnAH8aMY5Bo9 dQQiPDTe1YEW6rlJGEjenFyI62bjxKlnhVDHim5Sc1gUSJ8WyyJqHU4eydQUA4l6pEHp 3kDtnY5q/wEopAjurnB+pi0hU0GG5S/Mh3FtiB/rLzI3M2wM1qS0xVAnZNmOmuzgU0NF xnBhrjOh9OFPFM5y2dO3hSQS++NW1BZdNSYXnKPOLAQMn2fX4A6QHSkbMQJFzdOzK755 0spJ26z0DaTxu0w/u3nCwSJr/WfCcHAhB0lSGkF3hmP3KSpigjC3gl3VVOBa3ghHbXBh trOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=4Mtj6FBl3NXN0/tkjyoe5svduQp58RO6IseEvxhta/E=; b=Ya6RResDUvLwEPNRwr5lFVUJlYP83Nz2FSXSL4hV/3kvdH30hizUyj/yyMn3SGzbTy YA0a3AEUmXO66aExiLX/rz1FLAkl/OI5RfQBr2sOhBXTnu5txt7uFtq0QhSO0y+u6kHe clFNlrzWKsvQy2/o8aDDXLeB8b0yhQ4e+5zVu7Gq3bPBc/yI4e8m45R6HCT3oyXDrmlr QiwZ8g0M/yGRyY9SOQpgZj6Rk0ijk0xzMZI6Hvp5LWhdqfLhHTEFgeG+fKGEscQ7AkJJ V02MfAhd71hmmm6Sl72/5wC4VDhIwLESeqmy26Wwa9d6VmuVr4oR1UhtTLjpOHgDvD1l +7/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=qjVZ7Prj; 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 c25-v6si10515476pgm.523.2018.07.30.02.31.20; Mon, 30 Jul 2018 02:31:35 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=qjVZ7Prj; 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 S1726820AbeG3LEg (ORCPT + 99 others); Mon, 30 Jul 2018 07:04:36 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:34836 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726778AbeG3LEf (ORCPT ); Mon, 30 Jul 2018 07:04:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=4Mtj6FBl3NXN0/tkjyoe5svduQp58RO6IseEvxhta/E=; b=qjVZ7Prjgd/QjCeQBr5OILh6P 9JrXFukfEAClm0CGEJKbcO1/K4jLnj9nZBx8Y8ODtY/cNKEkhuZHCGRTbeNd0sL/HPykW+k8kLdCM 8xBQEiRBfP9SxO6PjOzA+YSwzIs0DjU+IyRw4PwhaAvOMhEWfrwVB0SDIzbkUBaq11JH1mad0Cd6A QmGm/9MQLSWyxcDrr1C9g83kug8XG77RBgtULMUnCtFIH/gAfHl2CvmmYtB4n4Vz7438syLY4Vdy8 UTzTy+Pcf9U8iARbjspPRuTg0YiX+r6Daxq+XEWzgkEWLFYMrWz9IMmS2NGfwO1uSwLj3ckEWRh5R XUk8LXAkA==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fk4VX-0002fP-8w; Mon, 30 Jul 2018 09:30:27 +0000 Date: Mon, 30 Jul 2018 02:30:27 -0700 From: Christoph Hellwig To: "Michael S. Tsirkin" Cc: Anshuman Khandual , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, aik@ozlabs.ru, robh@kernel.org, joe@perches.com, elfring@users.sourceforge.net, david@gibson.dropbear.id.au, jasowang@redhat.com, benh@kernel.crashing.org, mpe@ellerman.id.au, hch@infradead.org, linuxram@us.ibm.com, haren@linux.vnet.ibm.com, paulus@samba.org, srikar@linux.vnet.ibm.com Subject: Re: [RFC 2/4] virtio: Override device's DMA OPS with virtio_direct_dma_ops selectively Message-ID: <20180730093027.GC26245@infradead.org> References: <20180720035941.6844-1-khandual@linux.vnet.ibm.com> <20180720035941.6844-3-khandual@linux.vnet.ibm.com> <20180729001344-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180729001344-mutt-send-email-mst@kernel.org> User-Agent: Mutt/1.9.2 (2017-12-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > + > > + if (xen_domain()) > > + goto skip_override; > > + > > + if (virtio_has_iommu_quirk(dev)) > > + set_dma_ops(dev->dev.parent, &virtio_direct_dma_ops); > > + > > + skip_override: > > + > > I prefer normal if scoping as opposed to goto spaghetti pls. > Better yet move vring_use_dma_api here and use it. > Less of a chance something will break. I agree about avoid pointless gotos here, but we can do things perfectly well without either gotos or a confusing helper here if we structure it right. E.g.: // suitably detailed comment here if (!xen_domain() && !virtio_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM)) set_dma_ops(dev->dev.parent, &virtio_direct_dma_ops); and while we're at it - modifying dma ops for the parent looks very dangerous. I don't think we can do that, as it could break iommu setup interactions. IFF we set a specific dma map ops it has to be on the virtio device itself, of which we have full control.