Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2167035lqb; Mon, 27 May 2024 09:53:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUE0EDCVT4B0UT+TyeVNeRKCNZFZTXDZmrPtmNQ0MFX6rXJPVfcopnF79C63AtzKUCuN+BDbH8iQaLSqECGqS5c+vBvXbvXo/6cnYReLA== X-Google-Smtp-Source: AGHT+IEQmmo7UIVaxcQilqgslWtqkD6NV5k7+9XT6M1XC7Ki9ltzNLopSZNpl7ekg65BwHlVGekc X-Received: by 2002:a05:6a20:7494:b0:1af:6914:1154 with SMTP id adf61e73a8af0-1b205c8b038mr20110280637.7.1716828788076; Mon, 27 May 2024 09:53:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716828788; cv=pass; d=google.com; s=arc-20160816; b=YkF/2VfiIeclNmOcUXz5msfAnRIrOJDe95TNi2bWhcIS3FbXKQ2uGoP0MIxUAGF0cv j1e37isyNhth+dlnsffxW5IDe9Y8Fa7ox79j4sA1mzxPz3ghr5+u09bqO6s3iLUMdlUQ yMnmHBVTGERse+gwb2u344AMg1edRXmw+F3+XAesVRn5THzsxzwkFBcnz66Pt/ZbLuk2 aogMoYi4U+K3QCvZWYXi2Y3e6Zj31lUzNdraGovuMnKX1enoR+z83evigzX97q/Po4YU 3qZl+SWxoGQ+PX4hJ6XWd08WwJii3MnUCWyOY/kq07ksgxd3AMwbhWT2xbtJ/cK9zmjb DqyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=F2tGSXM64q5CkEofoukaYDnOH1U7xvQ9rdr6WJfwwYM=; fh=tCJG61tzEgQINHJ+m/cIoTD2SbzEVPHWWNFXbqVbOWA=; b=Zc55h7yU/Y5jBdIc1Y3nNlthP4GM1nbFOK3Sna04QeocZuO0yRyLEqhjRh2XIYcFEr Ro6qVG6z+31uN9cXbNqHIgplwGRMF3lXGO7VGp3HLLjZjYD0IYacZW+IG6ElPSuBn5oa pKR/kefF3Dk/pKJgDpCyDKT80T/SyRrjtDf8qc10NYTN1U2JvIN67hU+VIpiOACWOLdQ 58W+3Be6y7PUhvSc9vcvXqAwiRu0iETYitoAnhq6p9/NAd6nqgDqe5wRxMQy1AEqWLhJ 2qgJuicAKx1U5Op19MqHbZpK0r8m9/XMNhMV5daJHwdufxOMBCWC4qDtYiJpN6yrHYRl 02lw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=us2JMFZf; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-190629-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190629-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6822789027dsi6799389a12.413.2024.05.27.09.53.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 09:53:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190629-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=us2JMFZf; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-190629-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190629-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5440428569C for ; Mon, 27 May 2024 12:58:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1EB915FA93; Mon, 27 May 2024 12:56:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="us2JMFZf" Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BDAE15F3EF for ; Mon, 27 May 2024 12:56:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814612; cv=none; b=gxHRdojeN5Mg3TDhQ1CzH4uXZTWJ4Xi2DaUvoOasGmPQhMX5khv3pw56XbQstKpNwe53gQSV0Ep9aAu8sxWhu6HdyFBowLtT4HIqu07eucUhPXqe+FNYGNOnStg4zeo4dRrqEXcJfMU5JfjUOACBIxMt5dZIAMeF1mxSkJ1ge4U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814612; c=relaxed/simple; bh=H7pseenH3L02JxfV7omW/31iV86Lwn0PZV9E6T5f71c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=seVKHpJCxgLNTEUkqrqanRC7i3M+66vXM0i5Z4ar6NUd/9dcf7Fx+bEGosfiGyo/i7/pqFzLHoug2lX8ViJECSeQ0NLTVpNcqmB5yM9fjZ/vqD8cJrSyOBQdKjE/vGghgBdyyVHJ8z39Mi4FEZNSvBNEuK0La/+4ZCPiqV1gwSo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=us2JMFZf; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4202cea9a2fso48381155e9.3 for ; Mon, 27 May 2024 05:56:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1716814609; x=1717419409; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=F2tGSXM64q5CkEofoukaYDnOH1U7xvQ9rdr6WJfwwYM=; b=us2JMFZfcCsrXbXu+DgepLB03hPwvWVNaes8P+gZZvWmtnI2hALbF80CgWNS+SZX++ Wgj/+fHXbpdhKaiYRUJSAyjlfE8FosBGfqirA775Pdmkoq13AvtUQ+RQTxoi+0PsxHlv gu/3zMa9h/UGxDkxxst1e2/m8JRZbE0epJzDQpjJ84B5k1vx5OCjK+TMjfafxSqImOWU lVoeYJtVk+LWjBRqLhB2GCpVmNuRVK88jiePIXChPIYMDvD7sqL4fte6MvDHgQduq7EK x1niuLBz6N7tXXRl9jU4ADIcWJpleWqhC1lNZ4QBFA8M/4rNRi9OJog7kX4Q9zmv2fDj xNGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716814609; x=1717419409; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F2tGSXM64q5CkEofoukaYDnOH1U7xvQ9rdr6WJfwwYM=; b=sXz+bq9sohUuK/7Xv5pQINPB5ruivWqpHsam8OAdaV3qx3BDYRrXolAhqtBtWYCJL8 HpFG0St7QcITsgkox5DvcIGSDuaobAx4bTcMSUgUPMwfXTChEk+vkDhB3nLVl7CSKCom Y9hA+TtSvGOoppBH5JB2WYEg0LBtzGAfn0zGEWsVQYPqxcmLBg2+Ge2MFGP4Ch7Y9cYl s80hufycY7Xb2BupZqtqLFbSslenBu+oPImHMMa6O0nnmBNaQ9R4mKNJBnvNo0a5XiWe vRckdKITZce1zueoM6V7t0UfhFowBCfqMeGAccoLZYy6Yro7Q5aHnxfdnyB4SKHxJr05 nCnQ== X-Forwarded-Encrypted: i=1; AJvYcCU7cq4CQt1RpmmLzvJmXYG0w/nHh2iUHzuQcrE0cb/0I1wPdaUE6OUUhP+y2pYeVkTNrgEybjihiNZEW4ehlxbUxl32TkdjPmAAH8lO X-Gm-Message-State: AOJu0Yyo1DKlDkyhyW+O6N+D9I3DGjP/ITR0KwaPpDW3DhwvvvnzcILu d2dmVIZa3VqD34bs7XBt7hm4CgeGuGVdDM7XQd6nLFRBU45FLWqgTspdTBNvs7Q= X-Received: by 2002:a05:600c:6b0e:b0:41b:285:8417 with SMTP id 5b1f17b1804b1-42108a2e796mr66785555e9.40.1716814609554; Mon, 27 May 2024 05:56:49 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:75a:e000:c322:131e:ff9d:ef41]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42100f64f98sm138753635e9.24.2024.05.27.05.56.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:56:49 -0700 (PDT) From: Bartosz Golaszewski Date: Mon, 27 May 2024 14:54:55 +0200 Subject: [PATCH v10 05/15] firmware: qcom: scm: make qcom_scm_assign_mem() use the TZ allocator Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240527-shm-bridge-v10-5-ce7afaa58d3a@linaro.org> References: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> In-Reply-To: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robert Marko , Das Srinagesh , Bartosz Golaszewski , Maximilian Luz , Catalin Marinas , Will Deacon , Srini Kandagatla , Arnd Bergmann , Elliot Berman , Alex Elder Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Andrew Halaney , Deepti Jaggi X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2241; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=9Erqvqgiad5rjTJsNR0YSbu/CRguRxvgVp+lpYCpIVk=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBmVIMIKOO9v8eTMGirexp87ho1NlUlhkeO/Hz9j WAf+2zXRZeJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZlSDCAAKCRARpy6gFHHX crGMD/0YS7UnmIE3KqMGN3f/lgIUFTePpK9qvRMHBPLj2Dpag/edaQyVnec1ocNJlO8pz/bNR03 UdWI8Po0hrZN8wLxgwxiAytFfl+Sa/aJ99bbZjwnd7nk9o8icNvkBmE6wtg3OFHSx4rJspet0cf tD7cJ93DyEg8nVqzSw4anW94zC0NczKotQmHBvEmXzuITPwUmAsIVjey3it0QaXigk3k1LN4yLj pQmOTt0CINtQexASpTZAFvC++O0u708QBAU12SjPXB+9vNWpd/9OHS/P1Sp3ISzJqQP37QH+Ozz opcFF0t5siyZ5FgdRvui5YOcoIMdAmy1i4XhIqlAo5+UlhqsOqrAvV218vnNdsJFooB8Mm162Ga lqRB/8qrODadaf4jJY/5k2/mkL7jcCOZw9eFJQfnDNN8VMZdry4pcX/nnYDGMwgPV2I/1/xxCm3 qbbCV1RsuS56M2JZtdWxrbPwwvxPlAdCaRm9nmC7rPuKHPg38FoEglA7uz8iLYLSSSvw7CdUVP0 L0KLtJGnM6v8AFX0lR0wQ6ka+np8QNJYiU2/rLCL7QWAEXNgTDe2MIICEUkrR/RH05lP3cGml7a x6R0LfAwyWSeue/g49j07ahDu21bvrhvd/+tgJ63nVLSILaYCqg0v2LVevZbxkLcYmL99Ifhy3L 6DqEfDKi8bRUI8Q== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski Let's use the new TZ memory allocator to obtain a buffer for this call instead of using dma_alloc_coherent(). Signed-off-by: Bartosz Golaszewski Reviewed-by: Andrew Halaney Tested-by: Andrew Halaney # sc8280xp-lenovo-thinkpad-x13s Tested-by: Deepti Jaggi #sa8775p-ride Reviewed-by: Elliot Berman --- drivers/firmware/qcom/qcom_scm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 1d207c14afc8..ea4d71bb0ad3 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -1019,14 +1020,13 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz, struct qcom_scm_mem_map_info *mem_to_map; phys_addr_t mem_to_map_phys; phys_addr_t dest_phys; - dma_addr_t ptr_phys; + phys_addr_t ptr_phys; size_t mem_to_map_sz; size_t dest_sz; size_t src_sz; size_t ptr_sz; int next_vm; __le32 *src; - void *ptr; int ret, i, b; u64 srcvm_bits = *srcvm; @@ -1036,10 +1036,13 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz, ptr_sz = ALIGN(src_sz, SZ_64) + ALIGN(mem_to_map_sz, SZ_64) + ALIGN(dest_sz, SZ_64); - ptr = dma_alloc_coherent(__scm->dev, ptr_sz, &ptr_phys, GFP_KERNEL); + void *ptr __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, + ptr_sz, GFP_KERNEL); if (!ptr) return -ENOMEM; + ptr_phys = qcom_tzmem_to_phys(ptr); + /* Fill source vmid detail */ src = ptr; i = 0; @@ -1068,7 +1071,6 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz, ret = __qcom_scm_assign_mem(__scm->dev, mem_to_map_phys, mem_to_map_sz, ptr_phys, src_sz, dest_phys, dest_sz); - dma_free_coherent(__scm->dev, ptr_sz, ptr, ptr_phys); if (ret) { dev_err(__scm->dev, "Assign memory protection call failed %d\n", ret); -- 2.43.0