From patchwork Fri Sep 13 15:25:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 173769 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp297018ilq; Fri, 13 Sep 2019 08:25:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQeOjiiTaFG//RL7kgfyu/7lOQF+RfkJ/cmOthaXn+9hlHGEGraB3MERlmyA/Pwb8nMloX X-Received: by 2002:a50:ac0d:: with SMTP id v13mr4535057edc.189.1568388345470; Fri, 13 Sep 2019 08:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568388345; cv=none; d=google.com; s=arc-20160816; b=KU+2mBsakRSXDHsmaGQenH9T4sdL9uuCRvu0YZewZ+DXbZ7tXQ8/YSFgTDHyOVDrMe xB71l7g3fDU55DBjzn+rkoz8H46pg4NXLa0t9SjUr+up1jxnWwoSYiFhTVu0sHsFtnLg jKaZLzMDEPxqU5Ee7uh4iLM+ORdlCtf2Rw+zVy5WdlkfDWsHsID0IZzZuFTGWcKKwk7y GcMFJcfsDspqpCSAlG2NNC50j56yitDNSxKsn45HqseCT49CN/CDNvL9/+nvfgLXaUAB HRuMaOH/m+EYNoauJzOWs/1gqimSeVw20ZaZZinlYmZbqvIGpJ3RgUEG/+8fc36vObck vpig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=viZTAWPErx527r3fiNEC4gxd7nWs91ZnvKtAXTam2GA=; b=Ytb18OBuS9G9BEYI4USN8wwf/wX7rh23CSZMhJxu7LOVyLw+M22wxuj/lguxkxvYqM fkG4+p6gKAX55eiHPzyIE/ooh4B4KGoBZRuZXUDOd2Xldx2wtTu4J/V3MXvjdBnHPWWH HWTLn0mbF+CfruGZkqMAijrR9RSwRq6PwB9n/9MfUzvs8r2knoC4J56P8HVlrb/hO+qN aa3Q+eEwHBpBaAa73BJmpcn4/LmOm37UpDCDoLpB3QPlb/SbYhCo5Y6sqH5WujTkOWfL HJmZRP1zoXY4JvatWUUcKfr+k2nseUojAHNhMM0Pw6MAPkNFaYx9mDw7995LxW6R+17X Xkeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="E/SFIH6f"; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s18si13258228ejb.49.2019.09.13.08.25.45; Fri, 13 Sep 2019 08:25:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=@linaro.org header.s=google header.b="E/SFIH6f"; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388354AbfIMPZl (ORCPT + 15 others); Fri, 13 Sep 2019 11:25:41 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:33208 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389457AbfIMPZk (ORCPT ); Fri, 13 Sep 2019 11:25:40 -0400 Received: by mail-wm1-f65.google.com with SMTP id r17so2124224wme.0 for ; Fri, 13 Sep 2019 08:25:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=viZTAWPErx527r3fiNEC4gxd7nWs91ZnvKtAXTam2GA=; b=E/SFIH6fW1fnH2EEAJq0b/dMFmOLuZiHHNk3slp9yVsTlQoM1zVnuYLxdeFW1aoSZO HCaZtSFkFh3vzR5bC6I/gN/HwaN7zLxYwIAl5k5bn1nYxqOj62MQVL70HcPPkL0DRSNL QVOfCyZdAH7nJJReFF3ETVIXqsU3EYQWGtDIhE+83jZPwiaN5HVl04OtQrziQ+Jhxfg3 dssm36pOoxw+4yTFPP4wmpEX0uzNGEqiFZXKEx2TCHlGSX689NssaocOFz/OoisG5S0k nV0WKfXwwpHIUmIIrpc9e2rj7AGV2cWJbQaZiSwQiRXt1nZMwrX3t81Km0g0ikUcT+TX 6eGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=viZTAWPErx527r3fiNEC4gxd7nWs91ZnvKtAXTam2GA=; b=Vd9O7NfK/0FKXodwxFCSbnspr/hniUlopdtOjBSK/6wseOb1bDWO9ycutJwW0T+Dlp wbY6GC72XRBpbrvb34/PiCGzTKnFsqaHugmEZ0QEirNwzNUTYbP7Il04X0C63LQT4QnA FXfisKLS8WzGH9xXp6KYWJ/mlNXVKsXTBqmKGYLarpA5OVI7G2+dctB5104kLkl+vSk5 Eq5tR85zg0RiX+bddKFU4hR+PeJWhi3dl2dx8DUnDVpceSrIHpKjv/3YYHXTejnPzU5d a0Jf7jDYh3oj9UVSVwST0cLnbUPNyVHaQx9M7WyblKgfxt/qHnEtxMu0v1iGvWMuzKFd iYDw== X-Gm-Message-State: APjAAAWvPPpAXB6Jf1yeRs33/sL1jBUrk1aiN0C61Aa01rZBFptaxS9Q XwLZHodN+/w6bZT26kFCA5MFpQ== X-Received: by 2002:a7b:cc82:: with SMTP id p2mr3777899wma.165.1568388337669; Fri, 13 Sep 2019 08:25:37 -0700 (PDT) Received: from localhost.localdomain (69.red-83-35-113.dynamicip.rima-tde.net. [83.35.113.69]) by smtp.gmail.com with ESMTPSA id d9sm48717728wrc.44.2019.09.13.08.25.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Sep 2019 08:25:37 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, gregkh@linuxfoundation.org, arnd@arndb.de, srinivas.kandagatla@linaro.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 1/5] misc: fastrpc: add mmap/unmap support Date: Fri, 13 Sep 2019 17:25:28 +0200 Message-Id: <20190913152532.24484-2-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190913152532.24484-1-jorge.ramirez-ortiz@linaro.org> References: <20190913152532.24484-1-jorge.ramirez-ortiz@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Support the allocation/deallocation of buffers mapped to the DSP. When the memory mapped to the DSP at process creation is not enough, the fastrpc library can extend it at runtime. This avoids having to do large preallocations by default. Signed-off-by: Jorge Ramirez-Ortiz Reviewed-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 181 ++++++++++++++++++++++++++++++++++++ include/uapi/misc/fastrpc.h | 15 +++ 2 files changed, 196 insertions(+) -- 2.23.0 diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 98603e235cf0..8903388993d3 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -35,6 +35,7 @@ #define INIT_FILELEN_MAX (64 * 1024 * 1024) #define INIT_MEMLEN_MAX (8 * 1024 * 1024) #define FASTRPC_DEVICE_NAME "fastrpc" +#define ADSP_MMAP_ADD_PAGES 0x1000 /* Retrives number of input buffers from the scalars parameter */ #define REMOTE_SCALARS_INBUFS(sc) (((sc) >> 16) & 0x0ff) @@ -67,6 +68,8 @@ /* Remote Method id table */ #define FASTRPC_RMID_INIT_ATTACH 0 #define FASTRPC_RMID_INIT_RELEASE 1 +#define FASTRPC_RMID_INIT_MMAP 4 +#define FASTRPC_RMID_INIT_MUNMAP 5 #define FASTRPC_RMID_INIT_CREATE 6 #define FASTRPC_RMID_INIT_CREATE_ATTR 7 #define FASTRPC_RMID_INIT_CREATE_STATIC 8 @@ -90,6 +93,23 @@ struct fastrpc_remote_arg { u64 len; }; +struct fastrpc_mmap_rsp_msg { + u64 vaddr; +}; + +struct fastrpc_mmap_req_msg { + s32 pgid; + u32 flags; + u64 vaddr; + s32 num; +}; + +struct fastrpc_munmap_req_msg { + s32 pgid; + u64 vaddr; + u64 size; +}; + struct fastrpc_msg { int pid; /* process group id */ int tid; /* thread id */ @@ -124,6 +144,9 @@ struct fastrpc_buf { /* Lock for dma buf attachments */ struct mutex lock; struct list_head attachments; + /* mmap support */ + struct list_head node; /* list of user requested mmaps */ + uintptr_t raddr; }; struct fastrpc_dma_buf_attachment { @@ -192,6 +215,7 @@ struct fastrpc_user { struct list_head user; struct list_head maps; struct list_head pending; + struct list_head mmaps; struct fastrpc_channel_ctx *cctx; struct fastrpc_session_ctx *sctx; @@ -269,6 +293,7 @@ static int fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev, return -ENOMEM; INIT_LIST_HEAD(&buf->attachments); + INIT_LIST_HEAD(&buf->node); mutex_init(&buf->lock); buf->fl = fl; @@ -276,6 +301,7 @@ static int fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev, buf->phys = 0; buf->size = size; buf->dev = dev; + buf->raddr = 0; buf->virt = dma_alloc_coherent(dev, buf->size, (dma_addr_t *)&buf->phys, GFP_KERNEL); @@ -1098,6 +1124,7 @@ static int fastrpc_device_release(struct inode *inode, struct file *file) struct fastrpc_channel_ctx *cctx = fl->cctx; struct fastrpc_invoke_ctx *ctx, *n; struct fastrpc_map *map, *m; + struct fastrpc_buf *buf, *b; unsigned long flags; fastrpc_release_current_dsp_process(fl); @@ -1119,6 +1146,11 @@ static int fastrpc_device_release(struct inode *inode, struct file *file) fastrpc_map_put(map); } + list_for_each_entry_safe(buf, b, &fl->mmaps, node) { + list_del(&buf->node); + fastrpc_buf_free(buf); + } + fastrpc_session_free(cctx, fl->sctx); mutex_destroy(&fl->mutex); @@ -1143,6 +1175,7 @@ static int fastrpc_device_open(struct inode *inode, struct file *filp) mutex_init(&fl->mutex); INIT_LIST_HEAD(&fl->pending); INIT_LIST_HEAD(&fl->maps); + INIT_LIST_HEAD(&fl->mmaps); INIT_LIST_HEAD(&fl->user); fl->tgid = current->tgid; fl->cctx = cctx; @@ -1270,6 +1303,148 @@ static int fastrpc_invoke(struct fastrpc_user *fl, char __user *argp) return err; } +static int fastrpc_req_munmap_impl(struct fastrpc_user *fl, + struct fastrpc_req_munmap *req) +{ + struct fastrpc_invoke_args args[1] = { [0] = { 0 } }; + struct fastrpc_buf *buf, *b; + struct fastrpc_munmap_req_msg req_msg; + struct device *dev = fl->sctx->dev; + int err; + u32 sc; + + spin_lock(&fl->lock); + list_for_each_entry_safe(buf, b, &fl->mmaps, node) { + if ((buf->raddr == req->vaddrout) && (buf->size == req->size)) + break; + buf = NULL; + } + spin_unlock(&fl->lock); + + if (!buf) { + dev_err(dev, "mmap not in list\n"); + return -EINVAL; + } + + req_msg.pgid = fl->tgid; + req_msg.size = buf->size; + req_msg.vaddr = buf->raddr; + + args[0].ptr = (u64) (uintptr_t) &req_msg; + args[0].length = sizeof(req_msg); + + sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_MUNMAP, 1, 0); + err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, sc, + &args[0]); + if (!err) { + dev_dbg(dev, "unmmap\tpt 0x%09lx OK\n", buf->raddr); + spin_lock(&fl->lock); + list_del(&buf->node); + spin_unlock(&fl->lock); + fastrpc_buf_free(buf); + } else { + dev_err(dev, "unmmap\tpt 0x%09lx ERROR\n", buf->raddr); + } + + return err; +} + +static int fastrpc_req_munmap(struct fastrpc_user *fl, char __user *argp) +{ + struct fastrpc_req_munmap req; + + if (copy_from_user(&req, argp, sizeof(req))) + return -EFAULT; + + return fastrpc_req_munmap_impl(fl, &req); +} + +static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) +{ + struct fastrpc_invoke_args args[3] = { [0 ... 2] = { 0 } }; + struct fastrpc_buf *buf = NULL; + struct fastrpc_mmap_req_msg req_msg; + struct fastrpc_mmap_rsp_msg rsp_msg; + struct fastrpc_req_munmap req_unmap; + struct fastrpc_phy_page pages; + struct fastrpc_req_mmap req; + struct device *dev = fl->sctx->dev; + int err; + u32 sc; + + if (copy_from_user(&req, argp, sizeof(req))) + return -EFAULT; + + if (req.flags != ADSP_MMAP_ADD_PAGES) { + dev_err(dev, "flag not supported 0x%x\n", req.flags); + return -EINVAL; + } + + if (req.vaddrin) { + dev_err(dev, "adding user allocated pages is not supported\n"); + return -EINVAL; + } + + err = fastrpc_buf_alloc(fl, fl->sctx->dev, req.size, &buf); + if (err) { + dev_err(dev, "failed to allocate buffer\n"); + return err; + } + + req_msg.pgid = fl->tgid; + req_msg.flags = req.flags; + req_msg.vaddr = req.vaddrin; + req_msg.num = sizeof(pages); + + args[0].ptr = (u64) &req_msg; + args[0].length = sizeof(req_msg); + + pages.addr = buf->phys; + pages.size = buf->size; + + args[1].ptr = (u64) &pages; + args[1].length = sizeof(pages); + + args[2].ptr = (u64) &rsp_msg; + args[2].length = sizeof(rsp_msg); + + sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_MMAP, 2, 1); + err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, sc, + &args[0]); + if (err) { + dev_err(dev, "mmap error (len 0x%08llx)\n", buf->size); + goto err_invoke; + } + + /* update the buffer to be able to deallocate the memory on the DSP */ + buf->raddr = (uintptr_t) rsp_msg.vaddr; + + /* let the client know the address to use */ + req.vaddrout = rsp_msg.vaddr; + + spin_lock(&fl->lock); + list_add_tail(&buf->node, &fl->mmaps); + spin_unlock(&fl->lock); + + if (copy_to_user((void __user *)argp, &req, sizeof(req))) { + /* unmap the memory and release the buffer */ + req_unmap.vaddrout = buf->raddr; + req_unmap.size = buf->size; + fastrpc_req_munmap_impl(fl, &req_unmap); + return -EFAULT; + } + + dev_dbg(dev, "mmap\t\tpt 0x%09lx OK [len 0x%08llx]\n", + buf->raddr, buf->size); + + return 0; + +err_invoke: + fastrpc_buf_free(buf); + + return err; +} + static long fastrpc_device_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -1293,6 +1468,12 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int cmd, case FASTRPC_IOCTL_ALLOC_DMA_BUFF: err = fastrpc_dmabuf_alloc(fl, argp); break; + case FASTRPC_IOCTL_MMAP: + err = fastrpc_req_mmap(fl, argp); + break; + case FASTRPC_IOCTL_MUNMAP: + err = fastrpc_req_munmap(fl, argp); + break; default: err = -ENOTTY; break; diff --git a/include/uapi/misc/fastrpc.h b/include/uapi/misc/fastrpc.h index fb792e882cef..07de2b7aac85 100644 --- a/include/uapi/misc/fastrpc.h +++ b/include/uapi/misc/fastrpc.h @@ -10,6 +10,8 @@ #define FASTRPC_IOCTL_INVOKE _IOWR('R', 3, struct fastrpc_invoke) #define FASTRPC_IOCTL_INIT_ATTACH _IO('R', 4) #define FASTRPC_IOCTL_INIT_CREATE _IOWR('R', 5, struct fastrpc_init_create) +#define FASTRPC_IOCTL_MMAP _IOWR('R', 6, struct fastrpc_req_mmap) +#define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_req_munmap) struct fastrpc_invoke_args { __u64 ptr; @@ -38,4 +40,17 @@ struct fastrpc_alloc_dma_buf { __u64 size; /* size */ }; +struct fastrpc_req_mmap { + __s32 fd; + __u32 flags; /* flags for dsp to map with */ + __u64 vaddrin; /* optional virtual address */ + __u64 size; /* size */ + __u64 vaddrout; /* dsp virtual address */ +}; + +struct fastrpc_req_munmap { + __u64 vaddrout; /* address to unmap */ + __u64 size; /* size */ +}; + #endif /* __QCOM_FASTRPC_H__ */ From patchwork Fri Sep 13 15:25:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 173768 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp297009ilq; Fri, 13 Sep 2019 08:25:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1TWKuihl/WA/TnDCTAyOzY2uc4rf/roJtM1NlGwglgh53xbtc9SZY1Y6EWjoeanr/0Mcv X-Received: by 2002:a05:6402:2028:: with SMTP id ay8mr37172675edb.120.1568388345117; Fri, 13 Sep 2019 08:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568388345; cv=none; d=google.com; s=arc-20160816; b=NgbA7YbWgdaZYmGx1dF4j06K6xs8lvXkJT5NDJeVA/xvCTD4Lh9ksO3Y5lGo02UBcd 0Bt6oC/oEMwxWH3hTes0W4fjnKMhtb81u9xjRv+lLGZz8ZsalCw6IhVLE/X13tp4RekF 14uAm4+IiGiKBluIC7JK7v8ScDcPQFfzrt5zstFr4GwalOV12hlhz4KVM5EJXqmyGSFL BFQ3Z5y9s2rdOYa7M6kdg2PDXRD2VqK+JWoi5QChBbGj9om3QiPKYaGcT7/P35/TQ1p6 /XA/o5yrlcJNa9+YFlDqM6wg6Y9SDHRKfqlu4xT/41GZftI8aqfZwc2rW2jmKbvZF99A cXdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=e/lU9jG5N7e3DGoVf3x6D+rPQKudYImqOCFLI9QDQ8k=; b=lYYrtoZKKFua+HEJcQ6p5DFnWP8s2VfLYApP52IS4jrrkTZHv3d7GJaRZRY8tbU3KB +KZBcBG3imBYIg4xuBH93gMy5Z+fJIR2Dd3YT1FpSZA7Q36+FHwC6eV4cgrVsff98g5f gyGnO3wk6iZGw4AlqJTX3XVPwTIEiuINX4R+Hkn0313Pyr3PvaY/5WZJHRNrmwb8p8vD iRifHJ2/TkarH4oeS3lLPf+MKyL4EAewvkb3YcAa67JSJzLSOSudFaUISBTHktIYwLeM qY8c23Pgc3S+9mTww0M85VaoDKyrOAbY4jgbTfeQEg70qciycyE0osSGdMWbcqc7Y/BM V+Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gqpn2OIi; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s18si13258228ejb.49.2019.09.13.08.25.44; Fri, 13 Sep 2019 08:25:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=@linaro.org header.s=google header.b=gqpn2OIi; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391428AbfIMPZl (ORCPT + 15 others); Fri, 13 Sep 2019 11:25:41 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:51900 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388354AbfIMPZk (ORCPT ); Fri, 13 Sep 2019 11:25:40 -0400 Received: by mail-wm1-f65.google.com with SMTP id 7so3220462wme.1 for ; Fri, 13 Sep 2019 08:25:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e/lU9jG5N7e3DGoVf3x6D+rPQKudYImqOCFLI9QDQ8k=; b=gqpn2OIiZdZR/ujxmZ4QKVcE0P5jWYnbShSyKwt+5OJvAk//DlifLDtqxfEpAUw/l6 T/DR/0AYFynhblu0cN/SaXf0Xm/FdY9gTY17Cf+x5rj0ebfHya+BtDzrR2GF0JeAmAH7 FBlDd/omPPc+NNNMxizNCrTMDPoo4YUiNtEBLP4tEJQh2+4lpgQjMCiHIXzAZMdIKtFd 4nUHzhjGxdp75h5RzCVqrfg8ei+s69essebdX5VSw4Q8BunyAPSq7JDaG8vwaCBc0mE8 EZE8mPG3Ez3C8SDVWhgaF0Blqb+gUejmRiFvL2MjAd6xJAoP0p4mIwrRifcogsqKZOKP datg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e/lU9jG5N7e3DGoVf3x6D+rPQKudYImqOCFLI9QDQ8k=; b=ANx9gV98LvRBB/E9Ws7XADeOv2Isqy4kBuPPJKl2oxr3SHAF/iOW75U84rpyO/ZR+Y hvAwSPpRaU5pDqT5ojUbNeXyFBjXrroIrVwl32piTj/WJpnM4imR1fjkuLMyZdMsBkWO mibQX6nyHDFI/4Z1PvbnG9096KAzjachOLFS36bEruZkhegBKrfpnLSuGktlSx41ggG5 AkFrVL7Q/LrFMIZxWkqPt478fS+OyDKEP8yWSFhmrT4ZhZzvsxTtxl8K3AlBYZ1smFNw fW0/6B3unP5ee0bGbQ7i5Y9r+VzvYZUkhK81sPm9rCIjqJ926EJyFC1Q7fxU63ZRIfzH PWrg== X-Gm-Message-State: APjAAAWhPNFkO4+xTmC0AKZADzI/kX2Am6xk96EUh5axgh4lXV21sqad SZaat1vCAMX0Gm3o5tBK2DW3qQ== X-Received: by 2002:a1c:f518:: with SMTP id t24mr3725176wmh.98.1568388338932; Fri, 13 Sep 2019 08:25:38 -0700 (PDT) Received: from localhost.localdomain (69.red-83-35-113.dynamicip.rima-tde.net. [83.35.113.69]) by smtp.gmail.com with ESMTPSA id d9sm48717728wrc.44.2019.09.13.08.25.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Sep 2019 08:25:38 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, gregkh@linuxfoundation.org, arnd@arndb.de, srinivas.kandagatla@linaro.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 2/5] misc: fastrpc: fix memory leak from miscdev->name Date: Fri, 13 Sep 2019 17:25:29 +0200 Message-Id: <20190913152532.24484-3-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190913152532.24484-1-jorge.ramirez-ortiz@linaro.org> References: <20190913152532.24484-1-jorge.ramirez-ortiz@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Srinivas Kandagatla Fix a memory leak in miscdev->name by using devm_variant Orignally reported by kmemleak: [] kmemleak_alloc+0x50/0x84 [] __kmalloc_track_caller+0xe8/0x168 [] kvasprintf+0x78/0x100 [] kasprintf+0x50/0x74 [] fastrpc_rpmsg_probe+0xd8/0x20c [] rpmsg_dev_probe+0xa8/0x148 [] really_probe+0x208/0x248 [] driver_probe_device+0x98/0xc0 [] __device_attach_driver+0x9c/0xac [] bus_for_each_drv+0x60/0x8c [] __device_attach+0x8c/0x100 [] device_initial_probe+0x20/0x28 [] bus_probe_device+0x34/0x7c [] device_add+0x420/0x498 [] device_register+0x24/0x2c Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.23.0 diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 8903388993d3..bc03500bfe60 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1599,8 +1599,8 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) } data->miscdev.minor = MISC_DYNAMIC_MINOR; - data->miscdev.name = kasprintf(GFP_KERNEL, "fastrpc-%s", - domains[domain_id]); + data->miscdev.name = devm_kasprintf(rdev, GFP_KERNEL, "fastrpc-%s", + domains[domain_id]); data->miscdev.fops = &fastrpc_fops; err = misc_register(&data->miscdev); if (err) From patchwork Fri Sep 13 15:25:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 173770 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp297027ilq; Fri, 13 Sep 2019 08:25:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHONgk4c7Xl9BrdAuhiNS3cqIKwXly2NJ8uC0YgiVCqMpNUc2VpKym1LUOGXFPfNa5wFFV X-Received: by 2002:aa7:dcc3:: with SMTP id w3mr48674713edu.202.1568388345825; Fri, 13 Sep 2019 08:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568388345; cv=none; d=google.com; s=arc-20160816; b=ajq8Pr1mc7C8x1/Buf8UVSRw5MbD5jTNGYwdIiRgQrfOGz+yoOY08SaQNnOev1LM9G /PfiCrjD5UVjh+0y+9TJ7Sixao2kcsKdWyQ0+fOaPLHPdt5+6ThK1AsRfAPqc6jkrTyi FpafboiI+po3/BiDy7V2vXPZ6m1NIQJ4rJt1ysDtVPSfcdGSK6Sk/uU7L8ev8j1MdHXi OpIuBy6W7Y4Tttl7LP/ZTG4Kvw+lTCVe+N7G9O8PG5HKPvTOcQlAwVYjZIE6sX8qWdil enLdXrMzgBwXVrHWEGwQ0QDzgy6EE9wpp2S+F1go+eiS2/Fbuzn/NJQE4xlDnJycmhGu x9+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=V4nZUxO6Mm4xe18R5imoxVeMnq5wn7Jg/kL+/NyaL6M=; b=QoxYTzehkmtnxkhvvKcZW0bYf/IlWkDw8nvFmv5SRyLdhX8jpEvo2sr34fT427I87Q d6pUyYFi3UdOfO+jT3whOnsTGr0iYxZcJj5uj5j1lCMKJYFnTGUICiHrdAQyIpkewxZM wyQD2L4d9MQ6Nud9QF2b41InCx4qWamZkcb5QJE6TxYfdqC+IA/f09oZvOXpE7gz3VEr 45xugR35Li0NPhlm/Kxsq7RZd24lHr602yF0EHyR0dt8DqSGWxnRKdkPkcW0I/3/je+J X9o8c+xU4Yu0aiK4H1izZ1051eV3WSapUq0gtjVNQFP1MseTpOTxhaoB0i/eaLGqdW0r wsbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xEXgWcAm; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s18si13258228ejb.49.2019.09.13.08.25.45; Fri, 13 Sep 2019 08:25:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=@linaro.org header.s=google header.b=xEXgWcAm; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391446AbfIMPZm (ORCPT + 15 others); Fri, 13 Sep 2019 11:25:42 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36325 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391347AbfIMPZm (ORCPT ); Fri, 13 Sep 2019 11:25:42 -0400 Received: by mail-wr1-f66.google.com with SMTP id y19so32515692wrd.3 for ; Fri, 13 Sep 2019 08:25:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V4nZUxO6Mm4xe18R5imoxVeMnq5wn7Jg/kL+/NyaL6M=; b=xEXgWcAmcjCbnlv2PZIcl4tioAQPW+pRHXZ+DDwIDcwrrtMgr3qzqom11PVXxCxWLM rpnWqp2cCPzw2MsLejDa1mjJrJeVnJoa2V29h4sJ1or6BjmehFfFbLaIIBzr63oTwD/U cWLVUpgY77Pykty1tSlJIZvHnZCrr95m6o6xxcyVVZkj9+8Kg+iKiOuzEkXkSDldyaqN jeSmbyKztRbCEANeQIPtJtx+a58FqrFnDfGaj3aEmWGVGO508KlSm1Vu01TC58fMZbiQ 8BlWyVnqIWBWynUp7gEFp0VVLUIdjzAzTLL4V57uqnQNh5NcAWTIEPEmufn8WsImKum3 V2pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V4nZUxO6Mm4xe18R5imoxVeMnq5wn7Jg/kL+/NyaL6M=; b=F6p7jKYQWbLrnTUYglAvIaQxAWfrvC8XmqcYXWRgtY5jwF2ctV/Bq7MXaGUlr1cXYc FWbdr2kQ/REhMOpa1Pl5IqE4pWrYVX/KOBWB57yOd610EtIhikAYS8uIRQeYbHrxKosX Y5mkbF+fmaav05IEVYuFDNl4JnfsecVyDa68dZzx7s5bD8Q3sZb95y4xth5Da5it124M kJWco8YbnmpY1ISEuCGRBi/LwZ5yj4JtvWsJr4aDDvLTKdRCSClzLzRZQ14ZkAEWTHFt XJY3oq3ZekvBh5PeymgnTXL1CEHn7JeL1AOEvgGSwiUJ/PwtdQuprg9TCE+sxDzoHoKi UI0w== X-Gm-Message-State: APjAAAV1G72AQ4axeRoM4jidykUe8x1G3eGFFOTYUbKZoHZkG+F/XgXM 8bHPyWinRSr6+ebZx+62kY/5Mw== X-Received: by 2002:a5d:4a05:: with SMTP id m5mr11622678wrq.265.1568388339932; Fri, 13 Sep 2019 08:25:39 -0700 (PDT) Received: from localhost.localdomain (69.red-83-35-113.dynamicip.rima-tde.net. [83.35.113.69]) by smtp.gmail.com with ESMTPSA id d9sm48717728wrc.44.2019.09.13.08.25.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Sep 2019 08:25:39 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, gregkh@linuxfoundation.org, arnd@arndb.de, srinivas.kandagatla@linaro.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 3/5] misc: fastrpc: do not interrupt kernel calls Date: Fri, 13 Sep 2019 17:25:30 +0200 Message-Id: <20190913152532.24484-4-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190913152532.24484-1-jorge.ramirez-ortiz@linaro.org> References: <20190913152532.24484-1-jorge.ramirez-ortiz@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org the DSP firmware requires some calls to be held until processing has completed: this is to guarantee that memory continues to be accessible. Nevertheless, the fastrpc driver chooses not support the case were requests need to be held for unbounded amounts of time. If such a use-case becomes necessary, this timeout will need to be revisited. Signed-off-by: Jorge Ramirez-Ortiz Reviewed-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- 2.23.0 diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index bc03500bfe60..d2b639dfc461 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -927,8 +927,13 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel, if (err) goto bail; - /* Wait for remote dsp to respond or time out */ - err = wait_for_completion_interruptible(&ctx->work); + if (kernel) { + if (!wait_for_completion_timeout(&ctx->work, 10 * HZ)) + err = -ETIMEDOUT; + } else { + err = wait_for_completion_interruptible(&ctx->work); + } + if (err) goto bail; From patchwork Fri Sep 13 15:25:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 173772 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp297164ilq; Fri, 13 Sep 2019 08:25:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwH9ewkju4qHzBYZNqWez9gnp3JbgGbKaTqAl6eUVpmm8djj40zL7f504kCrGg5KkJeGHvy X-Received: by 2002:aa7:c50b:: with SMTP id o11mr50243709edq.55.1568388353289; Fri, 13 Sep 2019 08:25:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568388353; cv=none; d=google.com; s=arc-20160816; b=09eJ4KC3ur1TAfLg0Yx8tDH/drCy0oe0ctnsNYCOUHr+RNL8ZXeiiAWiPyBh22JC8H qlh5+nNQLvB+A1QSJrL+u6otJZxcyOFlMHILtyzTwfYQtgmTe+X+Ew91sJqtuBGFegoU oEkEPcdUb0mbsmu2iy1c7+JLze0H21ZDoHLckdo7w9R+v9muTqeEc31kpvuvvV1x6Mj3 L4HQio4qTNcrtYWWNLGU36XWFWyqSQsdXfLgMBKOEVEpl4iIjqs4HWUIZ00Ziqat+77M jAP04tMhWIxc7SRWJiLOF4RP8dwthnCDazUBJ1kcGkaCB1QewOJQvIJjn/YC7Hgr8mpm I4rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bOYzS8r6FFCe1w6kMt/c64rHO9y9+Q16CQmrviT721s=; b=TQAMifzORBFTBYPiL/ZVXT9uBCBw3u1gWCBr7wA/4qKXp1rdRptmMfSiYlpycy1P1J k4NuqqklTOx4tmS2LZW8sEVhZ8jKlf9i+QEwwhekr6pSntCc/f+4c1DFVbKn6Sxh3c6k qJ/nCnGu06DDlSJmjcXIsKvqmIqX6Oz5ZibuwWC5FJitCnSk1FCEyf3qKIav6S8VBU3h bN6MgoQC7KT+WcG6fb853BywXUZ7gPjfdGPER5Y1XDXfgH5hDMPtNInyX/3q9o8+E2eG SCdygukTlKBUzVxMkktymoiadflUhcCNFsMo4ZxbmPkVYQetGtbX8q3xPYjsMQUPqL2h EZog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TFdL1AcN; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jx9si14638732ejb.218.2019.09.13.08.25.53; Fri, 13 Sep 2019 08:25:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=@linaro.org header.s=google header.b=TFdL1AcN; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391476AbfIMPZp (ORCPT + 15 others); Fri, 13 Sep 2019 11:25:45 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:37693 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391455AbfIMPZo (ORCPT ); Fri, 13 Sep 2019 11:25:44 -0400 Received: by mail-wr1-f68.google.com with SMTP id i1so31928857wro.4 for ; Fri, 13 Sep 2019 08:25:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bOYzS8r6FFCe1w6kMt/c64rHO9y9+Q16CQmrviT721s=; b=TFdL1AcNXLVgcVLdgEs8GmnKDUPQYd47eafZmqW1SB0DPG1x0WlYI6j0S78cMxlNuK L+0iYzlmdkBL/N6NfA65/iXx3ULpxhxvFF8rUMwsy//9R3VKaI9ZA+SbmBDXQm0bGZu8 fyA2aXG4bs8iJdTIo6XBFuZwdUU6FGdO5TNEUtIEyeNknU1bNVX1VRGMZkHjjfP8ZOHl +eB//bCZ9KdSmLfLAVRDXX1WAh3shOORm5NdZM32zjIgk8uoc9Cj6TEqOw/anaUAFLfw CLqGQqSPimZAubkFQs9HnU57zZ2KHcB4E/VkR5VbbFY0RS/d56IBw7ZA9dfDlyRXpNXX 08MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bOYzS8r6FFCe1w6kMt/c64rHO9y9+Q16CQmrviT721s=; b=L9+/fT1Aibo74/xEF6pMfxsS9gLpvnwvOub+58CstPW2p1SRHLhwQ3gecDAcWXksss o0Oqqw0b7p4WxDVgFLhA+SA0C2MZ3WGlDt8213HwYXJ9CukDGWQUOPsmXFb7hCvvP/Tb lrnJ5kPbdoswOt25NNjz40MGcO1QU5EiEDbIjyhE9G3EOb+dghIpVVHAPTzwwaFx7bH6 WKqEw9yZksoi8/4KLySAg+RjfP5+HNasuiyN5OZ+i1tG31nOuUNxZDP/PV6AIDZQlPbu QPbdGge0uBiZf6Y01W3UZaWq5kfKThK+Jtot4Gy+Qf17LWf9G+p9nTKJqUzQjWRo8n1d P2pg== X-Gm-Message-State: APjAAAVqn68vxgAJmENpsX41JXb32igXLZXfbjQjjos+kcZ/3usw2Eda jtvG5YJI6CglBBKGBYsiHmgE5w== X-Received: by 2002:a5d:5450:: with SMTP id w16mr19578762wrv.55.1568388341124; Fri, 13 Sep 2019 08:25:41 -0700 (PDT) Received: from localhost.localdomain (69.red-83-35-113.dynamicip.rima-tde.net. [83.35.113.69]) by smtp.gmail.com with ESMTPSA id d9sm48717728wrc.44.2019.09.13.08.25.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Sep 2019 08:25:40 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, gregkh@linuxfoundation.org, arnd@arndb.de, srinivas.kandagatla@linaro.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 4/5] misc: fastrpc: handle interrupted contexts Date: Fri, 13 Sep 2019 17:25:31 +0200 Message-Id: <20190913152532.24484-5-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190913152532.24484-1-jorge.ramirez-ortiz@linaro.org> References: <20190913152532.24484-1-jorge.ramirez-ortiz@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Buffers owned by a context that has been interrupted either by a signal or a timeout might still be being accessed by the DSP. delegate returning the associated memory to a later time when the device is released. Signed-off-by: Jorge Ramirez-Ortiz Reviewed-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) -- 2.23.0 diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index d2b639dfc461..40b48db032b5 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -952,12 +952,13 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel, } bail: - /* We are done with this compute context, remove it from pending list */ - spin_lock(&fl->lock); - list_del(&ctx->node); - spin_unlock(&fl->lock); - fastrpc_context_put(ctx); - + if (err != -ERESTARTSYS && err != -ETIMEDOUT) { + /* We are done with this compute context */ + spin_lock(&fl->lock); + list_del(&ctx->node); + spin_unlock(&fl->lock); + fastrpc_context_put(ctx); + } if (err) dev_dbg(fl->sctx->dev, "Error: Invoke Failed %d\n", err); From patchwork Fri Sep 13 15:25:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 173771 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp297153ilq; Fri, 13 Sep 2019 08:25:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqy+Fxk17Xb43j4kxc7LrYkippIEX7QI9qVoUbbCUo4MlQh/ySQwtpzNsYdFmlWo1ocBzpcY X-Received: by 2002:a17:906:6618:: with SMTP id b24mr39826230ejp.215.1568388352859; Fri, 13 Sep 2019 08:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568388352; cv=none; d=google.com; s=arc-20160816; b=KoXtZdd5TYweY4GGzMW3Elt7gofyM7PKW8ytcvilmLTbKyykPg9THcsSKSjf7W0fTI 3V4ijYGUtK1IcQUt5U6u9IjQ6eMShWG+VgpVY1oBkMJhBh3SCkWN3Bnr40CaOvD3XWAK ITGbBQbiN59btwxIMw5siSsb2tSPyWNup661sGjHExyTcybJF2NYWPTVXEDqxN63lzta VMVBau6Ohc1FgsrK0LQJ5Cs3kpQ3LAOKNezUIDEw8uaVy8xvwDHOYxZ3lh1Wv079gqQY TGSUvnM5fUukU13VYUviO+fPeoS+hjtSDPmjCcooNPoqFJ6Uqo3H2L3QuMvDz2525p3Y vy8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YR/vHc0/aYOgQ7htuSAKCOpYZUSwbX4XADi3ha+KA8Q=; b=pq95sKOBHDBRfwhdVnAG72idNxlr75pHxiA8yVpQ72xDdw8jtO3b5XOzD9pu/+HgpV xBMA6XyxXYu5/as1GZ1KqfFBYO91MfQDfoVZLy3K+fMAMHDyDEVEady/WKH+WuR2gdos wQmKJ/RL0H4rra7hVJr6rc01UsWGGd67EcEITxe13rbkPoaSq9Md9MC/PzEyE6avWmn4 TIU3wYrZxudTZ9TeqShj2EU+rRk1reIUK9hltEnkH6GTe4iJWLWOhBTLSiuQunG0aKU+ eAqo6P4Cu4LJTBT/0PTB+h/HTVBQ4ZPUJs5GJ+OMyB3/RGnr63ajSAp6ZcAS9FvH8BVq YVqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Leu/DrQJ"; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jx9si14638732ejb.218.2019.09.13.08.25.52; Fri, 13 Sep 2019 08:25:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=@linaro.org header.s=google header.b="Leu/DrQJ"; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391346AbfIMPZs (ORCPT + 15 others); Fri, 13 Sep 2019 11:25:48 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:46308 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403855AbfIMPZp (ORCPT ); Fri, 13 Sep 2019 11:25:45 -0400 Received: by mail-wr1-f67.google.com with SMTP id o18so1290490wrv.13 for ; Fri, 13 Sep 2019 08:25:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YR/vHc0/aYOgQ7htuSAKCOpYZUSwbX4XADi3ha+KA8Q=; b=Leu/DrQJjKKYfvqHogFl3YpcT43VdEBKD/+N9xaZ5aX1MwS8dy5gsahY0TJNorpYbj RCM87o79r3lSZplmrXS7UrRD6815d9/SoKwUkCjFRlnYWOrDccnYMBMOP/LZQ2sCY/Sd XVdH/57tU+/Oh19meKnLhqO3VPgF/2Ob1PKAPKmvhbIbkr6gplGq24WEvwL7ekeu7bYh c1H3omILP/rlmpUkgQkyAarA4r4hlL+byuhBCLJ3Us5c4oY2LnWwh05rO3TQDL5yA4za p/jZNguN1Tr1Z09DdtxeI3uGrpp5XCyGPCGiajOWr+3JV9Jj7tcMTH9jSaTQo1yIrybV W5+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YR/vHc0/aYOgQ7htuSAKCOpYZUSwbX4XADi3ha+KA8Q=; b=IIm2P/NdssoW1GZJu6RcEs/EvGwl9vA8kcF3ZDPI21mYlNK2EHaZ7pJQWPrsG7WWzT eN9q/UR8fMSQZTe6st1PuDY/8WMFK+i4EXSBn1Uy4+NEoVMfIa8iol3rc6jC01WnJbfN vyNOsIQtFn1jjhSLnHZ4UtdHgtUJaqhPhuYWQrr+Sp5grRNunT6S3239m2aSIJBH4/co KIYC7tPS59Dqu4VGsCSuNr6eeMwoa+pd5+vNd16ECSxA/uVcnyJ8DcsA6lymG8s8GeRm WmDSMTHeslEz34F0sB/nq9e1ysPAfBpEqwv5fEEOCgw1tJSAp3L5Yn3kX0cJNkul8Qrt N9yg== X-Gm-Message-State: APjAAAXVjHaVZ1Qg1O+bPiSekek6BhrhrqZW52d8QhwaSiRcehM6UnCg BoY+7Ti7Y10Ekh6BCDfWB4GGEQ== X-Received: by 2002:adf:bb0a:: with SMTP id r10mr28521700wrg.13.1568388342113; Fri, 13 Sep 2019 08:25:42 -0700 (PDT) Received: from localhost.localdomain (69.red-83-35-113.dynamicip.rima-tde.net. [83.35.113.69]) by smtp.gmail.com with ESMTPSA id d9sm48717728wrc.44.2019.09.13.08.25.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Sep 2019 08:25:41 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, gregkh@linuxfoundation.org, arnd@arndb.de, srinivas.kandagatla@linaro.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 5/5] misc: fastrpc: revert max init file size back to 2MB Date: Fri, 13 Sep 2019 17:25:32 +0200 Message-Id: <20190913152532.24484-6-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190913152532.24484-1-jorge.ramirez-ortiz@linaro.org> References: <20190913152532.24484-1-jorge.ramirez-ortiz@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org With the integration of the mmap/unmap functionality, it is no longer necessary to allow large memory allocations upfront since they can be handled during runtime. Tested on QCS404 with CDSP Neural Processing test suite. Signed-off-by: Jorge Ramirez-Ortiz Reviewed-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.23.0 diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 40b48db032b5..ee6de5d9993d 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -32,7 +32,7 @@ #define FASTRPC_CTX_MAX (256) #define FASTRPC_INIT_HANDLE 1 #define FASTRPC_CTXID_MASK (0xFF0) -#define INIT_FILELEN_MAX (64 * 1024 * 1024) +#define INIT_FILELEN_MAX (2 * 1024 * 1024) #define INIT_MEMLEN_MAX (8 * 1024 * 1024) #define FASTRPC_DEVICE_NAME "fastrpc" #define ADSP_MMAP_ADD_PAGES 0x1000