From nobody Mon Feb 9 00:18:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DAB2C0015E for ; Fri, 11 Aug 2023 11:57:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235518AbjHKL4z (ORCPT ); Fri, 11 Aug 2023 07:56:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233772AbjHKL4w (ORCPT ); Fri, 11 Aug 2023 07:56:52 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C93F110 for ; Fri, 11 Aug 2023 04:56:51 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-99c4923195dso263889166b.2 for ; Fri, 11 Aug 2023 04:56:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691755010; x=1692359810; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0KbOGymP7OaffTHBxIipa1qriFrse7ok8bc9+6gM8Bo=; b=SUJDwsnTW6pbG7vD+g67dznFE3s3+YgkqWsX1abky6jdEPQM0ziAqQujZfLELDSzP/ Ax+pTse635fKzsGn2yquOaJDMXxbZyYmZyU/IvsKQm8u9BKU5bETs64ahDDIdxHVOGyB Jzrl4Z/7AVi8sKOod30vD6VWIUcYpLXF0Up0zvW/eGGY9ln5hkXVrdo+CYZnh0TzqfWJ mDeFdoGBUQGv7Ee70VGDfU8MqEUeTuJnJ3uwlsrCOHLSyFfZvX1oqtScIjxkjp7784hP vALP9lBBPkqG398pnc6QCRenNkUh07W9ax81SovmDhhN85HxgecUgQ6kAXgLqoKMQQKW zfOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691755010; x=1692359810; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0KbOGymP7OaffTHBxIipa1qriFrse7ok8bc9+6gM8Bo=; b=LoXD+nB9V9nzAU9KvaY2LNrq3gimd5e6u8tQCUC7KrUvXzhll2x38j8NMWIBcJO5oL QLLb6gVEwZ5YpbNtE8D2xAJN6avYFxkKX+FRJlM+j5nDBegtU3rsjEwLRLYI/yEJS59l tKvg/Lau1LoXYm76WG4JFbfZY7a4vD5ytDK9GDdKpNmckoZ4obPEHIasqrjN2P7K0XUw WFP/N4udke66ghIdk39/KLNLwzCzaLr+NI0peXbmuFAtqLkStwTym+SfvfxZfMQSkVjY A6azDDqAxwRyumYtIn4m0oWRC15Q3shfhz+VB509wAwga0jjhwDOQWny8Tl4ofAMDk4u wZ3w== X-Gm-Message-State: AOJu0YxtYgymyzaBJQh1F0DgcyFduCtLzu8uHQk7VppBVJN0774vXGRY +74ikJ8uxUtOHw49zmi58JaRZg== X-Google-Smtp-Source: AGHT+IG0wtiSPVD2BI/rt+0tKNTU322QQvf1TbPMiyS3rD+x0owk8gamY2YX0bJwHcEi5Ivdo7cVAw== X-Received: by 2002:a17:906:31c6:b0:994:3207:cddd with SMTP id f6-20020a17090631c600b009943207cdddmr1569351ejf.34.1691755010074; Fri, 11 Aug 2023 04:56:50 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id f16-20020a170906561000b00992076f4a01sm2165395ejq.190.2023.08.11.04.56.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 04:56:49 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Ekansh Gupta , stable , Srinivas Kandagatla Subject: [PATCH 1/3] misc: fastrpc: Fix remote heap allocation request Date: Fri, 11 Aug 2023 12:56:41 +0100 Message-Id: <20230811115643.38578-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230811115643.38578-1-srinivas.kandagatla@linaro.org> References: <20230811115643.38578-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ekansh Gupta Remote heap is used by DSP audioPD on need basis. This memory is allocated from reserved CMA memory region and is then shared with audioPD to use it for it's functionality. Current implementation of remote heap is not allocating the memory from CMA region, instead it is allocating the memory from SMMU context bank. The arguments passed to scm call for the reassignment of ownership is also not correct. Added changes to allocate CMA memory and have a proper ownership reassignment. Fixes: 532ad70c6d44 ("misc: fastrpc: Add mmap request assigning for static = PD pool") Cc: stable Tested-by: Ekansh Gupta Signed-off-by: Ekansh Gupta Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 9666d28037e1..2faabbd12755 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1866,7 +1866,11 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl,= char __user *argp) return -EINVAL; } =20 - err =3D fastrpc_buf_alloc(fl, fl->sctx->dev, req.size, &buf); + if (req.flags =3D=3D ADSP_MMAP_REMOTE_HEAP_ADDR) + err =3D fastrpc_remote_heap_alloc(fl, dev, req.size, &buf); + else + err =3D fastrpc_buf_alloc(fl, dev, req.size, &buf); + if (err) { dev_err(dev, "failed to allocate buffer\n"); return err; @@ -1905,12 +1909,8 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl,= char __user *argp) =20 /* Add memory to static PD pool, protection thru hypervisor */ if (req.flags =3D=3D ADSP_MMAP_REMOTE_HEAP_ADDR && fl->cctx->vmcount) { - struct qcom_scm_vmperm perm; - - perm.vmid =3D QCOM_SCM_VMID_HLOS; - perm.perm =3D QCOM_SCM_PERM_RWX; - err =3D qcom_scm_assign_mem(buf->phys, buf->size, - &fl->cctx->perms, &perm, 1); + err =3D qcom_scm_assign_mem(buf->phys, (u64)buf->size, + &fl->cctx->perms, fl->cctx->vmperms, fl->cctx->vmcount); if (err) { dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx= err %d", buf->phys, buf->size, err); --=20 2.25.1 From nobody Mon Feb 9 00:18:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 596DEC04A6A for ; Fri, 11 Aug 2023 11:57:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235806AbjHKL45 (ORCPT ); Fri, 11 Aug 2023 07:56:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230230AbjHKL4y (ORCPT ); Fri, 11 Aug 2023 07:56:54 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF8EA11F for ; Fri, 11 Aug 2023 04:56:52 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-99c3d3c3db9so266269566b.3 for ; Fri, 11 Aug 2023 04:56:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691755011; x=1692359811; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=COd39iwzA46hvSxeAdraThBadyCY8RFKXPeA//q6518=; b=Dme376pTaFqRA03PokDCOjB2CXKH5mu9JaK7GIixlIh3BzevEYZnHA2Z7vt4fNMJ6r I0TxL5Ueae5b490Wvmb3DmhWJVMri5VAUrOm9BBqIM84Z0xEDp/fKeuh8Xr6+uFOxehU /pob1MhAjHN9D7LegYMYF2p7vD5FqYPAnYawxuz9q+JiLk3wOXgQO30mjR4SF2u+OmPz 7mKSIgmx82EknmLrbub46VpKrruQaMqjLFi/3+3KMpkhyI48hTDQlPejcifZfbhaWpB7 AIfVbWDxzjXK2VgDIMwBgbepulbNkI5FhIEXy3oHNpXKyMNg//wgx7jUSAJyZ2TYrVHt lYgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691755011; x=1692359811; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=COd39iwzA46hvSxeAdraThBadyCY8RFKXPeA//q6518=; b=GCqVejGsLW4LuP82B57AsRZ77SkCGTAHJPJhjmj8lvjQhSpijfCqkfftRpILwRn7v+ ZD789/Xv/2gVSvZ60P4cEnKwhcP/BKjEkol7KC4eHq/Un+R0TEBvBFVbrlAf7YPMhWCd a7rPAffJ7tGCy/6X/b9BCRl33CGL/6kDJx9fCSWjFyYPnPCUwlJxny92rW9Oz8tWy+ld XqExGwWcOIRPADwdCD/JiMFkfj9DkPStW3W5Oy1SjNT+5lhLWNpK4NJa565lT1UDqeXx a6doSu9vaSk5NgcUrE8LguE2pvmWMhYVKQ45QImtVl9nZ4rBjIc5ghodA419Ruti2YFV Cdog== X-Gm-Message-State: AOJu0YyZtfnNMd5uWMOd45cn179RQ6VOOdRhDCUi8IUjbOVqFRSCT5AK X4K1jPV7fAal7ZJKlqpkKHhBiA== X-Google-Smtp-Source: AGHT+IEpX/sSsrjWxtT/mvymrNAy2/AAzpFg0YkSyQAi55UPqOxx3kBLaXW6ksgWG0KV9HcnKSDKEQ== X-Received: by 2002:a17:906:314c:b0:99b:64d0:f6c8 with SMTP id e12-20020a170906314c00b0099b64d0f6c8mr1348254eje.50.1691755011100; Fri, 11 Aug 2023 04:56:51 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id f16-20020a170906561000b00992076f4a01sm2165395ejq.190.2023.08.11.04.56.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 04:56:50 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Ekansh Gupta , stable , Srinivas Kandagatla Subject: [PATCH 2/3] misc: fastrpc: Fix incorrect DMA mapping unmap request Date: Fri, 11 Aug 2023 12:56:42 +0100 Message-Id: <20230811115643.38578-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230811115643.38578-1-srinivas.kandagatla@linaro.org> References: <20230811115643.38578-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ekansh Gupta Scatterlist table is obtained during map create request and the same table is used for DMA mapping unmap. In case there is any failure while getting the sg_table, ERR_PTR is returned instead of sg_table. When the map is getting freed, there is only a non-NULL check of sg_table which will also be true in case failure was returned instead of sg_table. This would result in improper unmap request. Add proper check before setting map table to avoid bad unmap request. Fixes: c68cfb718c8f ("misc: fastrpc: Add support for context Invoke method") Cc: stable Signed-off-by: Ekansh Gupta Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 2faabbd12755..8183c55283fb 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -756,6 +756,7 @@ static int fastrpc_map_create(struct fastrpc_user *fl, = int fd, { struct fastrpc_session_ctx *sess =3D fl->sctx; struct fastrpc_map *map =3D NULL; + struct sg_table *table; int err =3D 0; =20 if (!fastrpc_map_lookup(fl, fd, ppmap, true)) @@ -783,11 +784,12 @@ static int fastrpc_map_create(struct fastrpc_user *fl= , int fd, goto attach_err; } =20 - map->table =3D dma_buf_map_attachment_unlocked(map->attach, DMA_BIDIRECTI= ONAL); - if (IS_ERR(map->table)) { - err =3D PTR_ERR(map->table); + table =3D dma_buf_map_attachment_unlocked(map->attach, DMA_BIDIRECTIONAL); + if (IS_ERR(table)) { + err =3D PTR_ERR(table); goto map_err; } + map->table =3D table; =20 if (attr & FASTRPC_ATTR_SECUREMAP) { map->phys =3D sg_phys(map->table->sgl); --=20 2.25.1 From nobody Mon Feb 9 00:18:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 772BDC41513 for ; Fri, 11 Aug 2023 11:57:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236092AbjHKL5A (ORCPT ); Fri, 11 Aug 2023 07:57:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234015AbjHKL4y (ORCPT ); Fri, 11 Aug 2023 07:56:54 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7928120 for ; Fri, 11 Aug 2023 04:56:53 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-99bdcade7fbso261479666b.1 for ; Fri, 11 Aug 2023 04:56:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691755012; x=1692359812; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CcPdZ2nGxjXBiRr9VgUDUf+2/h+oYQAJVXrn/kAMSKY=; b=mtbWXaTnOWz2UBNDIj7Py9lRxlm59CI8VyQAcyOT4mJ7ucw8tUxqjAbyGpvrEmDYRF fhF6IR20W9KSQZRlExFMEwdA7rfoX1o2PEo+ChUSQDsDQxJ/RFfzzI5ZZb3uY0Yqgh3i oLwfYJ6SppX6/IuzbQloo0bez+S7AnQCA5T92IwiRuqFDSpi+/n1ydumBMdS1e5T/Fvy ODJNch1RBOircYPR9/FGzFnCWvQLsRcE7MJNR1xH12IfqQUXKbOGrxTj0E6x2NWUCSEA ON5OmThwydny6yw4Sf3Ernz+HuyCQK/Jlqi4RYbBzryJ6mZkEwMGw7fgymH4LF4KafU9 L5PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691755012; x=1692359812; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CcPdZ2nGxjXBiRr9VgUDUf+2/h+oYQAJVXrn/kAMSKY=; b=bmLhBaLfmjKtjrfhd/dTPc5fGRGfr4KNq9yZ2l4rXq+6xZTLk5fh+l5JoSXlL6wZ48 nMPYo9yjOaryYk4HivG1WJqfCh4lklG75VBvdr9BYUmdCVbJWM4rWkQ4PoYTKZfdTXAh 1tq75wsZNGXqgMuDQqWnztwIK791swWyS1W1SrYGk+CGkyMFJxWAXTc7K/Se5Uz25wrv 9IFHmJOWX9Bn8W8XryTOWfxM2QW8YDU9P1aqlLWNgWNfWZOWiQ2kuvThOfXtTy2ROxIT ze6owuhPEciMhS5kjgp4ocWp3xXXEzsHwacgSvLNZ6mn3+YANCkytkwvFrWmMu+DGscO G9jw== X-Gm-Message-State: AOJu0YzvLmxsg3n+EJqTela+/+aw0AKNV6TBGykm0OdWzrdz+IvTaao/ 7aJOx/zPd6wtw7NIYrV+2pxwVw== X-Google-Smtp-Source: AGHT+IFhxxvnRqxptZVAyz9MunaXK7HUcUK2LI63uCPy/Om+NAaO3v2u66BqqR0VJVIugWk7DCp5RA== X-Received: by 2002:a17:906:1db1:b0:997:deb1:ff6a with SMTP id u17-20020a1709061db100b00997deb1ff6amr1450934ejh.22.1691755012496; Fri, 11 Aug 2023 04:56:52 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id f16-20020a170906561000b00992076f4a01sm2165395ejq.190.2023.08.11.04.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 04:56:51 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Ekansh Gupta , stable , Srinivas Kandagatla Subject: [PATCH 3/3] misc: fastrpc: Pass proper scm arguments for static process init Date: Fri, 11 Aug 2023 12:56:43 +0100 Message-Id: <20230811115643.38578-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230811115643.38578-1-srinivas.kandagatla@linaro.org> References: <20230811115643.38578-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ekansh Gupta Memory is allocated for dynamic loading when audio daemon is trying to attach to audioPD on DSP side. This memory is allocated from reserved CMA memory region and needs ownership assignment to new VMID in order to use it from audioPD. In the current implementation, arguments are not correctly passed to the scm call which might result in failure of dynamic loading on audioPD. Added changes to pass correct arguments during daemon attach request. Fixes: 0871561055e6 ("misc: fastrpc: Add support for audiopd") Cc: stable Tested-by: Ekansh Gupta Signed-off-by: Ekansh Gupta Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 8183c55283fb..42c4f603ec81 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1324,13 +1324,18 @@ static int fastrpc_init_create_static_process(struc= t fastrpc_user *fl, return 0; err_invoke: if (fl->cctx->vmcount) { - struct qcom_scm_vmperm perm; + u64 src_perms =3D 0; + struct qcom_scm_vmperm dst_perms; + u32 i; =20 - perm.vmid =3D QCOM_SCM_VMID_HLOS; - perm.perm =3D QCOM_SCM_PERM_RWX; + for (i =3D 0; i < fl->cctx->vmcount; i++) + src_perms |=3D BIT(fl->cctx->vmperms[i].vmid); + + dst_perms.vmid =3D QCOM_SCM_VMID_HLOS; + dst_perms.perm =3D QCOM_SCM_PERM_RWX; err =3D qcom_scm_assign_mem(fl->cctx->remote_heap->phys, (u64)fl->cctx->remote_heap->size, - &fl->cctx->perms, &perm, 1); + &src_perms, &dst_perms, 1); if (err) dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx= err %d", fl->cctx->remote_heap->phys, fl->cctx->remote_heap->size, err); --=20 2.25.1