Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2427750imu; Thu, 24 Jan 2019 12:34:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN5kRr7ak5m0vIpACZRV13gJLf+NIPu7DAUeteiEG8Slzbkst+G59rilVyY+0G12RL0QELQ8 X-Received: by 2002:a65:590b:: with SMTP id f11mr7378840pgu.60.1548362089874; Thu, 24 Jan 2019 12:34:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548362089; cv=none; d=google.com; s=arc-20160816; b=WGad1BHVOCGoMbSIYcViS7mKnCJyls3FIQ/PW+aQLN6xTzeGEvsUPYWrkCrB9kaC/E 1rxHI3TxzZNmYk6jinl/M+XckZKw9o9k5CMeFPLyxWYC4vG16ZP+bUNUKVAZk03rCTce 3JmhD5bYPhSnvqD0CIA/KJhq/sAO8Sn29XrlRqR+3Ym++Xcu3y28U2GNmqQoaJZHIGK9 32M4rDSg4cEeVoUzOBSi0Ry8oJYH74tQw9Nr6szP3EvHxx2IVAO7vtHyD/o6lMKXv6N0 wcmPQw8+fAhQUrynqcQueRSKFe01X01y5XMyh/iQICRhvFHxE/7glXh0RdljkOuVI05j Ldlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=gQVmZQBxaMlQacr8WT3XVvJE3ZIj1y41f1j+KD+khpU=; b=kVWRGElRiwJEvLxUp2yVQt33fqV1tiJoIfWuCwlUKPW05YvrGbGS6bSC+z1qd3svx/ LHSGa4BtynwNXkNugPWpyzbeU4IUYDauuWVNAMZvLctG+wxMLLG4483GRW/GNIGjJj8I j16ZYglk/+JbAS0ZUOfMl147KKRROlc4k3QETuAQHmG1bhou9yRpIoGJ4ZOynscN664p g3whvWVbMdFzrmu4hIGmDeRZLgkC4Pymc1nXwNpZvFxXU6YMMD9mfb1aCLIBEDW/osYI qX+Rzp3VCg1mY7jfJZuiI/GT+bkzIhqRSd6KM3/gJc5Sd26hYIrVCW0kTlJRCCd6/0jl SkHQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bh5si482420plb.42.2019.01.24.12.34.33; Thu, 24 Jan 2019 12:34:49 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727721AbfAXUe3 (ORCPT + 99 others); Thu, 24 Jan 2019 15:34:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43950 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726259AbfAXUe2 (ORCPT ); Thu, 24 Jan 2019 15:34:28 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18AD9AB43E; Thu, 24 Jan 2019 20:34:28 +0000 (UTC) Received: from redhat.com (ovpn-121-100.rdu2.redhat.com [10.10.121.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B4681001F4A; Thu, 24 Jan 2019 20:34:26 +0000 (UTC) Date: Thu, 24 Jan 2019 15:34:25 -0500 From: "Michael S. Tsirkin" To: Stefano Stabellini Cc: Peng Fan , "hch@infradead.org" , "jasowang@redhat.com" , "xen-devel@lists.xenproject.org" , "linux-remoteproc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "luto@kernel.org" , "jgross@suse.com" , "boris.ostrovsky@oracle.com" , "bjorn.andersson@linaro.org" , "jliang@xilinx.com" Subject: Re: [Xen-devel] [RFC] virtio_ring: check dma_mem for xen_domain Message-ID: <20190124145849-mutt-send-email-mst@kernel.org> References: <20190121050056.14325-1-peng.fan@nxp.com> <20190123071232.GA20526@infradead.org> <20190123211405.GA4971@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 24 Jan 2019 20:34:28 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 24, 2019 at 11:14:53AM -0800, Stefano Stabellini wrote: > On Thu, 24 Jan 2019, Peng Fan wrote: > > Hi stefano, > > > > > -----Original Message----- > > > From: Stefano Stabellini [mailto:sstabellini@kernel.org] > > > Sent: 2019年1月24日 7:44 > > > To: hch@infradead.org > > > Cc: Stefano Stabellini ; Peng Fan > > > ; mst@redhat.com; jasowang@redhat.com; > > > xen-devel@lists.xenproject.org; linux-remoteproc@vger.kernel.org; > > > linux-kernel@vger.kernel.org; virtualization@lists.linux-foundation.org; > > > luto@kernel.org; jgross@suse.com; boris.ostrovsky@oracle.com; > > > bjorn.andersson@linaro.org; jliang@xilinx.com > > > Subject: Re: [Xen-devel] [RFC] virtio_ring: check dma_mem for xen_domain > > > > > > On Wed, 23 Jan 2019, hch@infradead.org wrote: > > > > On Wed, Jan 23, 2019 at 01:04:33PM -0800, Stefano Stabellini wrote: > > > > > If vring_use_dma_api is actually supposed to return true when > > > > > dma_dev->dma_mem is set, then both Peng's patch and the patch I > > > > > wrote are not fixing the real issue here. > > > > > > > > > > I don't know enough about remoteproc to know where the problem > > > > > actually lies though. > > > > > > > > The problem is the following: > > > > > > > > Devices can declare a specific memory region that they want to use > > > > when the driver calls dma_alloc_coherent for the device, this is done > > > > using the shared-dma-pool DT attribute, which comes in two variants > > > > that would be a little to much to explain here. > > > > > > > > remoteproc makes use of that because apparently the device can only > > > > communicate using that region. But it then feeds back memory obtained > > > > with dma_alloc_coherent into the virtio code. For that it calls > > > > vmalloc_to_page on the dma_alloc_coherent, which is a huge no-go for > > > > the ĐMA API and only worked accidentally on a few platform, and > > > > apparently arm64 just changed a few internals that made it stop > > > > working for remoteproc. > > > > > > > > The right answer is to not use the DMA API to allocate memory from a > > > > device-speficic region, but to tie the driver directly into the DT > > > > reserved memory API in a way that allows it to easilt obtain a struct > > > > device for it. > > > > > > If I understand correctly, Peng should be able to reproduce the problem on > > > native Linux without any Xen involvement simply by forcing > > > vring_use_dma_api to return true. Peng, can you confirm? > > > > It is another issue without xen involvement, > > There is an thread talking this: https://patchwork.kernel.org/patch/10742923/ > > > > Without xen, vring_use_dma_api will return false. > > With xen, if vring_use_dma_api returns true, it will dma_map_xx and trigger dump. > > It is true that for Xen on ARM DomUs it is not necessary today to return > true from vring_use_dma_api. However, returning true from > vring_use_dma_api should not break Linux. When the rpmesg issue is > fixed, this problem should also go away without any need for additional > changes on the xen side I think. Let less systems bypass the standard virtio logic (using feature bit to figure out bypassing DMA API), the better.