Received: by 10.223.185.116 with SMTP id b49csp587312wrg; Wed, 21 Feb 2018 03:41:32 -0800 (PST) X-Google-Smtp-Source: AH8x226cvimi9nwRZfkqmFpvUrZEzL/5uta2/dESzEFpIh+pfgCKLOVtaSzr22k92W30PQQ/q2RK X-Received: by 2002:a17:902:7808:: with SMTP id p8-v6mr2936706pll.161.1519213292854; Wed, 21 Feb 2018 03:41:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519213292; cv=none; d=google.com; s=arc-20160816; b=DIomrLCMNaI6eE95XoTlXDu2ELptklY8ZEPF678ZSH90NZEB4HZrrmH64i3Y3/8SfS dq44PEZxS4VTO+Sbgd8gFGetX8n2UsEX5ywnMxKD8uftyDsNYY/EUBbZ7zqa6vGAnfZs de8v09ub3Cy++XQ6eKdZUaEOKXfVx/zpk+S1y9Nw16M1AgLyK+5brzjPFKsAwgw1QU0p 7xuD4vYYoGasqLGMLso3jgQ6EpPGpn5EqAxqCHfo5ZQmm6T0JV4bPm190I2KjIgl+jtr cmd3yTvPO44wdM+zepO7oWCMIynx28qRCvj/k85V9m23ZU7O4DgrRHivu3Ap78s0myhr Xbdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=sxZPIZMhznUN+XUYtcAMld7nS7kZ/cOhL4N6i0pnXrU=; b=JjW8FiphHDAi2iIkD5G7rLqbVwaFq66O7ZcqPEeTsskYn/Fb8OdYYUDGEj9jcUtJw2 LKoQONq/AimrlIR5zwTzSvE5ZZ6HLLIHAGmSyUx32Jx+ZvumJ6RKbA5y+MhRDIcYhIG1 WqcK4KIxjB1V5qWcPfo9ptnMijM7pviEIp4lkANT59z4+ZGha5cgiLpiDb8AhHvxMWCh ebZAuwX9QRljHtRHDrZFEnm6WaG9uklbkakDwMsGhiHGDoQSaKlJrmOEEHM+Nc2E77oF p5M1ozlVUTlqyBvbe1EJ7un5tii3r7u4CviR/5fBrmAbOxvhgrhuW9Wg55cqvMVrwJDW V1Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=zYeEgWrE; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a7-v6si809855pll.581.2018.02.21.03.41.18; Wed, 21 Feb 2018 03:41:32 -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; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=zYeEgWrE; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933585AbeBULk3 (ORCPT + 99 others); Wed, 21 Feb 2018 06:40:29 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:42529 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932538AbeBULk2 (ORCPT ); Wed, 21 Feb 2018 06:40:28 -0500 Received: by mail-wr0-f193.google.com with SMTP id k9so3560314wre.9 for ; Wed, 21 Feb 2018 03:40:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=sxZPIZMhznUN+XUYtcAMld7nS7kZ/cOhL4N6i0pnXrU=; b=zYeEgWrE0trKYfVwcX/owCMiVlZJm5Fb+JLK92Yz8bnCvnbrscTi54Q8Gvc7vO7bSG t73l4bfNF3Fn9ks6yyFXb3s7F8eA4wkN1mJjKUUeu3VDqcT1oszbarcwRpnxn7Z+xrAI z5Oge+2HBSstXRZBG1ZBIYlh7WG9rdouqyvLlMpC+kur5NP968DT2qAHAupyILuaSYYv zS5UP7NtOx9Wgei1Mv1FDyzlQYRsL1j2XIj1ICCVMFKQvdG/XVuwTUF9z9K5EeXqY5bB EaYLWu4MkZ6rUIdy5CoUY+TQzEPGjZu3X3O/bJyKNA4HHz8Th3685gAr1XrNgES/YzzI ZU/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=sxZPIZMhznUN+XUYtcAMld7nS7kZ/cOhL4N6i0pnXrU=; b=IGeVgF5J+It7tCuWWbBm+uJpECqQ7ihksHFnkTPPejKV1ksxzDxRG3R4MLKArsaX5Q Fl6lFUKJFLbOxzA3dvQP2VUqnxuDO6N5AZBIkD1gjvz8/Lvwb73a8ZfZtwv8SE2OWGW1 ItB265l5J3zJdhnl9Ec3k2Q1Ukm1YOEpoh2y++ZwCErdmzEeql5YC1JE0ncEZt0Y6XwE FAIKiR7v0Wv7rVv90Rxh5W2WUYBXnNDm3r5nf8gIs1B/whcqr9l/7wV98FtxnFPf2ACy 3WbPQab1BDX+4h1fAJvH+6CpRcHw8G6LpGvHNWOu59EwZUfmvrnAH6EEzO/ZGos2jdSP E7yg== X-Gm-Message-State: APf1xPBPTi7TjuJDFxBHSlVYZFaF7yHWErabwjZbWO1+iQt0opHGisRx qQLVepo+noh+zerVPZVAo0gJnkZP8LndBVFPqTe9zhos X-Received: by 10.223.150.102 with SMTP id c35mr2711389wra.225.1519213226594; Wed, 21 Feb 2018 03:40:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.134.170 with HTTP; Wed, 21 Feb 2018 03:40:26 -0800 (PST) In-Reply-To: <1515590217-24256-1-git-send-email-anup@brainfault.org> References: <1515590217-24256-1-git-send-email-anup@brainfault.org> From: Anup Patel Date: Wed, 21 Feb 2018 17:10:26 +0530 Message-ID: Subject: Re: [PATCH RESEND] rpmsg: virtio_rpmsg_bus: fix rpmsg_probe() for virtio-mmio transport To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, "linux-kernel@vger.kernel.org List" , Anup Patel , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 10, 2018 at 6:46 PM, Anup Patel wrote: > When virtio-rpmsg device is provided via virtio-mmio transport, the > dma_alloc_coherent() (called by rpmsg_probe()) fails on ARM/ARM64 > systems because "vdev->dev.parent->parent" device is used as parameter > to dma_alloc_coherent(). > > The "vdev->dev.parent->parent" device represents underlying remoteproc > platform device when virtio-rpmsg device is provided via virtio-remoteproc > transport. When virtio-rpmsg device is provided via virtio-mmio transport, > the "vdev->dev.parent->parent" device represents the parent device of > virtio-mmio platform device and dma_alloc_coherent() fails for this device > because generally there is no corresponding platform device and dma_ops > are not setup for "vdev->dev.parent->parent". > > This patch fixes dma_alloc_coherent() usage in rpmsg_probe() by trying > dma_alloc_coherent() with "vdev->dev.parent" device when it fails with > "vdev->dev.parent->parent" device. > > Fixes: b5ab5e24e960 ("remoteproc: maintain a generic child device for > each rproc") > > Signed-off-by: Anup Patel > Cc: stable@vger.kernel.org > --- > drivers/rpmsg/virtio_rpmsg_bus.c | 18 +++++++++++++----- > 1 file changed, 13 insertions(+), 5 deletions(-) > > diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c > index 82b8300..7f8710a 100644 > --- a/drivers/rpmsg/virtio_rpmsg_bus.c > +++ b/drivers/rpmsg/virtio_rpmsg_bus.c > @@ -64,6 +64,7 @@ > struct virtproc_info { > struct virtio_device *vdev; > struct virtqueue *rvq, *svq; > + struct device *bufs_dev; > void *rbufs, *sbufs; > unsigned int num_bufs; > unsigned int buf_size; > @@ -924,9 +925,16 @@ static int rpmsg_probe(struct virtio_device *vdev) > total_buf_space, &vrp->bufs_dma, > GFP_KERNEL); > if (!bufs_va) { > - err = -ENOMEM; > - goto vqs_del; > - } > + bufs_va = dma_alloc_coherent(vdev->dev.parent, > + total_buf_space, &vrp->bufs_dma, > + GFP_KERNEL); > + if (!bufs_va) { > + err = -ENOMEM; > + goto vqs_del; > + } else > + vrp->bufs_dev = vdev->dev.parent; > + } else > + vrp->bufs_dev = vdev->dev.parent->parent; > > dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n", > bufs_va, &vrp->bufs_dma); > @@ -988,7 +996,7 @@ static int rpmsg_probe(struct virtio_device *vdev) > return 0; > > free_coherent: > - dma_free_coherent(vdev->dev.parent->parent, total_buf_space, > + dma_free_coherent(vrp->bufs_dev, total_buf_space, > bufs_va, vrp->bufs_dma); > vqs_del: > vdev->config->del_vqs(vrp->vdev); > @@ -1023,7 +1031,7 @@ static void rpmsg_remove(struct virtio_device *vdev) > > vdev->config->del_vqs(vrp->vdev); > > - dma_free_coherent(vdev->dev.parent->parent, total_buf_space, > + dma_free_coherent(vrp->bufs_dev, total_buf_space, > vrp->rbufs, vrp->bufs_dma); > > kfree(vrp); > -- > 2.7.4 > Hi Bjorn, Can you please review this patch? Regards, Anup