From patchwork Mon Feb 5 18:28:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13546039 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 B72D84EB37 for ; Mon, 5 Feb 2024 18:28:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707157707; cv=none; b=EcMbEFq3JDJC3VRxdanEPVFzbuwWa4zxQCpUzCTI4g4kM/IFXyHFTnoI7/1sOUHvD+o9iWG2kLRFJ5CoaEuscaoaGYokqEd5PhdTouNYC8OckYw07z5JJ1wq0ETsPUygk2cKNu27Gg1sFU5JSQ4S70RRqQyMv6hPhPkwisNlu8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707157707; c=relaxed/simple; bh=hMzsleAxBtBbguc8gCAikfvgC+u6v027CTjRT8cZCJM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IwVZb84j2LJzmz+TBPCd2gDrGQ7sMuq+bDMCc5F7KK2bnowQdrxr6hpP8+WTHYjM0Sir5crPmbzO4808LGvW/cOedZKOmuLEYCYNdLxkVhdfJmZqcR1XWpQazHQEtez3iDJ8IydutbgHM+OHSpMD7SHLdwUxr892jCGhxjzxovA= 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=k2BEKQ3/; arc=none smtp.client-ip=209.85.128.47 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 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="k2BEKQ3/" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-40f02b8d176so41668595e9.1 for ; Mon, 05 Feb 2024 10:28:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707157704; x=1707762504; 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=Ky7A6Q6k7ixaopUQaNLMQkcUAky1WorEIskukk+Y5Zs=; b=k2BEKQ3/Pt7DCniPFNC3bk1ZHAzfuGl58FGzII0QS9IFXoZeE3vw1Ek9J/pF4Gmgie rN5rOgUFTdIfrGMUWi1+S6sSbQuuaWVsVLdPC/kd33sRCEcFsFGf3Kn+yPYKj0oYJGZu UF1QyXvtbrA8/UipVFUIlbneTU7wGajLRNE9UtpYnHpDbsU3PveE3P04p5rqC1D/rQDP Kd7KgDk7IDsjM7mfCMH2joWCkxPGbar+9EepGCePHGEdYu9zj9yULQ77OrYV/D0cIDi2 9jzpVu4beWr7BGXTDohFApASFbSe13vpFb46K9dh3pv/HrnqyQJbwxXeYDYVi94Y8sC8 B2Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707157704; x=1707762504; 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=Ky7A6Q6k7ixaopUQaNLMQkcUAky1WorEIskukk+Y5Zs=; b=kGtoiq32LBDvNwf++VbZvnBZN+/fHv0il51cJOhMZcNkuMrBN4W4FHwFpHdX51xipx JlLy1C2W54uiQLjlACAIq11A8C4cXWWZutYmOZsj3qzWsZ+hJd4awu3l0EOMDpjGCffa yLm9f/Bb1zEcYLzR1sjhINMYU3/huL32wOFvBZDcLETzMP5s0MmM3Io2oWIvrjbagx4R bCDhwXRciP76FQ/KrJA2EAZK34GBmP+2oK8V34iBK7x5qL4OoxspTZADG0GopP2DEvZ7 +ZnLhbycUvLP6FgI/ca8zvNPZXwK+vgOMO56FE70+pIZwrpGQhkmJzmnOAOpWAgekkIp kTHQ== X-Gm-Message-State: AOJu0YwO0rjRW4fJrk85SjGM0czfmx+bBQgBXcnTy+wS0VrJC1BRzG/7 6ZT1tyI2pTCMjGNGmBZJWk4hwEffH8VfTxSWbKiPecvOJVu73fKBQwQ0mAUd1/g= X-Google-Smtp-Source: AGHT+IHD765uexuf9D1x8wbid5+wPG/IxGvcXWflosUmyncm2IQaH5q+GGQQo9+ALGv8/8VJY9iD7Q== X-Received: by 2002:adf:b35a:0:b0:33b:28ee:645d with SMTP id k26-20020adfb35a000000b0033b28ee645dmr226903wrd.68.1707157703922; Mon, 05 Feb 2024 10:28:23 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUdIiXSS/gpH931MfkdO0Sc5wlorS96kz6Tl+QjssTR3Qn14dYYj0MZDMg7QnloL0AiYaif6ZjjXPYRinmZ0GzAeXTEHKRNySKsblDiF+cPy2n+h6HoymfrcbFzXb1mPsiIlP+0kDmbqPbV3UYXpNKEmqqxLjoTrn2zN0a5go0tfPysE/vdgz0NZXqa6oMS9Bk96BpSPT37LC6FEB+zNmD9H0dxC5SaoODhdTZaeOXyT3o5ReqJGGbe3KVd78R1sfzt3aW7jOR3wlRWtOr89ttoWMe5M/4Y4g3zuj5C94rPv5ba1MccmdpGME5vGh0p2oy5LgcPNcVh9S/VAAsQFc753V1KWNEt51YvoqABivktphkj8v9I4RJq0X6qA6tHvCcDJKFnYQGCupXTBXfLYLZzMULI9zXIZ/0Mbbvf2KYStDUYTn4Sn7sPeNV3mDxHNE23ecKYflh/JHcS0W5OReZkwxtlXIo9XSzcs+5sL9+Ea7RH6XoPeO/+t4Yia6Hr5XCnKndftiFvABgBK50wUiYJjvoMf75DyHIdGIw5NrKskt0nT2K6KjuFYJcFYMXSUZU= Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d929:10db:5b5c:b49d]) by smtp.gmail.com with ESMTPSA id v15-20020a5d678f000000b0033b17e18df8sm203229wru.12.2024.02.05.10.28.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 10:28:23 -0800 (PST) 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 v7 04/12] firmware: qcom: scm: make qcom_scm_assign_mem() use the TZ allocator Date: Mon, 5 Feb 2024 19:28:02 +0100 Message-Id: <20240205182810.58382-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205182810.58382-1-brgl@bgdev.pl> References: <20240205182810.58382-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 71e98b666391..754f6056b99f 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -998,14 +999,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; @@ -1015,10 +1015,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; @@ -1047,7 +1050,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);