Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2762036lqp; Mon, 25 Mar 2024 08:32:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7xzUj6b1FYATAceP8z25Kg0ubqZgPaKhBTLqpME1f2QEu/M9H36LpJdFfDqYx9t4GyBnR2NCwgshaCDBAK04ffbpEwOqMvzB2SVeySA== X-Google-Smtp-Source: AGHT+IGFyfQ8hCYVfTbHpPLawQITPa85O+TItagfaDsbC0OYWMrjER1ljuJssNZCXlQSuEKlivxO X-Received: by 2002:ac8:7d42:0:b0:431:61af:ae87 with SMTP id h2-20020ac87d42000000b0043161afae87mr1576387qtb.18.1711380733196; Mon, 25 Mar 2024 08:32:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711380733; cv=pass; d=google.com; s=arc-20160816; b=klDTwLjavvRosRCW2lmnwK03Dx+57YOhMqZsFEfeEJY3K0Z5bR67/LSIcBkbw8qdY+ ql3lkWChF8AzxmKRJpjHRgvsWGELgvIhgX4oXjy8sYmIamWwDaEY6sJxqNdDL/IYvEKJ UUHjfBW2dd7GzbWd8hxp6DkORXNujd1Zk/ZxN4UtWypMkzTeuie5Facoqp9QfVdQqEPK fm//GCkBGNi/GxNamZ6NqLs1U3em2XHdLnXI3ewj46bhaD4O7ENt7Fe7BVMYJBbuV5fc En968hj1T7woaRB9jM5HjPD9rtyfagR2ddevSfBQdsgX4QRB/W0RupG7wt6IjrYYCJLc ye3g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=5xM9SBn4JRwG0bOMb0/BB9XkHkn86JKvqpbMlH4QUNA=; fh=0VXqLrTj8Uun4oMdMJ8p/CWNmO+YY8oO3P2MeolcRVk=; b=XfRbU7jEtLyxUsRuALjPTFXBUr4aSs7nMtq+gWrSTV86v5dx7fXyXC+yDhFJcUFnB6 htWD1x+dS/LrmL5BxM4Vma0SK59Ij4q0NKywM+G622cspmQtEyNpz07NaXOFCsU8uNoI 2JUChi0ADvuTZnw+fvSguWgu360Uaqx7tvo/EY5ybVre0TtoQ037LFw3N1x1FUEqyfkW VBOxeWU+acxGA6ExdHMYtuENA1xVwLosfhaRDHpuN0i5849Nh0recGPd4H5M7HuoHqzs ecHmTQfjb9KFidIl26n6kbot9kF1y+tz2iq3+pcX7eXRiKcnsFzmko3ObyFTRkwhHUws +J2w==; 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=JvLtRK0D; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-116788-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116788-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bx11-20020a05622a090b00b004312328e14csi5587221qtb.337.2024.03.25.08.32.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 08:32:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116788-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=JvLtRK0D; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-116788-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116788-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B3A4A1C3AE93 for ; Mon, 25 Mar 2024 14:15:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 49F89182EEF; Mon, 25 Mar 2024 10:47:28 +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="JvLtRK0D" Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 84BA4196691 for ; Mon, 25 Mar 2024 10:04:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711361052; cv=none; b=NaPSHWL7L/acmGU8dhtkje0VMYIeafaxhuY1ObC5JrnVQRHaa2kgRJx/p7XqZfF8AzrdbrkTxDBeag7GzT3PHQyPT8L1J44bCqYbt3eEfsqI1Qxm86yHhT6G2TCbZJnhTKBCdj+eoI7q+sIsEJelfTNH5FsmmV02uJwRPveKmfs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711361052; c=relaxed/simple; bh=EH51HCSeo8d+4t44xNDlJL+YzfigfLghhDUCkzVJpmI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Nh3v94NSRo+ocAKEHGfY5w6iiFsIGfet9PcU5zETcouZWlIdDTGUsWtKbygl94OatvrMgct24aDml6Dbqv/iJE6uZ6l8MBBX44xR5uEkIF8IG2DyysO6iCYzSnXY0N4WFRaOPLNFpHzQ1Epu7/+FliiR5+rL7rCM0QKQXILvsAg= 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=JvLtRK0D; arc=none smtp.client-ip=209.85.221.52 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-wr1-f52.google.com with SMTP id ffacd0b85a97d-33ec7e1d542so2899463f8f.1 for ; Mon, 25 Mar 2024 03:04:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1711361049; x=1711965849; darn=vger.kernel.org; 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=5xM9SBn4JRwG0bOMb0/BB9XkHkn86JKvqpbMlH4QUNA=; b=JvLtRK0DidNr8+iKGuHu+h1Q4yqcPXaQBId3DHhltOCh8rgmh5jJQ/8I4eZ28emnIo AlLRh5XEWoe6LYkDcCgp4BinLmQJ4issZoI8ZSeiOpeKPqwaoJNyIwHDCOOlacVizeB0 uT4KIr0pryKlKryWB8tHZqUo6xCTafQVABFQ2xKcbG82okhH5Ob6V85kKUvTyGp8YQNO g2TZWlLEC5QdslZrnQ0z9YgoURzaWSvHU/wSci7E1xelI76OuSSruLXVquPd4vZ0A0pQ 1Ppb9TQm+GQeh7QWqMICP0Pq67n4WsuA/oJ/tL40qrFhJZ2pNwRp2c2T/TCXW7prHLcV USCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711361049; x=1711965849; 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=5xM9SBn4JRwG0bOMb0/BB9XkHkn86JKvqpbMlH4QUNA=; b=fa2zaYzQmJluUVuTb0I0ovKGGoWfzkUW93nFoZxW6r1E7R5kcCNJ2ywu5slyGkPDJd yxyu07/clmC/ch1t9ayIu98Ya56OzS2bH3XdQoJ3rOcVJlZLFlRIBEBNUdcKVrGQQF0+ bTucMDb8NeXxENGd+W1jRg6lGyZzl/kElaS3/Ey9x+Qx2prKxLcZIF3VipVSew2SJtv8 Jc8eZlpNhSAT7HfV8zHrjxA5T7oSEQZQu/2zqbVJKaUUZF+DbYRjnlOLNB9v9sZ4P43L HBaJRGUpgRHQlT3AuqtmiqKYYKDpZD3api7dshBf5Nrt/JZPXBpOhzWp0Oo7783fLQDw lXMw== X-Forwarded-Encrypted: i=1; AJvYcCXQslu65KriiCqJ8KLd4MUAuqlBTyAM84tm9oFNLLf0fBw2Vlmd2ZdHl8GEjImtger+Prj8YFOEMNFEUY63XusOvv9UH4/9aeJFFm2B X-Gm-Message-State: AOJu0YylRTF24Ewc4/pJY/np1RdfSZwP929Qb5cW1O7fYqm1DnXUsj1R 3IvYxjIBnG3MU2ZOXeCac9Liw+0IVjQCi0zzDL8v7bF4yx+t6lz+4U0pA7nvjKo= X-Received: by 2002:a05:6000:1ace:b0:341:cf9b:c8e with SMTP id i14-20020a0560001ace00b00341cf9b0c8emr1303987wry.50.1711361048974; Mon, 25 Mar 2024 03:04:08 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:75a:e000:861d:8b72:a859:4ce9]) by smtp.gmail.com with ESMTPSA id dv13-20020a0560000d8d00b0033e25c39ac3sm9086874wrb.80.2024.03.25.03.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 03:04:08 -0700 (PDT) From: Bartosz Golaszewski To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Elliot Berman , Krzysztof Kozlowski , Guru Das Srinagesh , Andrew Halaney , Maximilian Luz , Alex Elder , Srini Kandagatla , Arnd Bergmann Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Bartosz Golaszewski , Deepti Jaggi Subject: [PATCH v9 04/13] firmware: qcom: scm: make qcom_scm_assign_mem() use the TZ allocator Date: Mon, 25 Mar 2024 11:03:50 +0100 Message-Id: <20240325100359.17001-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240325100359.17001-1-brgl@bgdev.pl> References: <20240325100359.17001-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 21c22d306aac..cd47389ac80c 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -1001,14 +1002,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; @@ -1018,10 +1018,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; @@ -1050,7 +1053,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.40.1