From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EFF2C433EF for ; Fri, 15 Apr 2022 22:02:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356256AbiDOWFT (ORCPT ); Fri, 15 Apr 2022 18:05:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232305AbiDOWFS (ORCPT ); Fri, 15 Apr 2022 18:05:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84D4E3AA60 for ; Fri, 15 Apr 2022 15:02:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3BDD4B8311F for ; Fri, 15 Apr 2022 22:02:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B080C385A4; Fri, 15 Apr 2022 22:02:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650060165; bh=jMIyyGQ4CRdsA1X7oxI8CTQb0IBKbJqeD84G5GJpvrs=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=DXvqR0Keim+tfwUUwYyM6574yaiWEcj28C/cHng/0XCSegk9hetkQruScA8hrYQlS /ZD/C1AjvTcFvA+XXBN77pc/acwLax0/RDIpW6c218usILvr5ehxi1F/0eyj6WXzi0 O1cDrfH+NOQVSkSKclpyrjWv3CIlYFatU0R4G+J4pyaE20kPRekBJxB7JLzPqRIi6V 30Zgqtkgwwv4XNEXn71dvq+Z2MUUCB9bMJs4PyIAj1Q+y/GnNOBNaGU0Est8neT7EQ qOK3sD4Gg9vLArJLSsNa+wTCI6qfW56EyOoPpLezZK1AlyLe43X1zlkbJFNu3ymWJS /vTcXwOaDkD2w== Date: Fri, 15 Apr 2022 15:02:45 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@ubuntu-linux-20-04-desktop To: Oleksandr Tyshchenko cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Oleksandr Tyshchenko , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Julien Grall Subject: Re: [RFC PATCH 6/6] arm/xen: Assign xen-virtio DMA ops for virtio devices in Xen guests In-Reply-To: <1649963973-22879-7-git-send-email-olekstysh@gmail.com> Message-ID: References: <1649963973-22879-1-git-send-email-olekstysh@gmail.com> <1649963973-22879-7-git-send-email-olekstysh@gmail.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 14 Apr 2022, Oleksandr Tyshchenko wrote: > From: Oleksandr Tyshchenko > > Call xen_virtio_setup_dma_ops() only for Xen-aware virtio devices > in Xen guests if restricted access to the guest memory is enabled. > > Signed-off-by: Oleksandr Tyshchenko > --- > include/xen/arm/xen-ops.h | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/include/xen/arm/xen-ops.h b/include/xen/arm/xen-ops.h > index 621da05..28b2ad3 100644 > --- a/include/xen/arm/xen-ops.h > +++ b/include/xen/arm/xen-ops.h > @@ -2,12 +2,19 @@ > #ifndef _ASM_ARM_XEN_OPS_H > #define _ASM_ARM_XEN_OPS_H > > +#include > #include > +#include > > static inline void xen_setup_dma_ops(struct device *dev) > { > if (xen_swiotlb_detect()) > dev->dma_ops = &xen_swiotlb_dma_ops; > + > +#ifdef CONFIG_XEN_VIRTIO > + if (arch_has_restricted_virtio_memory_access() && xen_is_virtio_device(dev)) > + xen_virtio_setup_dma_ops(dev); > +#endif This makes sense overall. Considering that the swiotlb-xen case and the virtio case are mutually exclusive, I would write it like this: if (arch_has_restricted_virtio_memory_access() && xen_is_virtio_device(dev)) xen_virtio_setup_dma_ops(dev); else if (xen_swiotlb_detect()) dev->dma_ops = &xen_swiotlb_dma_ops; There is no need for #ifdef (also see other comments). From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BB776C433F5 for ; Fri, 15 Apr 2022 22:12:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:Message-ID: In-Reply-To:Subject:cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QMVfzZ9+2+q8TQoYp7HDc5YJXi874m4CXaj9owC2+IA=; b=MFU3kfNySodZUw y248DssPoqvXTUbCcrdztY1VWb+16HFUOJdIKuUhB6zoIKlqd9c2hYNlimKy8GzuyJhgO6PVgDh2+ pUkJNjsS4Nzr+MI0bPYAE0G/uhifuuF6jWS45EvcXxX437sltBoCRAF4q4yCKr0INe0O5G4TZpyVj f8ar1LxNfy13gZ5c/juPv7NHXkwk5z+aHoM9QdE6NXYfhgWSuVrUHAIR3n5YxSugxpaMx59Fq3J4U 9dwUarTGdluxamkt464fHEkiZ4bhHwcrMF1B5kPVx/XN3jHGAw2lXDWSPMbJ13b2DInMqkY7Lhoe6 YOGCucl6jzdgbNQnWPIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nfU9l-00BWwL-LG; Fri, 15 Apr 2022 22:11:10 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nfU1g-00BTg2-Gj for linux-arm-kernel@lists.infradead.org; Fri, 15 Apr 2022 22:02:50 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2682CB82BAA; Fri, 15 Apr 2022 22:02:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B080C385A4; Fri, 15 Apr 2022 22:02:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650060165; bh=jMIyyGQ4CRdsA1X7oxI8CTQb0IBKbJqeD84G5GJpvrs=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=DXvqR0Keim+tfwUUwYyM6574yaiWEcj28C/cHng/0XCSegk9hetkQruScA8hrYQlS /ZD/C1AjvTcFvA+XXBN77pc/acwLax0/RDIpW6c218usILvr5ehxi1F/0eyj6WXzi0 O1cDrfH+NOQVSkSKclpyrjWv3CIlYFatU0R4G+J4pyaE20kPRekBJxB7JLzPqRIi6V 30Zgqtkgwwv4XNEXn71dvq+Z2MUUCB9bMJs4PyIAj1Q+y/GnNOBNaGU0Est8neT7EQ qOK3sD4Gg9vLArJLSsNa+wTCI6qfW56EyOoPpLezZK1AlyLe43X1zlkbJFNu3ymWJS /vTcXwOaDkD2w== Date: Fri, 15 Apr 2022 15:02:45 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@ubuntu-linux-20-04-desktop To: Oleksandr Tyshchenko cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Oleksandr Tyshchenko , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Julien Grall Subject: Re: [RFC PATCH 6/6] arm/xen: Assign xen-virtio DMA ops for virtio devices in Xen guests In-Reply-To: <1649963973-22879-7-git-send-email-olekstysh@gmail.com> Message-ID: References: <1649963973-22879-1-git-send-email-olekstysh@gmail.com> <1649963973-22879-7-git-send-email-olekstysh@gmail.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220415_150248_783136_909EF529 X-CRM114-Status: GOOD ( 17.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 14 Apr 2022, Oleksandr Tyshchenko wrote: > From: Oleksandr Tyshchenko > > Call xen_virtio_setup_dma_ops() only for Xen-aware virtio devices > in Xen guests if restricted access to the guest memory is enabled. > > Signed-off-by: Oleksandr Tyshchenko > --- > include/xen/arm/xen-ops.h | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/include/xen/arm/xen-ops.h b/include/xen/arm/xen-ops.h > index 621da05..28b2ad3 100644 > --- a/include/xen/arm/xen-ops.h > +++ b/include/xen/arm/xen-ops.h > @@ -2,12 +2,19 @@ > #ifndef _ASM_ARM_XEN_OPS_H > #define _ASM_ARM_XEN_OPS_H > > +#include > #include > +#include > > static inline void xen_setup_dma_ops(struct device *dev) > { > if (xen_swiotlb_detect()) > dev->dma_ops = &xen_swiotlb_dma_ops; > + > +#ifdef CONFIG_XEN_VIRTIO > + if (arch_has_restricted_virtio_memory_access() && xen_is_virtio_device(dev)) > + xen_virtio_setup_dma_ops(dev); > +#endif This makes sense overall. Considering that the swiotlb-xen case and the virtio case are mutually exclusive, I would write it like this: if (arch_has_restricted_virtio_memory_access() && xen_is_virtio_device(dev)) xen_virtio_setup_dma_ops(dev); else if (xen_swiotlb_detect()) dev->dma_ops = &xen_swiotlb_dma_ops; There is no need for #ifdef (also see other comments). _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel