Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2260739pxb; Sun, 17 Apr 2022 16:17:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwH7Q9v9wSLHYIf3mIklZTP3/+/IJcWpMSEYW5pw5aUi0RS1I2TxY+JnP01z4a96PzEIY4U X-Received: by 2002:a17:906:66c8:b0:6e8:8b06:1b32 with SMTP id k8-20020a17090666c800b006e88b061b32mr6924767ejp.236.1650237430984; Sun, 17 Apr 2022 16:17:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650237430; cv=none; d=google.com; s=arc-20160816; b=akt9x+HZvEW16r/5O5CaTjreAXHFD3QmpQ5f7dFWZd8gixM8BF8i/9ygeRPyo1TFXD awLhOhbT79tht/X65UISdAyxB3I1p7QvNcw0zHp4zCpj3yIyzs5yQZ9lK6Px/Z9SAOtr l4R3yiwv0hKzrq8vi8318JlL9Lqnz2VxeZrfHA9Zo8e5ZtU3yWmR6d19nZQUy6flb7zt uEsIkD8tYK/WuKIsLTtlRJU/u/WxYVzf6kqR/TsJET6zW/TaiDnVdUSylD4b44yAKDFv o57/I4MiCI3E9HuVdap0wgZfHD7uxPU/65mFUAojIk3khhkpaHkwkfzTKODcZURFGQ/A fs/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=UX+UJJi6cm6n3siakzXlqA7VdWeUuC0amPEI0CKnoy8=; b=iLBFXsNN4C1sv68eT6sapdiHNUMYCUyKbZqZ8VkPGwg3Y59xv+8Pk/T6otnU5qMhEy RTtwu84ZI2lWn9WO4WPPvIYqrfGD7V54y7R3N1YlZGWFnmstMUddzXbUWkMRefo5f+de mMEXtxBEBVM+Dr70a+o/1YVwR6D1c7xzqKk6IAM+mfvuauG7RKfTCH7mJxNNbWqW2afO C8QQoFFfRWplPYRcr1ZtgXD95DKImmRPS5T2zKvoZ4kzuF0fL58pnx9zD4adTo1/NGS+ 1xrVuJ46wLy28RAMpr0kcNX3PXF7letqHZ2iDS2fIEeSJRCYP3V24SnxWwddUF6dUB/D 09CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=anmuYIHM; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gy13-20020a170906f24d00b006e865dbaf29si4943882ejb.16.2022.04.17.16.16.47; Sun, 17 Apr 2022 16:17:10 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=anmuYIHM; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234905AbiDQTWo (ORCPT + 99 others); Sun, 17 Apr 2022 15:22:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232144AbiDQTWn (ORCPT ); Sun, 17 Apr 2022 15:22:43 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DC0162D2 for ; Sun, 17 Apr 2022 12:20:07 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id x33so21486791lfu.1 for ; Sun, 17 Apr 2022 12:20:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=UX+UJJi6cm6n3siakzXlqA7VdWeUuC0amPEI0CKnoy8=; b=anmuYIHMR44DHUBsKUVkyea2mPIgGJA1WVaLfL42XbsYHNLQ0QX5zF1vmXuveOfZa4 TlIHgkTCOoYjOOVnzvPRkPqi+LYsmZYW7I9daLrolOUzGvJlP00NxPg1O42tKDiJdj3F W9UfoOoRhm9POPkypEpow7p+m6+WvsPwt0uKdYh6rfDXjumAupEnI2eqJ5bvdLrMXSrC Cydz5opZP1kh8wO33oIdvdQNglyjqHQLYMwCMFJqbSQLDJLtzHIrpnxoZKpVTXJ6x3oS ln3RXLd9fG/Z8R9g6sIQ9UgqXuc/KTif0O4MOzEsU4QUu9/7gdRIRnOzt0xx7Xe7vU1v 3hVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=UX+UJJi6cm6n3siakzXlqA7VdWeUuC0amPEI0CKnoy8=; b=pGNA3JB767d77WW52sF7A4xhYsx4M8BqQNaF/ZVD3MaNTuWvz//11fGAmiCKw6fu9o 4bgXcT/IileL2xmosB1ffIy9phFWZpbcTdEzSY0iRvPyI/3/nnjE+YtJ2CF4w6X82k74 ff1epwBM8oQQLs24gq27ySWfX/tnoB8bdjy0mQKD76PDbSH3NOgN5WRsZr4vAv58zUMf mVJ29dMDZatgP/4AeW7rPgY1S7o1IMSxVeh+L92VPkF/mPt2ExAPMACWTmz8FMIhEBAn BTopJCJTzj4FtH/2V/JQeMPbcFDUEwUfEULDHwMy0fZAjvIx/v7XO5d41BpTSFeZHrPH FEXA== X-Gm-Message-State: AOAM531OtGVmYKhsLsUZt+UolUiej3TnYXA41fg790nscM89A5iK+H0g 9JuBzdqb+Mpgw2jjMrG/hJY= X-Received: by 2002:a05:6512:c21:b0:471:9935:f8f2 with SMTP id z33-20020a0565120c2100b004719935f8f2mr35608lfu.650.1650223205568; Sun, 17 Apr 2022 12:20:05 -0700 (PDT) Received: from [192.168.1.7] ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id f3-20020a056512322300b0046bbce218f2sm1005348lfe.79.2022.04.17.12.20.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 17 Apr 2022 12:20:05 -0700 (PDT) Subject: Re: [RFC PATCH 6/6] arm/xen: Assign xen-virtio DMA ops for virtio devices in Xen guests To: Stefano Stabellini Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Oleksandr Tyshchenko , Boris Ostrovsky , Juergen Gross , Julien Grall , "Michael S. Tsirkin" , Christoph Hellwig References: <1649963973-22879-1-git-send-email-olekstysh@gmail.com> <1649963973-22879-7-git-send-email-olekstysh@gmail.com> From: Oleksandr Message-ID: <8df1dc60-614a-67fa-3a9d-e2db4a7e0132@gmail.com> Date: Sun, 17 Apr 2022 22:20:04 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 16.04.22 01:02, Stefano Stabellini wrote: Hello Stefano > 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. thank you > 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; Agree, will do > > There is no need for #ifdef (also see other comments). Agree, if !CONFIG_XEN_VIRTIO then xen_virtio_ are just stubs. #ifdef CONFIG_XEN_VIRTIO void xen_virtio_setup_dma_ops(struct device *dev); bool xen_is_virtio_device(struct device *dev); #else static inline void xen_virtio_setup_dma_ops(struct device *dev) { } static inline bool xen_is_virtio_device(struct device *dev) {     return false; } #endif /* CONFIG_XEN_VIRTIO */ -- Regards, Oleksandr Tyshchenko