Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1016093pxb; Fri, 22 Apr 2022 16:53:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEK4QwnCkgKUgmqmfe+cdiHBF8zFi7uJ5HcfD0/aMrR9556jyfpmGyFlboZGsWFs81h9AR X-Received: by 2002:a17:90a:3d02:b0:1ca:7f92:1bf1 with SMTP id h2-20020a17090a3d0200b001ca7f921bf1mr18955835pjc.177.1650671594682; Fri, 22 Apr 2022 16:53:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650671594; cv=none; d=google.com; s=arc-20160816; b=kDmy8FXYeNozqaYHpC0yzzNmXSTeQCwpUhYk6Gu/lEtWfEx+5ICShAG6vUAd6Z7+tw 45rEvtpU7IaUF9WqkWQCgmvvBowZ/PBGvJuZcjKoGZtw8i74ufzMN1eqG6df6A2soq0Q 7q84ed+tNKp2reUObgwbU/cy2VFs9htT0Rk8iZWdCr9VWfu0dUQt0AA8QId7+kYJg1Wv Ub/Q9FoydZGHDFK4/XomcJG+wzVShPzhsKWwYrDhMIggmjAPUEYZ6tFPmx081n1lYbBv YXrt2s1KRdukLFPf55hWHHo2nH0E5DBHoBWO8AmKp6LyidC3tj4UzfOmIaOat4d8Ni6G 2BDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=bjXR9jYEt7mH+CFMtmwQH+VLcOsw7ASq8Ewss5YWxas=; b=DXkcWPRNs0c8dPAXFQi5ud83E9L2233JlBFXRR8Nv+wgaDN3gMIp2b/vx64qzhEQYB T1ACBWcTiQGuvyYkItZVtYpP3aIVT/pslVZPkJMKC6B7wH4/7JLF8zhuSY2TUuSnbj59 plG4KZbMWSxd8Im7+rJgiOgWDH/8ENv2V+wJxahVwFg/qeCE8sTzi4dVmLlpqCqhngLf 0y+lXHSPrNxhYK9G1iZOvA1mvjvcCcyCRO/43gEkiEKsZB+q2VYWuCtJ/t28E/ATXx24 Csb+PF1gmL18muefRFkUsm7F2OiwEH/FIc2SZx4ugXj++k07MXM+hBLhm8c+yb2XIavO JXig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=chdUsvXd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k4-20020a056a00134400b00505ad6b7610si9532960pfu.63.2022.04.22.16.53.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 16:53:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=chdUsvXd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9F33C5D659; Fri, 22 Apr 2022 16:23:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229535AbiDVXZx (ORCPT + 99 others); Fri, 22 Apr 2022 19:25:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231159AbiDVXZ0 (ORCPT ); Fri, 22 Apr 2022 19:25:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C3EC65CC for ; Fri, 22 Apr 2022 16:00:49 -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 D88F0B83302 for ; Fri, 22 Apr 2022 23:00:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE5F5C385A0; Fri, 22 Apr 2022 23:00:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650668446; bh=EG9Sat3nnlct87XJ7aI6xJ/IJzxF9nLDysqX+nVR4hI=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=chdUsvXdzye2ukDSePy0mN4FkH+KKMIU3Nycg5slUUctlXi2Hk1aYXRlJIlnhy3y5 /E7IR/cJtDDSGBTMVb0qqR21/7RpTMti9lQFp175AjdHQotbT0LUgHKUgkMzRjcTW9 HQdUEU909dGByOZd+NPKzTpKgzU2A3UI1DjHphnRS9zrbO+SWdg+zbgirJzXDXhaXX 9S+g84qZB7TdhBayLnzZWRYTxPiEhexK2KxcsIBkayp49QkOLjxZa8RBL5C5So3aBB 9uEUn8V7vres4ULlqLLJGN2d7pmknP3OQaXPYV/nGhRSDL/a6wZyrRu8cuszTbjEJU pcfhqO/x6ocNw== Date: Fri, 22 Apr 2022 16:00: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 , Stefano Stabellini , Boris Ostrovsky , Juergen Gross , Julien Grall , "Michael S. Tsirkin" , Christoph Hellwig Subject: Re: [PATCH V1 5/6] xen/grant-dma-ops: Retrieve the ID of backend's domain for DT devices In-Reply-To: <1650646263-22047-6-git-send-email-olekstysh@gmail.com> Message-ID: References: <1650646263-22047-1-git-send-email-olekstysh@gmail.com> <1650646263-22047-6-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 X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 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? > + 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 >