Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3044912pxb; Mon, 16 Nov 2020 04:28:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTFtZagXBHA9uoDAZyTindoklZ+YyOnRZiZ9iIi1lMybXs/4UTjUfmNCBAOF4k8fHbFTCF X-Received: by 2002:a17:906:82d9:: with SMTP id a25mr14083688ejy.101.1605529723878; Mon, 16 Nov 2020 04:28:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605529723; cv=none; d=google.com; s=arc-20160816; b=TFYIicjXgyFhJHgnnob/YKc5H2B04xbZV+76MucOm6EJvBeQUE6D9npHWycOL3LGSp +x1sJURz42dFdBkuzgo5e2DrtEjd4P3coBA8byaYwTNxc64F7j3qwz5Ow6XZKzOfSvDH 8ZL2WbdeDl1BaMrMvvo79tb8ryiiFV3FQl0whrz0QnNRk7NmYlQB8Gu6XAUaTKiFAFoc J19FUZp1Gs/ymMrB8fJOOSAOKIqS6pSKQ6thUc4Ake8V9B9Cwl7zXALaL6Ylhyt0PrAr HZ35HCLRxXt/MPbbzl7eSncr693m8P50lR/w4Mj4suK9MT8vsVnhEX/6JkVihtLSWgvv YNGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=twYAjgtjeEtP7dme/B3MtQN8LFC4b+SiLV0pksaCw+Q=; b=CHSrY40f0NruzA/LPrpnoqTEvBFvlyhCEZZTEQ8lme8pAg2m6rbmQCFBu9Bw4sJ0zh W25ppbAc/+vbSaU2cko8Yl3pfzdjpqv6mNDI8jK5bcOM08D77YeJsIb8Qspmg0Lw6vDw tVlzbRzRQlYbGbVi5HK+csoNwHSKtwDo0NDB/ZbrQ/jG+IT0BILHZ2aF+FgnK58rpHWo ddLpppcPrEiXAWPvMTV3U4Es69gHaCyufA4MBHH/mMMa1AyGoKDEqg1wKxmDKGlcDvb7 K9/7sSJ6VGrm3GYEAwVl1ygX3gg4fNtG3giGRNs1HEcyRSQPa0h4JLNbRQ4jevg1vqns QF1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=beiNO0zm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id me9si11284181ejb.199.2020.11.16.04.28.20; Mon, 16 Nov 2020 04:28:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=beiNO0zm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729972AbgKPMZo (ORCPT + 99 others); Mon, 16 Nov 2020 07:25:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60680 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727184AbgKPMZo (ORCPT ); Mon, 16 Nov 2020 07:25:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605529542; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=twYAjgtjeEtP7dme/B3MtQN8LFC4b+SiLV0pksaCw+Q=; b=beiNO0zmf1qEofoM6i6EUb8FXyRKDHCv7whNvQKSQhkrAYGpW54JifkHafQdEAICko/pXf 4WvB6vWtD8nIvhuymQ2Y5gRLq+QjQNWgJmYgZ+hIEFg46/Rnau/imd2Ao66txutxC1NsBe hPIizj0dXXZl6onCyHNQWjMCxL1wa88= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-35-A8hognzWOQudJpQ1oTNwVQ-1; Mon, 16 Nov 2020 07:25:40 -0500 X-MC-Unique: A8hognzWOQudJpQ1oTNwVQ-1 Received: by mail-wr1-f72.google.com with SMTP id x16so6326337wrn.9 for ; Mon, 16 Nov 2020 04:25:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=twYAjgtjeEtP7dme/B3MtQN8LFC4b+SiLV0pksaCw+Q=; b=qWbZrlgOWhpoa1GCJAj6pLqgOxIXKzzNvgsacWKfxtosH4OVgVkoQUQoQd3g7jdNB1 8g85XLEJylcnOW6uPcDuG6pyBPbZ5L7yzU+CkTna80GljpUFXtlgEg/3nXt/Cbaz9Yod q6FVjYl6wBekhpaJ9h3KU8qWOHaH2tTiSaAMKqiK6tYuHzL6hp87HRlZrei/G9b9xcYL 4nYNgNyyjKGmzYb3h3scZnjlxOXOUFb0pRp3km8VH6+T27Z6ptKSu9+Mn3MUkuv5Jm+q 876tc5eZuSOz4MT4rVd98uhG/RV6jBW4oRS24J1dp119RmCi/tjJri5Uxt+yWh6e1KFO IQBA== X-Gm-Message-State: AOAM533chajzR4BK9WIM+yvX48L+6/lqd00QYUJz+XVRDvFPpsMIDl6o 9tOglVBjcs4SQPdBojXN8TxQUs/Md38DV4KiAlm9jiI+I0/uDgSkNBkp8/nisvWg4NI0Jkbotru jCA9x9AzQiRkA3+j8k/rs0ua6 X-Received: by 2002:adf:a551:: with SMTP id j17mr20868542wrb.217.1605529539627; Mon, 16 Nov 2020 04:25:39 -0800 (PST) X-Received: by 2002:adf:a551:: with SMTP id j17mr20868522wrb.217.1605529539401; Mon, 16 Nov 2020 04:25:39 -0800 (PST) Received: from redhat.com ([147.161.8.56]) by smtp.gmail.com with ESMTPSA id i10sm22686923wrs.22.2020.11.16.04.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Nov 2020 04:25:38 -0800 (PST) Date: Mon, 16 Nov 2020 07:25:31 -0500 From: "Michael S. Tsirkin" To: Christoph Hellwig Cc: Alexander Lobakin , Amit Shah , Arnd Bergmann , Greg Kroah-Hartman , Arnaud Pouliquen , Suman Anna , Mathieu Poirier , Bjorn Andersson , Ohad Ben-Cohen , Jason Wang , virtualization@lists.linux-foundation.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH virtio] virtio: virtio_console: fix DMA memory allocation for rproc serial Message-ID: <20201116071910-mutt-send-email-mst@kernel.org> References: <20201116091950.GA30524@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201116091950.GA30524@infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 16, 2020 at 09:19:50AM +0000, Christoph Hellwig wrote: > I just noticed this showing up in Linus' tree and I'm not happy. Are you sure? I think it's in next. > This whole model of the DMA subdevices in remoteproc is simply broken. > > We really need to change the virtio code pass an expicit DMA device ( > similar to what e.g. the USB and RDMA code does), instead of faking up > devices with broken adhoc inheritance of DMA properties and magic poking > into device parent relationships. OK but we do have a regression since 5.7 and this looks like a fix appropriate for e.g. stable, right? > Bjorn, I thought you were going to look into this a while ago? > > > On Wed, Nov 04, 2020 at 03:31:36PM +0000, Alexander Lobakin wrote: > > Since commit 086d08725d34 ("remoteproc: create vdev subdevice with > > specific dma memory pool"), every remoteproc has a DMA subdevice > > ("remoteprocX#vdevYbuffer") for each virtio device, which inherits > > DMA capabilities from the corresponding platform device. This allowed > > to associate different DMA pools with each vdev, and required from > > virtio drivers to perform DMA operations with the parent device > > (vdev->dev.parent) instead of grandparent (vdev->dev.parent->parent). > > > > virtio_rpmsg_bus was already changed in the same merge cycle with > > commit d999b622fcfb ("rpmsg: virtio: allocate buffer from parent"), > > but virtio_console did not. In fact, operations using the grandparent > > worked fine while the grandparent was the platform device, but since > > commit c774ad010873 ("remoteproc: Fix and restore the parenting > > hierarchy for vdev") this was changed, and now the grandparent device > > is the remoteproc device without any DMA capabilities. > > So, starting v5.8-rc1 the following warning is observed: > > > > [ 2.483925] ------------[ cut here ]------------ > > [ 2.489148] WARNING: CPU: 3 PID: 101 at kernel/dma/mapping.c:427 0x80e7eee8 > > [ 2.489152] Modules linked in: virtio_console(+) > > [ 2.503737] virtio_rpmsg_bus rpmsg_core > > [ 2.508903] > > [ 2.528898] > > [ 2.913043] > > [ 2.914907] ---[ end trace 93ac8746beab612c ]--- > > [ 2.920102] virtio-ports vport1p0: Error allocating inbufs > > > > kernel/dma/mapping.c:427 is: > > > > WARN_ON_ONCE(!dev->coherent_dma_mask); > > > > obviously because the grandparent now is remoteproc dev without any > > DMA caps: > > > > [ 3.104943] Parent: remoteproc0#vdev1buffer, grandparent: remoteproc0 > > > > Fix this the same way as it was for virtio_rpmsg_bus, using just the > > parent device (vdev->dev.parent, "remoteprocX#vdevYbuffer") for DMA > > operations. > > This also allows now to reserve DMA pools/buffers for rproc serial > > via Device Tree. > > > > Fixes: c774ad010873 ("remoteproc: Fix and restore the parenting hierarchy for vdev") > > Cc: stable@vger.kernel.org # 5.1+ > > Signed-off-by: Alexander Lobakin > > --- > > drivers/char/virtio_console.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c > > index a2da8f768b94..1836cc56e357 100644 > > --- a/drivers/char/virtio_console.c > > +++ b/drivers/char/virtio_console.c > > @@ -435,12 +435,12 @@ static struct port_buffer *alloc_buf(struct virtio_device *vdev, size_t buf_size > > /* > > * 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. > > + * associated with the parent device: > > + * virtioY => remoteprocX#vdevYbuffer. > > */ > > - if (!vdev->dev.parent || !vdev->dev.parent->parent) > > + buf->dev = vdev->dev.parent; > > + if (!buf->dev) > > goto free_buf; > > - buf->dev = vdev->dev.parent->parent; > > > > /* Increase device refcnt to avoid freeing it */ > > get_device(buf->dev); > > -- > > 2.29.2 > > > > > ---end quoted text---