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 A9ACEC433EF for ; Sat, 23 Apr 2022 15:24:38 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wjz82kLj34F7yIFItRcr65kmowsU7rzz/VbsK/w0jYQ=; b=irxFXti7aMtPXxh8IKx0h/CCET RHB+pkxYKzkIwA3EQs+EC7avdq84QiACmNQFn+XwsrqA9VLgQlm3TbEDNdnz47T7kZcOKJnt7D2zf s5ApkQ1mlBuazE2rEgN/pMziewBLsTUVfrxW57kkl5qo9A+QoS+QBLNLKQqTHwOb4JGrbM1L+53Eo xKdaLpqm9swbGU8HXHkZ0saaacPNO2Dsg9J/8uIRjSWdy1/35zr4X9sGmbcqku6z3ZqQ/hUCC15eC S53+qA6EtjeY7RsdMP7VjSmHdmXwYPwQpKpiYsPkXpwlJs6qzuyCrWFFoG/0SEyNWCiMYziFpSJnd /MWIEDSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1niHbb-004WBp-IW; Sat, 23 Apr 2022 15:23:27 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1niHbX-004WAp-Vc for linux-arm-kernel@lists.infradead.org; Sat, 23 Apr 2022 15:23:25 +0000 Received: by mail-lj1-x232.google.com with SMTP id q14so12887077ljc.12 for ; Sat, 23 Apr 2022 08:23:22 -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=IrpG+O4O8YGPLjnEW6ym2q9Ak0YBISr2l1Uzmevi7UU=; b=IQIfElwQ6vipgSII8m7fw6jPT7ARLMUo+GYVfI8Knl2qwcFVEEhcFvD8Om4SSjKAx2 rhHWD/FD4idPYpw6gGmafqjLSO6s5PnKgRub3B+6obIRWzQnvSBJtyJQi3yrabfM/3YH nyMF8uDK1IRSsUIm9AaGjRtkUTA84vsuNJIwUvyB4GNP5y1x7sQZT+c8y4qqZ/6mHAet nubs7NGVFobqf7TGI1y4TrUGgxgSag+RI8iLIe9SEJTQyV0518eyYpKVLK3gEmGFlfzs i97+MmHFuoXsYprc+xZO4DAi1h+VcMtO3Ecc7KkUECH8yT0sSemR7hzD5vvLn3BlyJFZ JNuQ== 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=IrpG+O4O8YGPLjnEW6ym2q9Ak0YBISr2l1Uzmevi7UU=; b=wdLej/vEQnvFeS7j1I7D6FTZPvcfSsNWHA4Wuobs9gqesCY+7JM4TbvivL5j2ueuuW izihrFjzFQLvrU/q+vZNVIgEGf3jYU6RTxmwsbEeIZOK6SG5M48B6afMxV0R0HmIYdEZ abvrB24UqpKo14dxXQwaB2mPalIExwcU3nCEXAsjUeJY0iMModsMlzOVg+eyYnUoDqMw +M1v7qIldUQuF90UWE7zco7BOzH+FdzP6vnTdSJcoz96ALV72EP/xM/EZVfC9MSI6K7i bCmLWWrox4JC4JZTVrKClZVxQQNZ3pMsFYGU+UmWds1XQy2vWa2XW0JbKRtXh0h5qAzj ULyg== X-Gm-Message-State: AOAM532HlVgr3omJn+g4UpjjZ1u2qGQsvQBk7Yc4IkA7zLioK1/lS89X Rlh+9FVXzo2tjF3Z6rwRK18= X-Google-Smtp-Source: ABdhPJzDEm0kTMzLCkWHC07bFgwWAdrQLhfM8wiRtUiko+APIl1auVipAlGP2engdswsIY79u6w4jg== X-Received: by 2002:a2e:b537:0:b0:24f:9dc:28a6 with SMTP id z23-20020a2eb537000000b0024f09dc28a6mr637763ljm.509.1650727401488; Sat, 23 Apr 2022 08:23:21 -0700 (PDT) Received: from [192.168.1.7] ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id x22-20020a19e016000000b00471f7e4f09asm252577lfg.112.2022.04.23.08.23.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 23 Apr 2022 08:23:21 -0700 (PDT) Subject: Re: [PATCH V1 5/6] xen/grant-dma-ops: Retrieve the ID of backend's domain for DT devices 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: <1650646263-22047-1-git-send-email-olekstysh@gmail.com> <1650646263-22047-6-git-send-email-olekstysh@gmail.com> From: Oleksandr Message-ID: <6ac03d9f-a678-60e9-ca6e-fcbe1aee51d3@gmail.com> Date: Sat, 23 Apr 2022 18:23:19 +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-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220423_082324_086234_77F20D6A X-CRM114-Status: GOOD ( 28.08 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 23.04.22 02:00, Stefano Stabellini wrote: Hello Stefano > On Fri, 22 Apr 2022, Oleksandr Tyshchenko wrote: >> From: Oleksandr Tyshchenko >> >> Use the presence of recently introduced "xen,dev-domid" property >> in the device node as a clear indicator of enabling Xen grant >> mappings scheme for that device and read the ID of Xen domain where >> the corresponding backend resides. The ID (domid) is used as >> an argument to the Xen grant mapping APIs. >> >> Also introduce xen_is_grant_dma_device() to check whether xen-grant >> DMA ops need to be set for a passed device. >> >> Remove the hardcoded domid 0 in xen_grant_setup_dma_ops(). >> >> Signed-off-by: Oleksandr Tyshchenko >> --- >> Changes RFC -> V1: >> - new patch, split required changes from commit: >> "[PATCH 4/6] virtio: Various updates to xen-virtio DMA ops layer" >> - update checks in xen_virtio_setup_dma_ops() to only support >> DT devices for now >> - remove the "virtio,mmio" check from xen_is_virtio_device() >> - remane everything according to the new naming scheme: >> s/virtio/grant_dma >> --- >> drivers/xen/grant-dma-ops.c | 25 ++++++++++++++++++------- >> include/xen/xen-ops.h | 5 +++++ >> 2 files changed, 23 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/xen/grant-dma-ops.c b/drivers/xen/grant-dma-ops.c >> index 0e69aa8..70d5d77 100644 >> --- a/drivers/xen/grant-dma-ops.c >> +++ b/drivers/xen/grant-dma-ops.c >> @@ -66,11 +66,6 @@ static struct xen_grant_dma_data *find_xen_grant_dma_data(struct device *dev) >> * Such a DMA address is formed by using the grant reference as a frame >> * number and setting the highest address bit (this bit is for the backend >> * to be able to distinguish it from e.g. a mmio address). >> - * >> - * Note that for now we hard wire dom0 to be the backend domain. In order >> - * to support any domain as backend we'd need to add a way to communicate >> - * the domid of this backend, e.g. via Xenstore, via the PCI-device's >> - * config space or DT/ACPI. >> */ >> static void *xen_grant_dma_alloc(struct device *dev, size_t size, >> dma_addr_t *dma_handle, gfp_t gfp, >> @@ -277,6 +272,16 @@ static const struct dma_map_ops xen_grant_dma_ops = { >> .dma_supported = xen_grant_dma_supported, >> }; >> >> +bool xen_is_grant_dma_device(struct device *dev) >> +{ >> + /* XXX Handle only DT devices for now */ >> + if (!dev->of_node) >> + return false; >> + >> + return of_property_read_bool(dev->of_node, "xen,dev-domid"); >> +} >> +EXPORT_SYMBOL_GPL(xen_is_grant_dma_device); >> + >> void xen_grant_setup_dma_ops(struct device *dev) >> { >> struct xen_grant_dma_data *data; >> @@ -288,8 +293,14 @@ void xen_grant_setup_dma_ops(struct device *dev) >> return; >> } >> >> - /* XXX The dom0 is hardcoded as the backend domain for now */ >> - dev_domid = 0; >> + /* XXX ACPI and PCI devices unsupported for now */ >> + if (dev_is_pci(dev) || !dev->of_node) >> + goto err; > I think we can remove the "dev_is_pci" check, right? I think, yes (at least for now). I will remove the inclusion of #include as well. > > >> + if (of_property_read_u32(dev->of_node, "xen,dev-domid", &dev_domid)) { >> + dev_err(dev, "xen,dev-domid property is not present\n"); >> + goto err; >> + } >> >> data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); >> if (!data) { >> diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h >> index 4f9fad5..62be9dc 100644 >> --- a/include/xen/xen-ops.h >> +++ b/include/xen/xen-ops.h >> @@ -223,10 +223,15 @@ static inline void xen_preemptible_hcall_end(void) { } >> >> #ifdef CONFIG_XEN_GRANT_DMA_OPS >> void xen_grant_setup_dma_ops(struct device *dev); >> +bool xen_is_grant_dma_device(struct device *dev); >> #else >> static inline void xen_grant_setup_dma_ops(struct device *dev) >> { >> } >> +static inline bool xen_is_grant_dma_device(struct device *dev) >> +{ >> + return false; >> +} >> #endif /* CONFIG_XEN_GRANT_DMA_OPS */ >> >> #endif /* INCLUDE_XEN_OPS_H */ >> -- >> 2.7.4 >> >> >> _______________________________________________ >> linux-arm-kernel mailing list >> linux-arm-kernel@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel >> -- Regards, Oleksandr Tyshchenko _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel