From patchwork Thu Nov 30 16:46:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 120242 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp22530qgn; Thu, 30 Nov 2017 08:48:10 -0800 (PST) X-Google-Smtp-Source: AGs4zMY7ftvxqC36cQs322T+6ObTVMtmqxoqlZSB6aMc3Veau01b+lBjiWudIxDdnwUPsp9rSEW9 X-Received: by 10.84.138.1 with SMTP id 1mr3218397plo.156.1512060489953; Thu, 30 Nov 2017 08:48:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512060489; cv=none; d=google.com; s=arc-20160816; b=tE8h9DBKjtU3UZ62RtQbw8Y07jam7Ba+03aS38rulJeK7JuikKNtAlpOmSZsGfugpV kTaE2lB7gIuvDcaxHDN88lHVCi/v05LrYXcytTt91AbyvNiZ9FjZSmMK+jSpe/EniyGd a/+klkD7PTD1/VM2kI41I3I6pFZFMh2ZGsVs3Nnq0Rivy/nMhFHz0L3QqZ7uk0UFdzMZ FO/Hin4peh4iyDYk6iudteUqtHKq8t/74e+wUSzpJ3hyjoC9DMGlOI/swKUfG78HjDks Uzi/uhZtAfRhDHxQF5GvVf0rwzWYIDE/WhwS8TD+zdkZ366Gp7djt674LPJxZ/8Jme2G BWTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=gI0IxMsjSDz8JbW3Rfir99Z8SJ27eF3nY1SsiUUtiXM=; b=J26LZXrudBy22ANNCR8Hh7tuqS+fMQHQiO3v5DGWBI/BF4UVQYscytSKRUlIz6uYs/ UN/Fz0nMficI5f/xakBVfL9i+mCGmvzxX/jm5cM0YMKhQEH08JzY2j/1IOxmVEahi9Fv Wu0K+mlqBzqJp4ALMyPlObkISqTGZM7xbGw8qvr6KweRAdlpkDUVp069O8ZB+1Dljzlp FVCt7QInvL4fAQHKX2UMbLD9HODQ3AuTF3e7VGWh9m6ncK5mb2SODOYZdNVz0aKIH82B 32Aao7q7jKuLUnQn5DD4yRiO60sbuDEa2n0avd/pFLS5vhHxk6lO5/ecIB9ObSA+eDW3 ZMdQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n18si3276098pgd.666.2017.11.30.08.48.09; Thu, 30 Nov 2017 08:48:09 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753811AbdK3QrY (ORCPT + 28 others); Thu, 30 Nov 2017 11:47:24 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:59848 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753638AbdK3QrW (ORCPT ); Thu, 30 Nov 2017 11:47:22 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAUGiHCR001569; Thu, 30 Nov 2017 17:47:20 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2eexh9v2s6-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 30 Nov 2017 17:47:20 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 47F3534; Thu, 30 Nov 2017 16:47:20 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag7node2.st.com [10.75.127.20]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2B245537A; Thu, 30 Nov 2017 16:47:20 +0000 (GMT) Received: from localhost (10.75.127.49) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 30 Nov 2017 17:47:19 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 12/16] remoteproc: look-up memory-device for vring allocation Date: Thu, 30 Nov 2017 17:46:47 +0100 Message-ID: <1512060411-729-13-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512060411-729-1-git-send-email-loic.pallardy@st.com> References: <1512060411-729-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG7NODE2.st.com (10.75.127.20) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-30_05:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch parse existing carveout list to find a memory area matching on name. Naming rule for search is the following one: - "vdevvring" to find a memory pool dedicated to one vring belonging to one specific vdev (vdev_id). - "vdevvrings> to find common memory pool for allocation of all vrings belonging to one specific vdev (vdev_id). This allows to cover different SoC requirements like allocating vrings at best location taking into account access performance in read and write for master and slave processors. If memory area found, memory device will be used as device for vring allocation, else rproc platform device will be used as today. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 25 +++++++++++++++++++++++-- include/linux/remoteproc.h | 2 ++ 2 files changed, 25 insertions(+), 2 deletions(-) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 8d990b1..6b5e2b2 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -410,8 +410,11 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) struct rproc_vring *rvring = &rvdev->vring[i]; struct fw_rsc_vdev *rsc; dma_addr_t dma = -1; + struct device *memdev = dev->parent; + struct rproc_mem_entry *carveout; void *va; int ret, size, notifyid; + char name[16]; /* actual size of vring (in bytes) */ size = PAGE_ALIGN(vring_size(rvring->len, rvring->align)); @@ -428,11 +431,27 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) return -ENOMEM; } } else { + /* Find any carveout matching vring */ + /* Try dedicated vdev j vring i pool. */ + snprintf(name, sizeof(name), "vdev%dvring%d", rvdev->index, i); + carveout = rproc_find_carveout_by_name(rproc, name); + + if (!carveout) { + /* Try dedicated vdev j vrings pool. */ + snprintf(name, sizeof(name), "vdev%dvring", rvdev->index); + carveout = rproc_find_carveout_by_name(rproc, name); + } + + if (carveout && carveout->memdev) + memdev = &carveout->memdev->dev; + + rvring->dev = memdev; + /* * Allocate non-cacheable memory for the vring. In the future * this call will also configure the IOMMU for us */ - va = dma_alloc_coherent(dev->parent, size, &dma, GFP_KERNEL); + va = dma_alloc_coherent(memdev, size, &dma, GFP_KERNEL); if (!va) { dev_err(dev->parent, "dma_alloc_coherent failed\n"); return -EINVAL; @@ -455,7 +474,7 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) if (ret < 0) { dev_err(dev, "idr_alloc failed: %d\n", ret); if (dma != -1) - dma_free_coherent(dev->parent, size, va, dma); + dma_free_coherent(memdev, size, va, dma); return ret; } notifyid = ret; @@ -565,6 +584,7 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, struct device *dev = &rproc->dev; struct rproc_vdev *rvdev; int i, ret; + static int index; /* make sure resource isn't truncated */ if (sizeof(*rsc) + rsc->num_of_vrings * sizeof(struct fw_rsc_vdev_vring) @@ -596,6 +616,7 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, rvdev->id = rsc->id; rvdev->rproc = rproc; + rvdev->index = index++; /* parse the vrings */ for (i = 0; i < rsc->num_of_vrings; i++) { diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index d7e7485..fb293d3 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -480,6 +480,7 @@ struct rproc_subdev { * @vq: the virtqueue of this vring */ struct rproc_vring { + struct device *dev; void *va; dma_addr_t dma; int len; @@ -507,6 +508,7 @@ struct rproc_vdev { struct rproc_subdev subdev; unsigned int id; + unsigned int index; struct list_head node; struct rproc *rproc; struct virtio_device vdev;