Received: by 10.223.176.46 with SMTP id f43csp4187467wra; Tue, 23 Jan 2018 05:46:58 -0800 (PST) X-Google-Smtp-Source: AH8x225gg9C/sszTHaygJgKsDE06tJvZQNZN0uN+hriuSDaGLs3SD2sIxxr0rGwA55haM58DJrWi X-Received: by 10.101.101.144 with SMTP id u16mr8747655pgv.73.1516715218011; Tue, 23 Jan 2018 05:46:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516715217; cv=none; d=google.com; s=arc-20160816; b=szWB6i5PbfDFi4NCGHuQPKsIRBhhSsqLnokHljlK6QG0JCp1mgb7adrKl55yfw0NQo 4v/iAa2rkY0CZHS8b6WTCbg38guSU9YtcdNkA8KwJiwxDSDYVJwtUa4SrbYVfTsuFqN+ D69LsPwDsyjhZ3SEGSUlzVO1VHqJvvQQ+7MoX3ScF2Npa8afQ33V8ffEldc596xjuIVZ pir/avYiM+d9KK7EYfOI3AK0xWlAE+1hgkyqNWwH7q0Mkeggt3ndr1ASWKj2/hTbQzez VGV57ybfn6ycpeLgFwCTg7AapRyCSmCWT+2BgiXnUTfxmmtC4mvuzX02Vqy2B/zXPe9D l+YA== 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=XUFRdRjl9tfon4G8F5t4/po3c86Y3W+3wDqT38EwrbM=; b=DhbTqKu9sNwqwhkF0BA5YhLxXHgH0IWzR4GEU+NDUV4zTi8RyOmecgsJ3s2+S/tdSi uZax5secupcrL6Yul6Obzuoza1FkxAHPX1hQ+DbkeAi/ja9hmZtiZmDnLaQO1mAbZPQD Jkpkea04BO/K7nidbdjL/IVKRsZkH7NRs8akiboUTfY31P6TD9OOZgLcocDtUecbs8UJ 5K8mQHFRqtTEBqSYb8gTiTxZBhsZZ7uqiVurux0LnvFCgTPCeoinSZb3Pr624Oq24a4p rvpZT9OcopU/jslhZvL0359afS/lf64go/vBqNZfffSFGvkhb/LOLBqu1Fp4qMVMFI7m xxAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=T8PiCnvx; 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 b3-v6si929065plx.805.2018.01.23.05.46.42; Tue, 23 Jan 2018 05:46:57 -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=T8PiCnvx; 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 S1751612AbeAWNqR (ORCPT + 99 others); Tue, 23 Jan 2018 08:46:17 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:37548 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751437AbeAWNqP (ORCPT ); Tue, 23 Jan 2018 08:46:15 -0500 Received: by mail-wr0-f196.google.com with SMTP id f11so623131wre.4 for ; Tue, 23 Jan 2018 05:46:14 -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=XUFRdRjl9tfon4G8F5t4/po3c86Y3W+3wDqT38EwrbM=; b=T8PiCnvxas0iRCCpHOQocH3vbpF4IF3ZCzyNfeTy8QY+VhizodzyvoINdlM4pJbVsW ycbA9wfrompqFn0RIDJRVF+P8DYNzZotqQyODciydQ6wwnYFkDj3fDv/Ck4g2N5KYhtz gzCdlN2xn9B9K711MNYZi9/FkIFlg6yeBv8adIdP410UNjBH37luRDzef1HSq4wdw/Kh vdrAugQ2g6FSXwz8Uh0vOeaUbAeKIFTcTrepHIL/+BA/40R52Z2IAruaM1CcN76IasGm 3xorl5OdVr9Vl4j2U2e+KjP2HxrxckaVcPsq3ANp72Cl6hHnjm6y2TabFHQRlWZhX426 j6mg== 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=XUFRdRjl9tfon4G8F5t4/po3c86Y3W+3wDqT38EwrbM=; b=FbgQdB41KHQENzLKR+bZB2OHP5XVdHphzeOiHksjCxKQz2CBuZah5NjKgs2HEAwKw4 Jp9qY9uZ8IfqSxj4la0TxBQecvf3jlVma8J6h7lP4O61d7xiT+ggJo6U62ECnoiwgiN7 d+wPGg7jpONY19lrdFTx/8l4kGkUdPMuYna1jorLQWAlrMjopt2HMsZ1o0N23sdLhcnL 2cPOnmQSJVen949YErj81W5FERsn19WwEdYQyCg2NfdO85teSH8MLzILKPEEIKXvOz3y OU+qpI/X+rmpRmcXTmv2BUSdTPiqDH0R9Hg0ufiW8IrD5Osb2ehGXma5d/aKTB7F8gM0 F3uQ== X-Gm-Message-State: AKwxytcUmgutVj9ajPgaOFFVQAMkY7rurxCT6YMOxB3acX+KRg/+xua1 tCcTt+45Fzf/64DDPXO/3MQTE5AqKKRdDgXA0v5RHA== X-Received: by 10.223.134.166 with SMTP id 35mr2447734wrx.10.1516715173627; Tue, 23 Jan 2018 05:46:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.199.65 with HTTP; Tue, 23 Jan 2018 05:46:13 -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: Tue, 23 Jan 2018 19:16:13 +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 All, Any comments on this?? Regards, Anup