From patchwork Mon Apr 23 19:40:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 10358025 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8F2D8601BE for ; Mon, 23 Apr 2018 19:40:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7223D28C04 for ; Mon, 23 Apr 2018 19:40:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 66E1428C0F; Mon, 23 Apr 2018 19:40:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 990A028C04 for ; Mon, 23 Apr 2018 19:40:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932295AbeDWTkk (ORCPT ); Mon, 23 Apr 2018 15:40:40 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36574 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932292AbeDWTkk (ORCPT ); Mon, 23 Apr 2018 15:40:40 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D6E2401DEB0; Mon, 23 Apr 2018 19:40:39 +0000 (UTC) Received: from redhat.com (ovpn-123-116.rdu2.redhat.com [10.10.123.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id B89451C703; Mon, 23 Apr 2018 19:40:38 +0000 (UTC) Date: Mon, 23 Apr 2018 22:40:38 +0300 From: "Michael S. Tsirkin" To: Loic PALLARDY Cc: Anup Patel , "linux-remoteproc@vger.kernel.org" , Ohad Ben-Cohen , Bjorn Andersson , "virtualization@lists.linux-foundation.org" Subject: Re: virtio remoteproc device Message-ID: <20180423223717-mutt-send-email-mst@kernel.org> References: <20180420194321-mutt-send-email-mst@kernel.org> <1d7df45a692b42bd9d70462e0af63ca9@SFHDAG7NODE2.st.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1d7df45a692b42bd9d70462e0af63ca9@SFHDAG7NODE2.st.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 23 Apr 2018 19:40:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 23 Apr 2018 19:40:39 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mst@redhat.com' RCPT:'' Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Apr 23, 2018 at 08:55:57AM +0000, Loic PALLARDY wrote: > > > > -----Original Message----- > > From: linux-remoteproc-owner@vger.kernel.org [mailto:linux-remoteproc- > > owner@vger.kernel.org] On Behalf Of Anup Patel > > Sent: Sunday, April 22, 2018 6:08 AM > > To: Michael S. Tsirkin > > Cc: linux-remoteproc@vger.kernel.org; Ohad Ben-Cohen > > ; Bjorn Andersson ; > > virtualization@lists.linux-foundation.org > > Subject: Re: virtio remoteproc device > > > > On Fri, Apr 20, 2018 at 10:23 PM, Michael S. Tsirkin > > wrote: > > > Hello! > > > I note the following in the serial console: > > > > > > if (is_rproc_serial(vdev)) { > > > /* > > > * Allocate DMA memory from ancestor. When a virtio > > > * device is created by remoteproc, the DMA memory is > > > * associated with the grandparent device: > > > * vdev => rproc => platform-dev. > > > */ > > > if (!vdev->dev.parent || !vdev->dev.parent->parent) > > > goto free_buf; > > > buf->dev = vdev->dev.parent->parent; > > > > > > /* Increase device refcnt to avoid freeing it */ > > > get_device(buf->dev); > > > buf->buf = dma_alloc_coherent(buf->dev, buf_size, &buf->dma, > > > GFP_KERNEL); > > > } > > > > > > Added here: > > > commit 1b6370463e88b0c1c317de16d7b962acc1dab4f2 > > > Author: Sjur Brændeland > > > Date: Fri Dec 14 14:40:51 2012 +1030 > > > > > > virtio_console: Add support for remoteproc serial > > > > > > > > > I am not familiar with rproc so I have a question: > > > why is it required to use coherent memory here, > > > and why through a grandparent device? > > > > I faced similar issue when I tried VirtIO RPMSG bus over > > VirtIO MMIO transport. > > > > Here's my fix for VirtIO RPMSG bus driver: > > https://patchwork.kernel.org/patch/10155145/ > > Hi Anup and Michael, > > I pushed a series to modify virtio device allocation in remoteproc. Please see [1]. > It allows to remove allocation based on "grand-parent" device in the case of virtio device allocated by remoteproc. > Virto_console patch missing, only virtio_rpmsg modification proposed. I can add it in next version. > > Regards, > Loic > > [1] https://lkml.org/lkml/2018/3/1/644 > > > > > Regards, > > Anup > > -- > > To unsubscribe from this list: send the line "unsubscribe linux-remoteproc" in > > the body of a message to majordomo@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html So on top of your patches, can we just force use of DMA API and drop special casting? E.g. maybe something like the below - completely untested - patch? Does it work for you? --- To unsubscribe from this list: send the line "unsubscribe linux-remoteproc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 2108551..6c6767c 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -40,7 +40,8 @@ #include #include "../tty/hvc/hvc_console.h" -#define is_rproc_enabled IS_ENABLED(CONFIG_REMOTEPROC) +//#define is_rproc_enabled IS_ENABLED(CONFIG_REMOTEPROC) +#define is_rproc_enabled 0 /* * This is a global struct for storing common data for all the devices diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index b0633fd..4a13ca2 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -199,7 +199,7 @@ static u64 rproc_virtio_get_features(struct virtio_device *vdev) rsc = (void *)rvdev->rproc->table_ptr + rvdev->rsc_offset; - return rsc->dfeatures; + return rsc->dfeatures | (1ULL << VIRTIO_F_IOMMU_PLATFORM); } static int rproc_virtio_finalize_features(struct virtio_device *vdev) @@ -213,7 +213,7 @@ static int rproc_virtio_finalize_features(struct virtio_device *vdev) vring_transport_features(vdev); /* Make sure we don't have any features > 32 bits! */ - BUG_ON((u32)vdev->features != vdev->features); + //BUG_ON((u32)vdev->features != vdev->features); /* * Remember the finalized features of our vdev, and provide it