From nobody Fri Apr 26 14:14:54 2024 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 08D2AC4332F for ; Thu, 24 Nov 2022 17:51:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229635AbiKXRvo (ORCPT ); Thu, 24 Nov 2022 12:51:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbiKXRvk (ORCPT ); Thu, 24 Nov 2022 12:51:40 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04B34C1F77 for ; Thu, 24 Nov 2022 09:51:40 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id b12so3486028wrn.2 for ; Thu, 24 Nov 2022 09:51:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=WwNxnTC0a1IPalPxtww27IAv5/GUzCtpz/69xMVLEK0=; b=elT90pt/B9VByyHA/3c/7e0czDBA6h96oQ6bzTZ/E9XFY5M5gxv23hxIUyh1QQlesE XyImgwvR/6oqSjKG9BccPVC2jGn8ywdqpAHBAwLj8gM38e7X9x58gUnuXOqPLclOV6G1 rl/DVSU+/7TUojQHXwd2q4ZJ9f114gOGY5KFD2rfI2HYx/4/Mpp2xnV8cxDFeEVzwr8y 2wknpZruJkzTsp31lunPCOpw5J7lZ24I6SrWxkchpOI0VrFQX0kUphdaXAPEdgaBbKul MqUZMDAnWtUyVTn6lOQMw44l+t7FIctgohnuadps0ZbN12Y8R7vEBEBPgQSeTiiJYJbV MB/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=WwNxnTC0a1IPalPxtww27IAv5/GUzCtpz/69xMVLEK0=; b=1rvIhUiFkTDShSi9+bSS7LVVW/1DOqBHFNyeiWEZLJyUrLQDPI9X3VyzOTsbTpkxgd 7M7yKCNHBjO/8GUGXmUdVzYBKRF5d30vXBwAiZXXbxmbgheasRySuLBvxRhLDVcN8sIQ Toi+thDq5MWAzU3LayVBrT5qfb9yRJpzXQPAveV+aVpOO+V/m917P2idtsl0ik/VgilC Jfw/MC0ByNLcVAXSD/B1GXPg8soH27pZk8pdvHYrjhjrSkRIJbGcAy3RWfqECV2hicmF 25DCg3jbAnndSIfMq1r8NaTfqCPySHJPj6Z5zDp5UiiRq3EgOPLxhMhf/Umbt+o8Gmvz 2UmA== X-Gm-Message-State: ANoB5plmS4ZNhGCNFpTB18qUOqVwTuvUTAPlE749x1u5cwtUY5ObnxxG 7EtnH+9oH8WAAytJEbCiMoMlHBt7lqRtiA== X-Google-Smtp-Source: AA0mqf79AyazuLtjXg72fI9A7E59qHQZ/9oSMktAk9Ii7br/oTDXqhkfZ3E5pk1RgElZplB0gDOuyQ== X-Received: by 2002:a5d:4584:0:b0:241:ec41:9f1f with SMTP id p4-20020a5d4584000000b00241ec419f1fmr5453331wrq.162.1669312298504; Thu, 24 Nov 2022 09:51:38 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id bi8-20020a05600c3d8800b003c701c12a17sm6394192wmb.12.2022.11.24.09.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 09:51:37 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Dmitry Osipenko , Daniel Vetter , Srinivas Kandagatla Subject: [PATCH 01/11] misc: fastrpc: Assert held reservation lock for dma-buf mmapping Date: Thu, 24 Nov 2022 17:51:15 +0000 Message-Id: <20221124175125.418702-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124175125.418702-1-srinivas.kandagatla@linaro.org> References: <20221124175125.418702-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: Dmitry Osipenko When userspace mmaps dma-buf's fd, the dma-buf reservation lock must be held. Add locking sanity check to the dma-buf mmaping callback to ensure that the locking assumption won't regress in the future. Suggested-by: Daniel Vetter Signed-off-by: Dmitry Osipenko Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 80811e852d8f..c6b9ddaa698b 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -692,6 +693,8 @@ static int fastrpc_mmap(struct dma_buf *dmabuf, struct fastrpc_buf *buf =3D dmabuf->priv; size_t size =3D vma->vm_end - vma->vm_start; =20 + dma_resv_assert_held(dmabuf->resv); + return dma_mmap_coherent(buf->dev, vma, buf->virt, FASTRPC_PHYS(buf->phys), size); } --=20 2.25.1 From nobody Fri Apr 26 14:14:54 2024 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 6E576C433FE for ; Thu, 24 Nov 2022 17:51:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229682AbiKXRvt (ORCPT ); Thu, 24 Nov 2022 12:51:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbiKXRvm (ORCPT ); Thu, 24 Nov 2022 12:51:42 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61634C1F77 for ; Thu, 24 Nov 2022 09:51:41 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id cl5so3450530wrb.9 for ; Thu, 24 Nov 2022 09:51:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=h0J+ugIJ0lSNoX8rurDzNvXKfWJes9/BQo4T8s3+pWU=; b=pG5+Nx2wJu0RIfHviyjO3qsjpAE2KMJo+ZRThiMO566MYUtyjXI6moQyQvGMbHJpaK ikIxtMjGOsNTLKNcQ3exZW8a1LF5qVE+rA4rh7z0o1V7VqyIPGsvTBRViUozjpoJaKc2 6o94FYbEQ/KGzLmJnrBUWInc/j5pYAi6I76ZAOIEA5C7jyJ2fABGquIDipLWTESpBpxN lwKj/3ym6HUQR4FgWDfdzulPunTqcHzCC5Lm849H7lWD03mygxIPvS8bJdhPckgB+yqd +0jEuVL375WtvqzRu7e0P4RLTZZ7wGDxMb8DkCAfResgU+FmW6MetMoNMtsONvs7+mR3 C03A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=h0J+ugIJ0lSNoX8rurDzNvXKfWJes9/BQo4T8s3+pWU=; b=sBZrBicoQJBOQfssW+AX6TU2eI83poSUy72ho8R4agaN7qxGssx6Kiwb6WPQPoVeAf BcHGcuTpBC32nPAP9M6bbA7kB2bE0yf3htR5+L62flI8NHGLdG+PWlccZSBeJY5U1owc hTi7E91sC85EIqziUNbZSmtBGwKFk4Y9wEmKps7Gdg+5rb5kxhH6L+BqOiWFxoltqVY/ q+mr0iJOn2RNvfU001gj7iY+WVTlIB+8UA5bzBqQAxDPhpYoaJxr8L8VXX7QIzh1C3jf cjrw4INsYYIZ5VrflonkqqJoqB1R98Xj9tFd9aweISXagDSQU10wdxDuLH+Vbi3Q/SNE dgWg== X-Gm-Message-State: ANoB5pmj5EeHHFFMqtiUDKwH6zmsg1xKHs+GfQ3xKIInOO1XNUiHFNjP nMJOghJgEPfX+B1RMGCXRkFoYQ== X-Google-Smtp-Source: AA0mqf68gwP7ATKpznGpcyPgSw5e7j6U38AtVRozWrIz4lZoYnIk+ntkF2FdZitj0TY27w6TbDRTMw== X-Received: by 2002:a05:6000:12cb:b0:236:62e3:6202 with SMTP id l11-20020a05600012cb00b0023662e36202mr20991346wrx.47.1669312299905; Thu, 24 Nov 2022 09:51:39 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id bi8-20020a05600c3d8800b003c701c12a17sm6394192wmb.12.2022.11.24.09.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 09:51:39 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Neil Armstrong , Srinivas Kandagatla Subject: [PATCH 02/11] dt-bindings: misc: qcom,fastrpc: increase allowed iommus entries Date: Thu, 24 Nov 2022 17:51:16 +0000 Message-Id: <20221124175125.418702-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124175125.418702-1-srinivas.kandagatla@linaro.org> References: <20221124175125.418702-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: Abel Vesa The fastrpc components on the SM8550 SoC can require up to 3 IOMMU entries, this bumps the maxItems to 3 for this purpose. Signed-off-by: Abel Vesa Signed-off-by: Neil Armstrong Signed-off-by: Srinivas Kandagatla --- Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml b/Doc= umentation/devicetree/bindings/misc/qcom,fastrpc.yaml index d7576f8ac94b..1ab9588cdd89 100644 --- a/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml +++ b/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml @@ -79,7 +79,7 @@ patternProperties: =20 iommus: minItems: 1 - maxItems: 2 + maxItems: 3 =20 qcom,nsessions: $ref: /schemas/types.yaml#/definitions/uint32 --=20 2.25.1 From nobody Fri Apr 26 14:14:54 2024 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 3CB3CC4332F for ; Thu, 24 Nov 2022 17:51:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229731AbiKXRvw (ORCPT ); Thu, 24 Nov 2022 12:51:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229569AbiKXRvn (ORCPT ); Thu, 24 Nov 2022 12:51:43 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9291AC1F77 for ; Thu, 24 Nov 2022 09:51:42 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id g12so3434511wrs.10 for ; Thu, 24 Nov 2022 09:51:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=PHd3FytA/femKWEdUMvYef6FMWectBCCK+YzjMDjemI=; b=V9bTAl4Xw4U+QYcQYY07x2tfUjk6lRtUoU+gGn7nqddBgYA/ZDwzrxXdB6wlqbYU81 TCb6yJJUMKcFB3jMT5ahJRV6lFp61tCX9VikYauK05qiHDTesWzCXf8LQhFQId3OhKPf e76x3r1opcjFNDS8uNBhtGxe0ogG3CXqiE5VLr3kYljmEUZLcLJDqWC/z70tb179TXJM Wg3M2xEM9uVs1VOCdv/yC/rrThnCK1+jYnWZI0zITbAYGHZakwbK6debzRZZEH/xwh9N +FvA7RVNprZupUrJzbMhQb+J/ERmZv0eQEKLmU9EuXWAxZhoHp+A/03kG6wNefBND05I jPbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=PHd3FytA/femKWEdUMvYef6FMWectBCCK+YzjMDjemI=; b=xe+gEmXEE4S1AyeLHhfV24k2dI+bA1l3FxCmvOSVP1uMYDK1LTHZI2lE6KRPWMn5i9 vaoAYaHuZUJxS3tdR2d5x8XIg6jHAqVXXUu2WOdHFSJ8lGa3+xll5PPzP1b0jxLcpi0a hXQ3NVQDKcCtL9NhCmsG1t0MQgPVLcoetK/TAcVOmCD3R80uy2aFB02pq4Whp6ZoU6h4 xwj2L1CCA2/1aui1jvj7dN9Ph489JdXYY+tFf2c62DOIj3qKiJ3l5Hhexl2rAY6c5UQ3 TT4ZH6l2WV72fJIQY4dSTtP0edzVyosti/KOe1H2yesA5fFSSBIcpXfUqS8KTpcOs64U sdrg== X-Gm-Message-State: ANoB5plWRdG3piGicmuk8iNTgVluzng4LXMnUIfbXwSmNhi+tVQAPcnR FiaTnjeG0DRPWRC9b8cYFNFbt1Zs3D1ZPA== X-Google-Smtp-Source: AA0mqf70xiOZyMF3AXAgI2fvs8pBe3Qwu5mRd1W/dUsUgAIpSIUO9xMd95vUyCy/ivu1Gzh83kU55w== X-Received: by 2002:adf:fcd0:0:b0:241:cc8a:7445 with SMTP id f16-20020adffcd0000000b00241cc8a7445mr10879237wrs.521.1669312301030; Thu, 24 Nov 2022 09:51:41 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id bi8-20020a05600c3d8800b003c701c12a17sm6394192wmb.12.2022.11.24.09.51.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 09:51:40 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH 03/11] misc: fastrpc: Rename audio protection domain to root Date: Thu, 24 Nov 2022 17:51:17 +0000 Message-Id: <20221124175125.418702-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124175125.418702-1-srinivas.kandagatla@linaro.org> References: <20221124175125.418702-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: Abel Vesa The AUDIO_PD will be done via static pd, so the proper name here is actually ROOT_PD. Signed-off-by: Abel Vesa Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index c6b9ddaa698b..545b7dea68bc 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -84,7 +84,7 @@ #define FASTRPC_RMID_INIT_MEM_UNMAP 11 =20 /* Protection Domain(PD) ids */ -#define AUDIO_PD (0) /* also GUEST_OS PD? */ +#define ROOT_PD (0) #define USER_PD (1) #define SENSORS_PD (2) =20 @@ -1892,7 +1892,7 @@ static long fastrpc_device_ioctl(struct file *file, u= nsigned int cmd, err =3D fastrpc_invoke(fl, argp); break; case FASTRPC_IOCTL_INIT_ATTACH: - err =3D fastrpc_init_attach(fl, AUDIO_PD); + err =3D fastrpc_init_attach(fl, ROOT_PD); break; case FASTRPC_IOCTL_INIT_ATTACH_SNS: err =3D fastrpc_init_attach(fl, SENSORS_PD); --=20 2.25.1 From nobody Fri Apr 26 14:14:54 2024 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 59D44C433FE for ; Thu, 24 Nov 2022 17:51:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229775AbiKXRv4 (ORCPT ); Thu, 24 Nov 2022 12:51:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229645AbiKXRvo (ORCPT ); Thu, 24 Nov 2022 12:51:44 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3B4F107E52 for ; Thu, 24 Nov 2022 09:51:43 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id s5so3483168wru.1 for ; Thu, 24 Nov 2022 09:51:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=e5v771DEFc9rL1zQ1Yv2p2JInBg9pG0PvBjFvduECqo=; b=nl6Qpc9LUPQ1/U+y2XCzvo51QK9XwuwvEhKETGkJYvSmHGfJmLem2BjLxkPV81S6C8 sflcIw+PJuN5V3OCspIoG5mfVv8g7kRbjarRhvx7R7EaS1Hrwmm7x4cNtu2lpqQ5iIEP +Gx/Cab+AyLnqnQkh+YRW9dtOhpKRrU+tOqw+Nw4HZ699yZ94aJcFPT3HzoL4DkxJN// upYqbp2nA+8RH0iLaRRAfbun+PczTc+5MP0lKhuvXSpKK7k9yG5/wiNqitXgit73TsNo FAhleGi8iV3rZ+t05LJj0oE8JBUbbIZacQnBd7yM2s2WJ6zvKm/QDSWFBv6/ItF7Bp2r aP8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=e5v771DEFc9rL1zQ1Yv2p2JInBg9pG0PvBjFvduECqo=; b=yQY8kenFwDa7PUsihCnqs/QB1mSvO+UzFE8NnYFQgPhog3byx0pLnUwWQ81xmJ2i4b f2Lhopqora/m0HyEenR5jvkkvzZL0+BlrV70XpDyqXvk4FLt0ljfdKzIMhYLxAr5DDaE SzFkbHF66LNoqK5dPd/HTSpOfxyuGHj7vaY6sjCpMl6TTFXPHHXur826+1DnSXYMAhtK rvfBz92R8oqF8S4Se7hkAWFyYvwLY70ArKuXVj4IajBIwNeIyB5XtfB4YLEgc6S58PA7 XL7eU43q1CUAe1ngrQSaf12xm546p40K/wV9Flc95FGakKTa41HIE090HepdmWFeJ11i A/+A== X-Gm-Message-State: ANoB5pkwvrY4dOlKp0cB463sjgSzwIwc53fmBUJ5/JZhc/PXrS3MIOBU hKhBYGSRNg5Vv9avB8gzP0XV6g== X-Google-Smtp-Source: AA0mqf6UKLk9Lk4qE9FWHgQJ14qRqLHCPhurA3KE5Y0uih28Sgoe+Tqt3S+qP2v8BXY2U8XPV4Zh0w== X-Received: by 2002:a5d:6486:0:b0:241:ba9c:cc65 with SMTP id o6-20020a5d6486000000b00241ba9ccc65mr20343872wri.443.1669312302331; Thu, 24 Nov 2022 09:51:42 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id bi8-20020a05600c3d8800b003c701c12a17sm6394192wmb.12.2022.11.24.09.51.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 09:51:41 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH 04/11] misc: fastrpc: Add reserved mem support Date: Thu, 24 Nov 2022 17:51:18 +0000 Message-Id: <20221124175125.418702-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124175125.418702-1-srinivas.kandagatla@linaro.org> References: <20221124175125.418702-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: Abel Vesa The reserved mem support is needed for CMA heap support, which will be used by AUDIOPD. Signed-off-by: Abel Vesa Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 545b7dea68bc..86d11ffadf29 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -20,6 +20,7 @@ #include #include #include +#include =20 #define ADSP_DOMAIN_ID (0) #define MDSP_DOMAIN_ID (1) @@ -2071,6 +2072,9 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *r= pdev) return -EINVAL; } =20 + if (of_reserved_mem_device_init_by_idx(rdev, rdev->of_node, 0)) + dev_info(rdev, "no reserved DMA memory for FASTRPC\n"); + vmcount =3D of_property_read_variable_u32_array(rdev->of_node, "qcom,vmids", &vmids[0], 0, FASTRPC_MAX_VMIDS); if (vmcount < 0) --=20 2.25.1 From nobody Fri Apr 26 14:14:54 2024 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 440A1C433FE for ; Thu, 24 Nov 2022 17:52:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229786AbiKXRwB (ORCPT ); Thu, 24 Nov 2022 12:52:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbiKXRvp (ORCPT ); Thu, 24 Nov 2022 12:51:45 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26F1D13F4BE for ; Thu, 24 Nov 2022 09:51:45 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id bs21so3462920wrb.4 for ; Thu, 24 Nov 2022 09:51:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=cTmLcUHM8TPUmaE0W/RaZtsLjw1tkQ7u3GK43vuBULU=; b=fO7DrylENu6t49oXq95ToTkrDPr9tSDxEM4MDfbVOrz7CbItBaACnnq6/eHUViKrje nZpa2kMdsY+ri9PUm/kdFP4UhMQDGAlABXG47GqzQ/01TzfsszJ2iP8irOGLb/0ggec3 j3P7jXOKA8vMg0JBPDC3r+3w+V6U41xK5q4624MDGlcYM18iRBAHNmIm3A7ZqgTfGU0h /JOmxc2znQVFJ7EcveBmG6R251GG2aKpTP3hB5s6MsuzppAez+ItEVxnx2GkwtkXFQ95 j233D917ZlzGwcOQIH0CprdE4Sddyg4Sl0FnkYZ0shS8K17MSCmDa4rSjUqjDUq/CRKY PhtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=cTmLcUHM8TPUmaE0W/RaZtsLjw1tkQ7u3GK43vuBULU=; b=Om8zcpeBT65ttxoQKy7ofotFQs2w8O1AOvE58ni/wM+asuFSKUedfGehRQ+S4jhBY1 JBa55FK9LeB1HwlnDTK+/4DtUQ2K+QKwy28L08Dd8ZBOqGVwHvGZIiYzsCaUJ4YsI/Ul FUKQ9nnv/qTQ5GilckxV8cG2m5kQj8Ep0yJBw7LeYZvya1FOGCBmfdE/HoLKdra55xJK oz/t9EuMkjg0XKGymM/8PRPYFep6cHAj++h3OkaUbCFGfccZXWrz0mYChgFNkxEAGnOl xb1knlmSygZZqNO1KPgqXRZXnHBvJ86+R7mTcOmegQc0X6ttWEuEmm6s9bV1Gm3prkzU mkrQ== X-Gm-Message-State: ANoB5pmVqc0Tyu4jYKNMPCvFOGd1Ol0vUZwwauD8QVUppBRi2lyaRWSu arNGVa1814IqPpEvJRPoQmvqJQ== X-Google-Smtp-Source: AA0mqf6JkG5XG2ut6luCUpi8fkJP/8kW9Ro0altTUIpC1y+0sl7prGtJQWrtDGVDSfg+5TgI6Dfimw== X-Received: by 2002:adf:f48f:0:b0:236:715c:aaa6 with SMTP id l15-20020adff48f000000b00236715caaa6mr14334046wro.25.1669312303538; Thu, 24 Nov 2022 09:51:43 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id bi8-20020a05600c3d8800b003c701c12a17sm6394192wmb.12.2022.11.24.09.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 09:51:43 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH 05/11] misc: fastrpc: Add fastrpc_remote_heap_alloc Date: Thu, 24 Nov 2022 17:51:19 +0000 Message-Id: <20221124175125.418702-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124175125.418702-1-srinivas.kandagatla@linaro.org> References: <20221124175125.418702-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: Abel Vesa Split fastrpc_buf_alloc in such a way it allows allocation of remote heap too and add fastrpc_remote_heap_alloc to do so. Signed-off-by: Abel Vesa Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 86d11ffadf29..0ddad976a4d2 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -380,7 +380,7 @@ static void fastrpc_buf_free(struct fastrpc_buf *buf) kfree(buf); } =20 -static int fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev, +static int __fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev, u64 size, struct fastrpc_buf **obuf) { struct fastrpc_buf *buf; @@ -408,14 +408,37 @@ static int fastrpc_buf_alloc(struct fastrpc_user *fl,= struct device *dev, return -ENOMEM; } =20 + *obuf =3D buf; + + return 0; +} + +static int fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev, + u64 size, struct fastrpc_buf **obuf) +{ + int ret; + struct fastrpc_buf *buf; + + ret =3D __fastrpc_buf_alloc(fl, dev, size, obuf); + if (ret) + return ret; + + buf =3D *obuf; + if (fl->sctx && fl->sctx->sid) buf->phys +=3D ((u64)fl->sctx->sid << 32); =20 - *obuf =3D buf; - return 0; } =20 +static int fastrpc_remote_heap_alloc(struct fastrpc_user *fl, struct devic= e *dev, + u64 size, struct fastrpc_buf **obuf) +{ + struct device *rdev =3D &fl->cctx->rpdev->dev; + + return __fastrpc_buf_alloc(fl, rdev, size, obuf); +} + static void fastrpc_channel_ctx_free(struct kref *ref) { struct fastrpc_channel_ctx *cctx; --=20 2.25.1 From nobody Fri Apr 26 14:14:54 2024 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 965E9C433FE for ; Thu, 24 Nov 2022 17:52:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229777AbiKXRv7 (ORCPT ); Thu, 24 Nov 2022 12:51:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbiKXRvv (ORCPT ); Thu, 24 Nov 2022 12:51:51 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BF30109599 for ; Thu, 24 Nov 2022 09:51:46 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id d1so3430643wrs.12 for ; Thu, 24 Nov 2022 09:51:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=Vup2T8n4HhZF0U9tpTO6VabW8eaW07MBYBBBLUca2B4=; b=z1rd8ZVZ8/yWSTEgtwkLFEgJ0iVO4O9RKQMMvx/lY3fMHNTc/rUCaRnOPo4yJnWj6b Y8T6tWEUHNsitwA4aA1s+q7PsUwN9AmDqIhdW7UoN7zxDvb7VO2IEwigTtEpv6q+1pVQ e5rFLpur380IYSxFNrougwU/sy9KTPkrE57Gopdb4nvRmWnetE1clntNBRJv3DS2ERTK JE3p7V99xAKdohCffWQb+lRbJK8W8f94Hyya2doMcfaDLAcwGwGcmj6hO7wpCtVO/Fn5 Ncu0iVeYtz1PQrEKFaPXSnjQbN0XuuBbBcDZSufMuXtK1hbsnDbMPUjqSLmryMpcilwl 3UPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Vup2T8n4HhZF0U9tpTO6VabW8eaW07MBYBBBLUca2B4=; b=KqlHlx5uqhXy3pDrNanzjlg3BUjCoY9WU78ckEqIpn7oj52byfJ0BSRAs+pqFytJ8J jiLosGLuUV/kVDRqmolRB3UxoHeNUdLMs/XwjaXaQ90OvegXXQ53oiNSm797Z0hQ1ICp f6f6snDNB5zb/Bua5V201yNqKzVkvKSSMZhijlhZISWySs5EjUAdfE8c8Ldlsaf/LWgY C3ZKWf8ucxh09yV8IESBzlozq2lKA5G+n16D0G/na9cGZm81kBziehVwTrmeVH/qKY/n hlmXehhv4buYjxEQhsTYVi2ydT5bXUVnZDbG33VxxGj/yRAToJsAQDUFAsRpvTUC1NkJ Gn0g== X-Gm-Message-State: ANoB5pnVmpNRa0suunBXlsR0DNgnhk5DCR5+HOv1xRm01dJoR3S/ipj2 aODxK5cF/LtMhWAUgeUU3rWn7DVlOL7LSw== X-Google-Smtp-Source: AA0mqf40XwQEHCP+taZvTgll0Nyt4S+Hj0pe8bAsuov/tNW1IEz7O62iJ4tUggvjPpaD9AoiD/MrMQ== X-Received: by 2002:adf:ff84:0:b0:241:ff1d:f9e8 with SMTP id j4-20020adfff84000000b00241ff1df9e8mr2162856wrr.598.1669312304569; Thu, 24 Nov 2022 09:51:44 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id bi8-20020a05600c3d8800b003c701c12a17sm6394192wmb.12.2022.11.24.09.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 09:51:43 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH 06/11] misc: fastrpc: Use fastrpc_map_put in fastrpc_map_create on fail Date: Thu, 24 Nov 2022 17:51:20 +0000 Message-Id: <20221124175125.418702-7-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124175125.418702-1-srinivas.kandagatla@linaro.org> References: <20221124175125.418702-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: Abel Vesa Move the kref_init right after the allocation so that we can use fastrpc_map_put on any following error case. Signed-off-by: Abel Vesa Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 0ddad976a4d2..b1e16bd56c6b 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -748,6 +748,8 @@ static int fastrpc_map_create(struct fastrpc_user *fl, = int fd, return -ENOMEM; =20 INIT_LIST_HEAD(&map->node); + kref_init(&map->refcount); + map->fl =3D fl; map->fd =3D fd; map->buf =3D dma_buf_get(fd); @@ -774,7 +776,6 @@ static int fastrpc_map_create(struct fastrpc_user *fl, = int fd, map->size =3D len; map->va =3D sg_virt(map->table->sgl); map->len =3D len; - kref_init(&map->refcount); =20 if (attr & FASTRPC_ATTR_SECUREMAP) { /* @@ -804,7 +805,7 @@ static int fastrpc_map_create(struct fastrpc_user *fl, = int fd, attach_err: dma_buf_put(map->buf); get_err: - kfree(map); + fastrpc_map_put(map); =20 return err; } --=20 2.25.1 From nobody Fri Apr 26 14:14:54 2024 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 5FAC0C433FE for ; Thu, 24 Nov 2022 17:52:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229798AbiKXRwH (ORCPT ); Thu, 24 Nov 2022 12:52:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229720AbiKXRvw (ORCPT ); Thu, 24 Nov 2022 12:51:52 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9146D1400F0 for ; Thu, 24 Nov 2022 09:51:47 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id 83-20020a1c0256000000b003d03017c6efso3765479wmc.4 for ; Thu, 24 Nov 2022 09:51:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=EGKfeLLXR8UXYClXrSFQFEuyRrCPr0drWE3Ez3BPlNU=; b=vGbQnE5rTF9zbT/k+8m87lu/6wkEriSHS8n2R84eGdUHEZ0ndOYQmmQ90Sd5j3DGFL Fb0U3vQyj/67eq8zLfpRjWJL2yFIrblLs3tn01mpxydkycvxSJb1tNkmLucVlY5gIdkX 4XzE17beahHVapYTDcqubUM5daz691L4dWq/6+I8Yk9hpj01qmStMPcr9Jr0Pl7Tut81 DFYK5cUGSdhYjJGCWnblp9qY794rcXcMkYYI21tcYPdDlFAlmD0FBZOyVZEmJR+uNd75 i0uVZRbDhBvMVEUHfk5dgwG7LkfPuoBNflPWZNMM/LIZ5zzhlbowFMXgxHcHFrCt5gkb /Tsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=EGKfeLLXR8UXYClXrSFQFEuyRrCPr0drWE3Ez3BPlNU=; b=wOu9AS5xctD6H/PCU7bdnbJOkv+A9xUTR+6NskAPlDSndWgVkkA1bV3cWRonOPVg1x GW2qbS0gr2CRP+sw4wMazOcdVTemon2wFqDltAEHhhmP9pd1sH1+AUKpuJqrbcuZwpWa CKqa/xesG89pT79Umo7pKEvZSo/fuidpWWY5UR2mPxC/AS4VKzGjto5MlDkyvGWT86e9 JHCn5xIMTND7SwNGBJVozh2YVjVsNvfu0xJxhqx38CrsEDGv0qa0PISVZB7Z+QcBt1wZ Y3T5V/t6xy1ewlYWpYeADEP3cWze5Rz+pEjfKD61Iaer992oVoH4ormSIZwU3aCt97Pf wNqA== X-Gm-Message-State: ANoB5pn4BAg4QAB/QeQ46A8mJI5xboLaCgRA7VgIkbF/yBdfvYQ+gOQh GJeLyqfhCH+lZBECqkpBmUUV+Q== X-Google-Smtp-Source: AA0mqf6UozkIYPaSA618Jw6J6qWa2uG/imwsd/96grIBbjfZhvx7Vka7SUgJ1SxxmvQ3IOzL9EMbdQ== X-Received: by 2002:a05:600c:602a:b0:3c6:c05a:a50e with SMTP id az42-20020a05600c602a00b003c6c05aa50emr23904939wmb.81.1669312306091; Thu, 24 Nov 2022 09:51:46 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id bi8-20020a05600c3d8800b003c701c12a17sm6394192wmb.12.2022.11.24.09.51.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 09:51:45 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH 07/11] misc: fastrpc: Rework fastrpc_req_munmap Date: Thu, 24 Nov 2022 17:51:21 +0000 Message-Id: <20221124175125.418702-8-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124175125.418702-1-srinivas.kandagatla@linaro.org> References: <20221124175125.418702-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: Abel Vesa Move the lookup of the munmap request to the fastrpc_req_munmap and pass on only the buf to the lower level fastrpc_req_munmap_impl. That way we can use the lower level fastrpc_req_munmap_impl on error path in fastrpc_req_mmap to free the buf without searching for the munmap request it belongs to. Signed-off-by: Abel Vesa Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 47 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index b1e16bd56c6b..9a373fcb4ba0 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1633,30 +1633,14 @@ static int fastrpc_get_dsp_info(struct fastrpc_user= *fl, char __user *argp) return 0; } =20 -static int fastrpc_req_munmap_impl(struct fastrpc_user *fl, - struct fastrpc_req_munmap *req) +static int fastrpc_req_munmap_impl(struct fastrpc_user *fl, struct fastrpc= _buf *buf) { struct fastrpc_invoke_args args[1] =3D { [0] =3D { 0 } }; - struct fastrpc_buf *buf =3D NULL, *iter, *b; struct fastrpc_munmap_req_msg req_msg; struct device *dev =3D fl->sctx->dev; int err; u32 sc; =20 - spin_lock(&fl->lock); - list_for_each_entry_safe(iter, b, &fl->mmaps, node) { - if ((iter->raddr =3D=3D req->vaddrout) && (iter->size =3D=3D req->size))= { - buf =3D iter; - break; - } - } - spin_unlock(&fl->lock); - - if (!buf) { - dev_err(dev, "mmap not in list\n"); - return -EINVAL; - } - req_msg.pgid =3D fl->tgid; req_msg.size =3D buf->size; req_msg.vaddr =3D buf->raddr; @@ -1682,12 +1666,29 @@ static int fastrpc_req_munmap_impl(struct fastrpc_u= ser *fl, =20 static int fastrpc_req_munmap(struct fastrpc_user *fl, char __user *argp) { + struct fastrpc_buf *buf =3D NULL, *iter, *b; struct fastrpc_req_munmap req; + struct device *dev =3D fl->sctx->dev; =20 if (copy_from_user(&req, argp, sizeof(req))) return -EFAULT; =20 - return fastrpc_req_munmap_impl(fl, &req); + spin_lock(&fl->lock); + list_for_each_entry_safe(iter, b, &fl->mmaps, node) { + if ((iter->raddr =3D=3D req.vaddrout) && (iter->size =3D=3D req.size)) { + buf =3D iter; + break; + } + } + spin_unlock(&fl->lock); + + if (!buf) { + dev_err(dev, "mmap\t\tpt 0x%09llx [len 0x%08llx] not in list\n", + req.vaddrout, req.size); + return -EINVAL; + } + + return fastrpc_req_munmap_impl(fl, buf); } =20 static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) @@ -1696,7 +1697,6 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, = char __user *argp) struct fastrpc_buf *buf =3D 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 =3D fl->sctx->dev; @@ -1758,11 +1758,8 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl,= char __user *argp) spin_unlock(&fl->lock); =20 if (copy_to_user((void __user *)argp, &req, sizeof(req))) { - /* unmap the memory and release the buffer */ - req_unmap.vaddrout =3D buf->raddr; - req_unmap.size =3D buf->size; - fastrpc_req_munmap_impl(fl, &req_unmap); - return -EFAULT; + err =3D -EFAULT; + goto err_assign; } =20 dev_dbg(dev, "mmap\t\tpt 0x%09lx OK [len 0x%08llx]\n", @@ -1770,6 +1767,8 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, = char __user *argp) =20 return 0; =20 +err_assign: + fastrpc_req_munmap_impl(fl, buf); err_invoke: fastrpc_buf_free(buf); =20 --=20 2.25.1 From nobody Fri Apr 26 14:14:54 2024 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 4C897C433FE for ; Thu, 24 Nov 2022 17:52:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229816AbiKXRwN (ORCPT ); Thu, 24 Nov 2022 12:52:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229743AbiKXRvw (ORCPT ); Thu, 24 Nov 2022 12:51:52 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F209A14A2ED for ; Thu, 24 Nov 2022 09:51:48 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id v7so1822737wmn.0 for ; Thu, 24 Nov 2022 09:51:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=5uJnnFI92/NPRiP6WIUFOR8d16yKk84qiKlemig/24Y=; b=WmiNc6ldia7GRs/sXSbOcmyBhED2RsdsBDLtIlWDdgtQzym8uQg4jacEy85AG4KPqk kn5z4dYKJ/f+p3F5jZ71qch0PE+zHW762REuGfHcnYOdT1iBuvO78kK7sJbbbrFQiQ0N FPRJXLS2RWxAVpHenpiZUM0hA4ERezYTjqPecunuYDtQ+InYSH9D/tB1feVeucjiODF/ j3Z+R3FOEFxVKwVtmkgw7dNwSE/gccExpjwqk7bhas7pDBwy6RbISk37gxVIIjCywyPZ KVYEN0IwzoGMV+hU5O7SpWar8xWJRXeiXXf0blUciaGQQKjONIIsG7JkmN8Yst+0C616 zXYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=5uJnnFI92/NPRiP6WIUFOR8d16yKk84qiKlemig/24Y=; b=tp0x9PHDC0EKluJDzHfvbrvpYzxmByUxlTXqBddBTQI9sLkSQLGzBZEaL+WMKXD1u0 nywrSOxswTl8G9je+YQJ98XARz+zzMTD8nfLxQvHRoKidmP6Ugux4rkuxvbH81xVfZCO Af+vwHV2fRB3/8FZ6H7Q9yKOzXVu8GgTeH2z57CVEyAx37OnrcHRQLBs1uuWrbgDOf42 2F0+7q1sW14mV9J8vIASyACdTPBjeJ5UfBwhrIiki8zXCCORmTe5eUVOyCqPAptJP/mr 1EFxe4oAEXBLRh6yI+EIrTmWGj02PvXlFjwIJckYMP81j1WfKcaT0bY0lgULiOCPSjkM iz9w== X-Gm-Message-State: ANoB5pnXi07wJkoWZtcFdDg6nb55NP8j8mgg87LmvdIG2UgLKmJd57DZ VcCC2hJ/Soe97fm1Yg8UkYvicg== X-Google-Smtp-Source: AA0mqf6laUILDqrp3T6xGVOmtQTAXM01STzH0hbg1pk8/aLrmYxY6qXoYSQLK+kLxDDLnHv+B3AmgA== X-Received: by 2002:a1c:f401:0:b0:3c7:84d:72d with SMTP id z1-20020a1cf401000000b003c7084d072dmr10929864wma.181.1669312307522; Thu, 24 Nov 2022 09:51:47 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id bi8-20020a05600c3d8800b003c701c12a17sm6394192wmb.12.2022.11.24.09.51.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 09:51:46 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH 08/11] misc: fastrpc: Add support for audiopd Date: Thu, 24 Nov 2022 17:51:22 +0000 Message-Id: <20221124175125.418702-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124175125.418702-1-srinivas.kandagatla@linaro.org> References: <20221124175125.418702-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: Abel Vesa In order to be able to start the adsp listener for audiopd using adsprpcd, we need to add the corresponding ioctl for creating a static process. On that ioctl call we need to allocate the heap. Allocating the heap needs to be happening only once and needs to be kept between different device open calls, so attach it to the channel context to make sure that remains until the RPMSG driver is removed. Then, if there are any VMIDs associated with the static ADSP process, do a call to SCM to assign it. And then, send all the necessary info related to heap to the DSP. Signed-off-by: Abel Vesa Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 135 ++++++++++++++++++++++++++++++++++++ include/uapi/misc/fastrpc.h | 7 ++ 2 files changed, 142 insertions(+) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 9a373fcb4ba0..00e741fd6d91 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -38,8 +38,20 @@ #define FASTRPC_DSP_UTILITIES_HANDLE 2 #define FASTRPC_CTXID_MASK (0xFF0) #define INIT_FILELEN_MAX (2 * 1024 * 1024) +#define INIT_FILE_NAMELEN_MAX (128) #define FASTRPC_DEVICE_NAME "fastrpc" + +/* Add memory to static PD pool, protection thru XPU */ +#define ADSP_MMAP_HEAP_ADDR 4 +/* MAP static DMA buffer on DSP User PD */ +#define ADSP_MMAP_DMA_BUFFER 6 +/* Add memory to static PD pool protection thru hypervisor */ +#define ADSP_MMAP_REMOTE_HEAP_ADDR 8 +/* Add memory to userPD pool, for user heap */ #define ADSP_MMAP_ADD_PAGES 0x1000 +/* Add memory to userPD pool, for LLC heap */ +#define ADSP_MMAP_ADD_PAGES_LLC 0x3000, + #define DSP_UNSUPPORTED_API (0x80000414) /* MAX NUMBER of DSP ATTRIBUTES SUPPORTED */ #define FASTRPC_MAX_DSP_ATTRIBUTES (256) @@ -73,6 +85,7 @@ FASTRPC_BUILD_SCALARS(0, method, in, out, 0, 0) =20 #define FASTRPC_CREATE_PROCESS_NARGS 6 +#define FASTRPC_CREATE_STATIC_PROCESS_NARGS 3 /* Remote Method id table */ #define FASTRPC_RMID_INIT_ATTACH 0 #define FASTRPC_RMID_INIT_RELEASE 1 @@ -262,6 +275,7 @@ struct fastrpc_channel_ctx { u32 dsp_attributes[FASTRPC_MAX_DSP_ATTRIBUTES]; struct fastrpc_device *secure_fdevice; struct fastrpc_device *fdevice; + struct fastrpc_buf *remote_heap; bool secure; bool unsigned_support; }; @@ -1170,6 +1184,7 @@ static int fastrpc_internal_invoke(struct fastrpc_use= r *fl, u32 kernel, spin_unlock(&fl->lock); fastrpc_context_put(ctx); } + if (err) dev_dbg(fl->sctx->dev, "Error: Invoke Failed %d\n", err); =20 @@ -1194,6 +1209,120 @@ static bool is_session_rejected(struct fastrpc_user= *fl, bool unsigned_pd_reques return false; } =20 +static int fastrpc_init_create_static_process(struct fastrpc_user *fl, + char __user *argp) +{ + struct fastrpc_init_create_static init; + struct fastrpc_invoke_args *args; + struct fastrpc_phy_page pages[1]; + char *name; + int err; + struct { + int pgid; + u32 namelen; + u32 pageslen; + } inbuf; + u32 sc; + + args =3D kcalloc(FASTRPC_CREATE_STATIC_PROCESS_NARGS, sizeof(*args), GFP_= KERNEL); + if (!args) + return -ENOMEM; + + if (copy_from_user(&init, argp, sizeof(init))) { + err =3D -EFAULT; + goto err; + } + + if (init.namelen > INIT_FILE_NAMELEN_MAX) { + err =3D -EINVAL; + goto err; + } + + name =3D kzalloc(init.namelen, GFP_KERNEL); + if (!name) { + err =3D -ENOMEM; + goto err; + } + + if (copy_from_user(name, (void __user *)(uintptr_t)init.name, init.namele= n)) { + err =3D -EFAULT; + goto err_name; + } + + if (!fl->cctx->remote_heap) { + err =3D fastrpc_remote_heap_alloc(fl, fl->sctx->dev, init.memlen, + &fl->cctx->remote_heap); + if (err) + goto err_name; + + /* Map if we have any heap VMIDs associated with this ADSP Static Proces= s. */ + if (fl->cctx->vmcount) { + unsigned int perms =3D BIT(QCOM_SCM_VMID_HLOS); + + err =3D qcom_scm_assign_mem(fl->cctx->remote_heap->phys, + (u64)fl->cctx->remote_heap->size, &perms, + fl->cctx->vmperms, fl->cctx->vmcount); + if (err) { + dev_err(fl->sctx->dev, "Failed to assign memory with phys 0x%llx size = 0x%llx err %d", + fl->cctx->remote_heap->phys, fl->cctx->remote_heap->size, err); + goto err_map; + } + } + } + + inbuf.pgid =3D fl->tgid; + inbuf.namelen =3D init.namelen; + inbuf.pageslen =3D 0; + fl->pd =3D USER_PD; + + args[0].ptr =3D (u64)(uintptr_t)&inbuf; + args[0].length =3D sizeof(inbuf); + args[0].fd =3D -1; + + args[1].ptr =3D (u64)(uintptr_t)name; + args[1].length =3D inbuf.namelen; + args[1].fd =3D -1; + + pages[0].addr =3D fl->cctx->remote_heap->phys; + pages[0].size =3D fl->cctx->remote_heap->size; + + args[2].ptr =3D (u64)(uintptr_t) pages; + args[2].length =3D sizeof(*pages); + args[2].fd =3D -1; + + sc =3D FASTRPC_SCALARS(FASTRPC_RMID_INIT_CREATE_STATIC, 3, 0); + + err =3D fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, + sc, args); + if (err) + goto err_invoke; + + kfree(args); + + return 0; +err_invoke: + if (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(fl->cctx->remote_heap->phys, + (u64)fl->cctx->remote_heap->size, + &(fl->cctx->vmperms[0].vmid), &perm, 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); + } +err_map: + fastrpc_buf_free(fl->cctx->remote_heap); +err_name: + kfree(name); +err: + kfree(args); + + return err; +} + static int fastrpc_init_create_process(struct fastrpc_user *fl, char __user *argp) { @@ -1921,6 +2050,9 @@ static long fastrpc_device_ioctl(struct file *file, u= nsigned int cmd, case FASTRPC_IOCTL_INIT_ATTACH_SNS: err =3D fastrpc_init_attach(fl, SENSORS_PD); break; + case FASTRPC_IOCTL_INIT_CREATE_STATIC: + err =3D fastrpc_init_create_static_process(fl, argp); + break; case FASTRPC_IOCTL_INIT_CREATE: err =3D fastrpc_init_create_process(fl, argp); break; @@ -2190,6 +2322,9 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device = *rpdev) if (cctx->secure_fdevice) misc_deregister(&cctx->secure_fdevice->miscdev); =20 + if (cctx->remote_heap) + fastrpc_buf_free(cctx->remote_heap); + of_platform_depopulate(&rpdev->dev); =20 cctx->rpdev =3D NULL; diff --git a/include/uapi/misc/fastrpc.h b/include/uapi/misc/fastrpc.h index 5e29f2cfa42d..f33d914d8f46 100644 --- a/include/uapi/misc/fastrpc.h +++ b/include/uapi/misc/fastrpc.h @@ -13,6 +13,7 @@ #define FASTRPC_IOCTL_MMAP _IOWR('R', 6, struct fastrpc_req_mmap) #define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_req_munmap) #define FASTRPC_IOCTL_INIT_ATTACH_SNS _IO('R', 8) +#define FASTRPC_IOCTL_INIT_CREATE_STATIC _IOWR('R', 9, struct fastrpc_init= _create_static) #define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 10, struct fastrpc_mem_map) #define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 11, struct fastrpc_mem_unmap) #define FASTRPC_IOCTL_GET_DSP_INFO _IOWR('R', 13, struct fastrpc_ioctl_cap= ability) @@ -87,6 +88,12 @@ struct fastrpc_init_create { __u64 file; /* pointer to elf file */ }; =20 +struct fastrpc_init_create_static { + __u32 namelen; /* length of pd process name */ + __u32 memlen; + __u64 name; /* pd process name */ +}; + struct fastrpc_alloc_dma_buf { __s32 fd; /* fd */ __u32 flags; /* flags to map with */ --=20 2.25.1 From nobody Fri Apr 26 14:14:54 2024 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 D9F1DC4332F for ; Thu, 24 Nov 2022 17:52:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229827AbiKXRwO (ORCPT ); Thu, 24 Nov 2022 12:52:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbiKXRvw (ORCPT ); Thu, 24 Nov 2022 12:51:52 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59B0714EC9A for ; Thu, 24 Nov 2022 09:51:50 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id o30so1805714wms.2 for ; Thu, 24 Nov 2022 09:51:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=TKdWE5BFQ1ZKevg2FpHfyLdEPvi7Rl4963q2XP3WFlg=; b=grpg55XU7zA4v2+va0FqIXjIadVRsPFv/tdU7RfIr+Fx61qICib9L6ywZU1s94Ffw/ k2nEsSSXbe5tOCXl6t1GsfSBWFYxswRSJ51o/SblcztdOR4hLS2F55yqr/jpib/xL/nZ xyPWPmyFSyc89emqgHvKRjJc5NJ7SIRwej5hfOKZxcnhIrHzP786BBsg3ouDGGOmUcKV TYirrleMbxPSWoUZevYa4P4yPfkjk3INNaTA+moRD+XW35mBQqqDSHKwe7gW/Sw2inKD QZywCleQNlyfZvt67ve5alXAVQuI/XsDbHkAi8KYqIDrFQUD+QmzQKWxLIrjB/Kesxp5 U7AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=TKdWE5BFQ1ZKevg2FpHfyLdEPvi7Rl4963q2XP3WFlg=; b=NEMjtpV0pgixoUaouvhQ34PBICqXOzCf2+kxTV3ymi368r/6sZhNwUEe9owCt85O6/ lP96vY4hssRW6tzsrlgLS7EZ01CDenWo+1j6Y/VG6k8fBoQ4B8VbAZCXu+Om4eqZMgQS DsJkUkOUy5VmYYrb9gkIViVgX/OEg6bdiM6Ux2FZm4oPku7mn56lLVBVBJ3P+kgyZ6eF 4KNjadz7ibUHRbIbEPLEaxi3Daz7ZSa8lJuv57CP9RX9UmF8KouYCLIILl2yhnJLVqUo Y2VXj+Hc2/nSuuQCwjTndYOnUoPiIuag9MTKVla2yYgts69QLZmZlDrCNR49f2AQtLvc /YMw== X-Gm-Message-State: ANoB5pnNWBJqeNkJ0Czb4iNkf/qfmj1W+Wdrjb30Ip416zZmbixzpaCO k6TDHtSK/C952x/f2Tp3cwh6hQ== X-Google-Smtp-Source: AA0mqf65gkLMVRSfmyn9wM2jKTEE9YhTB1jQSyKgnt2NsW5whLJNzJjP1GO8eWQzsXcQq49dF1aAwA== X-Received: by 2002:a1c:ed01:0:b0:3cf:7d41:f2bb with SMTP id l1-20020a1ced01000000b003cf7d41f2bbmr12165600wmh.62.1669312308863; Thu, 24 Nov 2022 09:51:48 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id bi8-20020a05600c3d8800b003c701c12a17sm6394192wmb.12.2022.11.24.09.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 09:51:48 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH 09/11] misc: fastrpc: Safekeep mmaps on interrupted invoke Date: Thu, 24 Nov 2022 17:51:23 +0000 Message-Id: <20221124175125.418702-10-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124175125.418702-1-srinivas.kandagatla@linaro.org> References: <20221124175125.418702-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: Abel Vesa If the userspace daemon is killed in the middle of an invoke (e.g. audiopd listerner invoke), we need to skip the unmapping on device release, otherwise the DSP will crash. So lets safekeep all the maps only if there is in invoke interrupted, by attaching them to the channel context (which is resident until RPMSG driver is removed), and free them on RPMSG driver remove. Signed-off-by: Abel Vesa Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 00e741fd6d91..3cf76a240b7a 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -276,6 +276,7 @@ struct fastrpc_channel_ctx { struct fastrpc_device *secure_fdevice; struct fastrpc_device *fdevice; struct fastrpc_buf *remote_heap; + struct list_head invoke_interrupted_mmaps; bool secure; bool unsigned_support; }; @@ -1122,6 +1123,8 @@ static int fastrpc_internal_invoke(struct fastrpc_use= r *fl, u32 kernel, struct fastrpc_invoke_args *args) { struct fastrpc_invoke_ctx *ctx =3D NULL; + struct fastrpc_buf *buf, *b; + int err =3D 0; =20 if (!fl->sctx) @@ -1185,6 +1188,13 @@ static int fastrpc_internal_invoke(struct fastrpc_us= er *fl, u32 kernel, fastrpc_context_put(ctx); } =20 + if (err =3D=3D -ERESTARTSYS) { + list_for_each_entry_safe(buf, b, &fl->mmaps, node) { + list_del(&buf->node); + list_add_tail(&buf->node, &fl->cctx->invoke_interrupted_mmaps); + } + } + if (err) dev_dbg(fl->sctx->dev, "Error: Invoke Failed %d\n", err); =20 @@ -2284,6 +2294,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *r= pdev) dev_set_drvdata(&rpdev->dev, data); dma_set_mask_and_coherent(rdev, DMA_BIT_MASK(32)); INIT_LIST_HEAD(&data->users); + INIT_LIST_HEAD(&data->invoke_interrupted_mmaps); spin_lock_init(&data->lock); idr_init(&data->ctx_idr); data->domain_id =3D domain_id; @@ -2308,6 +2319,7 @@ static void fastrpc_notify_users(struct fastrpc_user = *user) static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev) { struct fastrpc_channel_ctx *cctx =3D dev_get_drvdata(&rpdev->dev); + struct fastrpc_buf *buf, *b; struct fastrpc_user *user; unsigned long flags; =20 @@ -2322,6 +2334,9 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device = *rpdev) if (cctx->secure_fdevice) misc_deregister(&cctx->secure_fdevice->miscdev); =20 + list_for_each_entry_safe(buf, b, &cctx->invoke_interrupted_mmaps, node) + list_del(&buf->node); + if (cctx->remote_heap) fastrpc_buf_free(cctx->remote_heap); =20 --=20 2.25.1 From nobody Fri Apr 26 14:14:54 2024 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 9F9FEC4332F for ; Thu, 24 Nov 2022 17:52:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229683AbiKXRw3 (ORCPT ); Thu, 24 Nov 2022 12:52:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229627AbiKXRvz (ORCPT ); Thu, 24 Nov 2022 12:51:55 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B94315B4D8 for ; Thu, 24 Nov 2022 09:51:52 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id i12so3530452wrb.0 for ; Thu, 24 Nov 2022 09:51:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=PryoH4Na1cIsfvTRA0L1CZLJGcy9N2macRHvAEBFkbA=; b=Zi1EzsgG2QlG4e8EUVrheaYLdBT6/+Tllun/yqv2JZmVgXyfnVeEmfmXDka2Wk866a /Lp2izyg3ZbM2Nc2NiHylfQ/8ezsHALBtihO3Zzw/WqHTje5uQFE0Eakzh6DVKzJJ36A N7CjtP5/N5C7eKYJW/GShrP9nMvSkc75eEBS0xsD0cCjfVKQ5Ketg8vbHy1KnE1TnM3y sB4eTxdmxoeyFzCkSl66ptKIThBoJ8IleUazay2ZTIc08wCzs30zsfhDrgSIj3fcO7Iv vdjkB9sxSB7i6rh878UFQhT8smdaaGyrGGH62yYZoVj4jfA+VZoJeHiySCiKhYCIcNp0 Hbjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=PryoH4Na1cIsfvTRA0L1CZLJGcy9N2macRHvAEBFkbA=; b=qt7sttEye179aN8SfQhtYXeKfN/0hWpzb54DTyUQmUyCQDNqn0UVEMynxEEq5+AGkr yGSilpJYQc9A8TBUWf8XlHWFdGgpFW/d7RMIPFTFZQE5++1wS6zy+9rgrb1knkGpxdGr 6YXnpsy62y3RqagmNPapEnYHj21yTj+YeHvpowW+LB02wbVnYN8o5V34VFoXYZpwO1SU mfHqKIFEOPr219QEFRYEFMe6CgPMlZY1rSHSbE2LR9kQYahS5WuvvmKZcvr5xV33UXfh KoIjwVb3gmEYe6kJZvDkxiw2FyKggSmgFkHqJfYMBGqqY3hiq8x2VaXV6VB+nnknpj36 7KfQ== X-Gm-Message-State: ANoB5pk2OU6Al+M0F4kQ4J9I/6KPPNG7kwJkGztppYQkdbARzTWaaicw 9Wt9hM3LggELu3V8j7c6rTW9uA== X-Google-Smtp-Source: AA0mqf697EyavO58iiKvgzz7RcdFYMhwktje2cCID4YcWhiBqmK45iM6nDR5j2sA+kflPTP9+Sbqyw== X-Received: by 2002:a05:6000:18c1:b0:236:5d8c:97fd with SMTP id w1-20020a05600018c100b002365d8c97fdmr21309432wrq.473.1669312310625; Thu, 24 Nov 2022 09:51:50 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id bi8-20020a05600c3d8800b003c701c12a17sm6394192wmb.12.2022.11.24.09.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 09:51:50 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH 10/11] misc: fastrpc: Add mmap request assigning for static PD pool Date: Thu, 24 Nov 2022 17:51:24 +0000 Message-Id: <20221124175125.418702-11-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124175125.418702-1-srinivas.kandagatla@linaro.org> References: <20221124175125.418702-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: Abel Vesa If the mmap request is to add pages and thre are VMIDs associated with that context, do a call to SCM to reassign that memory. Do not do this for remote heap allocation, that is done on init create static process only. Signed-off-by: Abel Vesa Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 3cf76a240b7a..d3147e4313cc 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1845,8 +1845,9 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, = char __user *argp) if (copy_from_user(&req, argp, sizeof(req))) return -EFAULT; =20 - if (req.flags !=3D ADSP_MMAP_ADD_PAGES) { + if (req.flags !=3D ADSP_MMAP_ADD_PAGES && req.flags !=3D ADSP_MMAP_REMOTE= _HEAP_ADDR) { dev_err(dev, "flag not supported 0x%x\n", req.flags); + return -EINVAL; } =20 @@ -1892,6 +1893,22 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl,= char __user *argp) /* let the client know the address to use */ req.vaddrout =3D rsp_msg.vaddr; =20 + /* Add memory to static PD pool, protection thru hypervisor */ + if (req.flags !=3D ADSP_MMAP_REMOTE_HEAP_ADDR && fl->cctx->vmcount) { + struct qcom_scm_vmperm perm; + int err =3D 0; + + 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->vmperms[0].vmid), &perm, 1); + if (err) { + dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx= err %d", + buf->phys, buf->size, err); + goto err_assign; + } + } + spin_lock(&fl->lock); list_add_tail(&buf->node, &fl->mmaps); spin_unlock(&fl->lock); --=20 2.25.1 From nobody Fri Apr 26 14:14:54 2024 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 B91D2C433FE for ; Thu, 24 Nov 2022 17:52:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229747AbiKXRwX (ORCPT ); Thu, 24 Nov 2022 12:52:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbiKXRvz (ORCPT ); Thu, 24 Nov 2022 12:51:55 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E00415B4F7 for ; Thu, 24 Nov 2022 09:51:52 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id bs21so3463261wrb.4 for ; Thu, 24 Nov 2022 09:51:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=rylusfgUDpkkWgalnBLghu7kEy11PXXS0gvZ7chhswg=; b=XPDXYp9KiAJX835BXQlDYnHHGeXq/je8vdMyi6suSfk5joz+t4t3Hi30Uqhrs5LSMY ZtoieTiw+0jj5/harETzmyCF80lZt7CYCpwfWpBGEZR6rghIukacHhfWEvpKOn5iyJna XN5m9TDzeklaY52nPzYMLyANOTuGGWU86Y1RcoJ4Yg2a9JdM4o6jUVqVBkyJUV8lyLpb hnHJResQwXk0qcFzSht+0L5dJEpFEdr1bljA2QzFBEf8kmjV979hIT6Kb+/dNjfKEkn+ 47FHpwUDE3Fal69YeLagMO/96ZcmCCYgRQLpiBSGA8tie10+F1g0ONa3lh249vur0mKb qboA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=rylusfgUDpkkWgalnBLghu7kEy11PXXS0gvZ7chhswg=; b=UNTmCcRYnR1UrK+lY42fD2ALTj4WbdEImi3yRYhuMchU5UDSxW8xRTO4Cgh7K5OjSX mMBxezkv83MSYZjmWOBmhqbM5ruR3CFzaB2zlkf6HQbrhwJJUJOvBMtwM95qPY4dpeXe loIUhI7lDctyvlE9b6nR5brQP1eGhqRmx9c7G6m4bulhXN53gIovmaLFVHd8LecDsNBR /6h2JytNBms+1Jca7aGKBFLJUqaYbhBwmHLrxDuKuF8v1TR4WineONE2oNiG0kxjloBe Q3Sv1mfv608VyHI8hVnd933/jR2eKqybjcshEpIK7G1E4riG7dwm6ai/obIj07txxbgT 2xfA== X-Gm-Message-State: ANoB5pmojEP8A1L1mjhEjQ8PAkTl2y0apbEm68ZlCyKVQomPM3Hh9Dyu Bar2vAsNRh26w4Mm67f+uiSkxve1l3hIvw== X-Google-Smtp-Source: AA0mqf7YYfEU+aHSMZkd+Lg99Olb7J0LABBto9g40UcKL9A2ryrilcIhSjNUOFWh6lzsw23IoZG0mg== X-Received: by 2002:adf:dc02:0:b0:236:77f4:6e19 with SMTP id t2-20020adfdc02000000b0023677f46e19mr21398695wri.638.1669312311888; Thu, 24 Nov 2022 09:51:51 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id bi8-20020a05600c3d8800b003c701c12a17sm6394192wmb.12.2022.11.24.09.51.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 09:51:51 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH 11/11] misc: fastrpc: Add dma_mask to fastrpc_channel_ctx Date: Thu, 24 Nov 2022 17:51:25 +0000 Message-Id: <20221124175125.418702-12-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124175125.418702-1-srinivas.kandagatla@linaro.org> References: <20221124175125.418702-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: Abel Vesa dma_set_mask_and_coherent only updates the mask to which the device dma_mask pointer points to. Add a dma_mask to the channel ctx and set the device dma_mask to point to that, otherwise the dma_set_mask will return an error and the dma_set_coherent_mask will be skipped too. Signed-off-by: Abel Vesa Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index d3147e4313cc..9ddcaa4def06 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -279,6 +279,7 @@ struct fastrpc_channel_ctx { struct list_head invoke_interrupted_mmaps; bool secure; bool unsigned_support; + u64 dma_mask; }; =20 struct fastrpc_device { @@ -2309,6 +2310,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *r= pdev) kref_init(&data->refcount); =20 dev_set_drvdata(&rpdev->dev, data); + rdev->dma_mask =3D &data->dma_mask; dma_set_mask_and_coherent(rdev, DMA_BIT_MASK(32)); INIT_LIST_HEAD(&data->users); INIT_LIST_HEAD(&data->invoke_interrupted_mmaps); --=20 2.25.1