From patchwork Tue Nov 19 18:33:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13880440 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 7C64A14D70B for ; Tue, 19 Nov 2024 18:33:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732041220; cv=none; b=cLkq7crmvCS/x4w2+e8k/o5rN+AzVKNjgZLiSQ53fRM/RNVYYBS5/Tt+bjHJ7u3KBsChitrqt7Qedj30xwabJfb0gJijk5w3dbQcHgP73ugncGUA7Sgqr7Go74SDTFSVesd8Hmk2EknChAk9G01zYV1xjVk8BEmHrUtZG5VICaM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732041220; c=relaxed/simple; bh=4+hwar7hksX4/M0z4NFaljX6f1cD5Yplk+PiSWSgQRo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=t07fHNc3W3uQdmNqdv1IUPqoEBaIj5wfQKIJf3ZK0OjPP7dAPNBqU7FpqdJCZPBL89DIcJBQNvwEXrfzPPSWYxU8Y/XVMpXNk32O5HoSS+EUZObGcLN+3vpIZPI5D/T+XnURu11lPpzVR6plZZqfF00h0/Ojf2aXnJAh7+HTZ1k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=yErh/Cv/; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yErh/Cv/" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4314c006fa4so5618365e9.0 for ; Tue, 19 Nov 2024 10:33:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732041217; x=1732646017; 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=efvOEpCd95WeO/48w+qj0oP+ZGNtmRm4St0msFrAtIM=; b=yErh/Cv/ya3qYr2Y5tYS7qxG4jIHygLgHxiw8YAbfjCsjDETCP73xoY+CQBWKGcCOd w4ivfjOSegE96NwINW+USurpQfDC5d/iTPOH5e6gNr1sursUwwEVwfkUX7Mm0Z528/Eb JD7Kgda4cdeyzW0C2nQTG+xlLaSt0uyHb0C9zpTi9YGPm3ZYmuHqy5xy0RfQu5jBZO7G OXn3YWSxScS85hj8clG29NqAOcRu+RS0wy8ML6NQF/Jr2iKZY7kNvx534o48c531oEpk jAJem7SpTU2YoTmWtKqXH53K2u4alX/8LNJXNBDOQ0ndrUws0zsBsjGT8oqPXZ1pcerb vD8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732041217; x=1732646017; 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=efvOEpCd95WeO/48w+qj0oP+ZGNtmRm4St0msFrAtIM=; b=iR+5Cm0A7blIqaxQeB0xr59Xv0KnKRdYJ6ISabpT82Xm3jQLTnm5ABfTSVhgKDUg1e DivGgNpqAnX4UfZc7oJi4p+x13GmaL6CB1H2sBiIZtB9jQcRUFHxhiACKifzwz71NnIX MQw5V/RgK892ztKeyxC0PL3kTyNM0tXVHoxROzP+RAatWuV8kVbf3GlhnUhqBpIyQTf2 fEhDns0sNW1QnBCpLEeSZ+6Lra7HcFXJgujIKchqUxs8HcPalkV3iYheTiKogYBm2SeB Nxky3Kh2l7nEgCxqwL4UA/PzU3HdIbE/A6yXcjwq7+1vdeOeOs6nb41/ji6f2gHuRhbD hVhw== X-Gm-Message-State: AOJu0Yw+zSVtE5KkDqrwQAMlxWvS1XhXa3EpROxtbty+IwOKuoHplhRd kdli4ZMarA3Rf7koEdBOvuhWFGqD1wUBz+l9w2+ZiiXzYDwoBOHRg61o82pJRYQ= X-Gm-Gg: ASbGnctzweuCQX32Xh3yFh0NSYYl2MZMfKhiW19ZniO0/pmBtGO0Ktkx7HrSDGfuJWk sD8N8ozTTxQMNAS4L+MFGUtp7S46uKmuygGqf9QJIYpWYQZ00osqlKbXmugwciERlTWzXVhQN5x 17+yep0z37Hxog2iji9w1EfGI2JiHvlG/oZkCaKyeB2w3d5Yg/YkzNKp1VEfCbcpOzyA5v0tO6A 6bmfRtGeKwXgC8a/vix59RN8HtgacRQ8jGCP6vokGQjFNBwgvTVFPPXT1v77s2VyQ== X-Google-Smtp-Source: AGHT+IFYWxyynk2sfdjI6zEKI1/p2FFiirdli/9bZ7gZYwreNjnXC2OHtYTc93Faqf94ePMZ80JLtQ== X-Received: by 2002:a05:600c:354b:b0:42c:aeee:80b with SMTP id 5b1f17b1804b1-432df797e02mr64688085e9.8.1732041216817; Tue, 19 Nov 2024 10:33:36 -0800 (PST) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac1fb7asm201566805e9.42.2024.11.19.10.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 10:33:36 -0800 (PST) From: Krzysztof Kozlowski Date: Tue, 19 Nov 2024 19:33:17 +0100 Subject: [PATCH 1/6] firmware: qcom: scm: Fix missing read barrier in qcom_scm_is_available() Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-1-7056127007a7@linaro.org> References: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-0-7056127007a7@linaro.org> In-Reply-To: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-0-7056127007a7@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Mukesh Ojha , Dmitry Baryshkov , Stephan Gerhold , Bartosz Golaszewski , Kuldeep Singh , Elliot Berman , Andrew Halaney , Avaneesh Kumar Dwivedi , Andy Gross Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2415; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=4+hwar7hksX4/M0z4NFaljX6f1cD5Yplk+PiSWSgQRo=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnPNn4YvyTrrVQ2ijl7+Oi6n0F0Aq4/byHzwRun llOJtQbA6iJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZzzZ+AAKCRDBN2bmhouD 19hFD/9GIIDYhi+PrS+qUWDkluN3W+XZL198CX0iOUIm2HEDywnOVrTgfaMPFnWwYRCEO/n08n2 q0AKqTk/zoo+bcOlJZjnZy/NOQipv5J0GHotUw+25guqkMKDU2GO4lnRFsAKEAqR0HLbs0q2gBu LVDWihY+APlv7sjgEWQ7RSqquGfD6mT9F6J0K3qD+YcYuQugc/Y+NwLD8rY1deJZioF1RW6gpGp QbpkG2YsuXfgnFd1GlPPoROT5PUVedFD9mhHi/8g1utecHPrtwRgn3cS+8xDo9ja35dc7aKOh2A ioecBL5mZ46S7QO/87ZAAcHjVPGky0tPd/4nFTitR67IG6a/VK5U/2AWGkWbb1uQRiKiu5vOZwM mollWngi5XhnlO6KtGlLAya9wbCz8QHdbEUN4ayzmIZr0ALukN/nehmy8BvsNhnlBZj+DBQb+8d eIoyj+clcIUX51TmffduPT/aSqbHHWsUn2W28aTqWBcokWVHdwp2XDy0BJ1FGqXBwaF1vDwuYFP L0q0PSxLSYr/e3dhuSb1HlINCEnRlSB/mgSwuJKoLytApfy06k8v8DGcGPv24w6u1JT061bK15g E/CGUjSnDbIeDlnRZZNCziLJGmfl7zhAGFhLc0H6+y6s4j2YsF3z9FOyc5PSG6u16TSvXDboOB7 I2OdHxy22EUGNNg== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Commit 2e4955167ec5 ("firmware: qcom: scm: Fix __scm and waitq completion variable initialization") introduced a write barrier in probe function to store global '__scm' variable. It also claimed that it added a read barrier, because as we all known barriers are paired (see memory-barriers.txt: "Note that write barriers should normally be paired with read or address-dependency barriers"), however it did not really add it. The offending commit used READ_ONCE() to access '__scm' global which is not a barrier. The barrier is needed so the store to '__scm' will be properly visible. This is most likely not fatal in current driver design, because missing read barrier would mean qcom_scm_is_available() callers will access old value, NULL. Driver does not support unbinding and does not correctly handle probe failures, thus there is no risk of stale or old pointer in '__scm' variable. However for code correctness, readability and to be sure that we did not mess up something in this tricky topic of SMP barriers, add a read barrier for accessing '__scm'. Change also comment from useless/obvious what does barrier do, to what is expected: which other parts of the code are involved here. Fixes: 2e4955167ec5 ("firmware: qcom: scm: Fix __scm and waitq completion variable initialization") Cc: Signed-off-by: Krzysztof Kozlowski --- drivers/firmware/qcom/qcom_scm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 72bf87ddcd969834609cda2aa915b67505e93943..246d672e8f7f0e2a326a03a5af40cd434a665e67 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -1867,7 +1867,8 @@ static int qcom_scm_qseecom_init(struct qcom_scm *scm) */ bool qcom_scm_is_available(void) { - return !!READ_ONCE(__scm); + /* Paired with smp_store_release() in qcom_scm_probe */ + return !!smp_load_acquire(&__scm); } EXPORT_SYMBOL_GPL(qcom_scm_is_available); @@ -2024,7 +2025,7 @@ static int qcom_scm_probe(struct platform_device *pdev) if (ret) return ret; - /* Let all above stores be available after this */ + /* Paired with smp_load_acquire() in qcom_scm_is_available(). */ smp_store_release(&__scm, scm); irq = platform_get_irq_optional(pdev, 0); From patchwork Tue Nov 19 18:33:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13880441 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 32EF51D90DF for ; Tue, 19 Nov 2024 18:33:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732041222; cv=none; b=s/njFk6ZnZxDG6teVI4z85cUgL3OOOJ+mTnGq+lyqvL46cUnHwlssNZnk7bieRWq7iDhKMoHv4BqKhCAOqhCdHfpJfyq7kwbZwvYeYesJjv+xbEETuNmOj1DPjA/6cMB4ulpwPEW+I3XKVtVlRFHOSL6+irBk9PnNMKek42/g+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732041222; c=relaxed/simple; bh=/16xZGK1B4eLSoXZt75MWgQkmhlzjbCUALoc2x5/66E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MOTHXYpytk4JdCDZv1Q6UUUxwLylg24qWRgv25twN9SwsoFam1cK0e0mas0+osaf2Mjd7o2fO2eR1ndrfJUIX3tXAPZSsXGtCtSjmkofZ+RRdM4WspORt/rZb/A7sTLxu8SIqFTUtHgvyIRKlFH4fb9EUcs/anufgBsSxNQhcC4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=jUJt1Odt; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jUJt1Odt" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4315855ec58so6464785e9.2 for ; Tue, 19 Nov 2024 10:33:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732041218; x=1732646018; 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=Ysh4eTWrTYIAWVaLPQ/SwS4fAOwEtQWE4oRj4GrDmYg=; b=jUJt1Odt2qbK5g3JrtC0I1UdYktoZ3lrm7evBeD3msqnNCWv5y6GT7B891U6Czwl0b Ys40HwpxcGRBWBiHpbn+lj7DTQHnnD9oILCB7a7GY3ZLec/dXNe/BY4mOli3YZPx9HQK /ogBqvOO2m5Qm2d70f4L64EUmFoIHEV3MD1rSTnSC2kGSHYvv+ngQahXsW5lEhdxLkDx VJPRC/LClK49hajwdTf2NPiF7wGMdI7qKLDgj3o6zYHJTgGmd/JK94fku6eTCLOVhPtW Jont1mgHWgL7H4gbIyZbrhbdHC7bC0ploiQdbTOd19CPTC9kN8px6QFMbuezHyYS7DSC /jDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732041218; x=1732646018; 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=Ysh4eTWrTYIAWVaLPQ/SwS4fAOwEtQWE4oRj4GrDmYg=; b=WM1xcsrlxIaRfRQS2lBaIO+9RVSi9/rtrB2B+I6TwucZ67plWQP8TrxCZmeUPS3Yjd 6SYTC+ZepATIu64IgNhbYFCL3xaYsAlvYylrwX1KZoyfI/llGcXl1mjF+1FdgmiP1kTn AKQaYYYjfxe7VnwgdcZ4wtsr3FRWbi3SH1HlsOEUtM4BuDf0WNz96QMblIVGVT9hPTnS wnP+C9cvUVZx/0nrVshZEM1RiQxhtpFETAclTCrjtG+J5RinqdEt/l+UglOU6zrXhk4g Th4EYVrC5rYP0+1uXczNIQvfhSIfdDKjTyBbtFjd+p1DZ5mbAmibWWA8TSS/Tt4BH5iP Turg== X-Gm-Message-State: AOJu0YykMA/Go83PCahZ6+UBKa6Fa8YiS8Du2HQxo2aF5cOl44ApoqJA ZMWHNZg19xtjn7CB4xJ8u+CSBlRZHohXjB9amDIF8ZaS9MBl70TuIBVl/yMlBl0= X-Gm-Gg: ASbGncsDblPiFSGvLKSfJRjcG61N38BY/C+a0LAMVERbHzqv7ymPHRgl3lqZiKYEfJ9 6KKTa5LyHEEnrCJne3Ih1yfHIHPvw6Xd9QT2uv3RXpe7OxQtu6+gLBmB+V/cTpo9fy2H/xTVTur lxtBJ7s3+dMpyIUp/PVasS3BI20Rt3i3FLnB/Y2JZ63Qnc7KgCpRfdgr1sMrUeXIjc7yX87BO9D +40/bNc8TVGGH2VIAuX3ai16Knvjh9lWEfBPr2GhKIABX/Tf6hV4EVSFIGWzT7uzQ== X-Google-Smtp-Source: AGHT+IGYCW73/Wi3BjocNSQs20lNIiT/tHi0fQubojntSw+RXjyxB5epjn3pJ6Y+leKtNvGu1KiIQg== X-Received: by 2002:a05:6000:1acd:b0:382:4e71:1a12 with SMTP id ffacd0b85a97d-3824e711bf1mr1316633f8f.1.1732041218534; Tue, 19 Nov 2024 10:33:38 -0800 (PST) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac1fb7asm201566805e9.42.2024.11.19.10.33.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 10:33:37 -0800 (PST) From: Krzysztof Kozlowski Date: Tue, 19 Nov 2024 19:33:18 +0100 Subject: [PATCH 2/6] firmware: qcom: scm: Fix missing read barrier in qcom_scm_get_tzmem_pool() Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-2-7056127007a7@linaro.org> References: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-0-7056127007a7@linaro.org> In-Reply-To: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-0-7056127007a7@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Mukesh Ojha , Dmitry Baryshkov , Stephan Gerhold , Bartosz Golaszewski , Kuldeep Singh , Elliot Berman , Andrew Halaney , Avaneesh Kumar Dwivedi , Andy Gross Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1564; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=/16xZGK1B4eLSoXZt75MWgQkmhlzjbCUALoc2x5/66E=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnPNn5lMI//tlzXyB+RRWLAKe8iMjfIaa/xwb5v HV9Ygf+24uJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZzzZ+QAKCRDBN2bmhouD 1yl+D/9apEhYDtrWMlqfvOyzmxRwalcPLrXknm09drQTCFNRSomEq2G8y25kevpGbyg3V8yPcWh 6SSd8Fc+9MDI0kLOYdm2ub+GbaSg1dhwgM7W3ph64mDuXEHhhEN0X0Fi+m5csFSBVGIYpIadqdf 8fu/oZ9X6j04yoYUP79iA6Kphk3caJvfIUq7OZ0sDHvDOPuH90YmNommaRm+s0qltR+3cUuZdOm nyc66EL+OkkAxbYNPau1R52G69eXbgrN6NBQ6CHO2ZWZ74vm+YQf6n58PK+sMP1DAeGmKkal3RT 8nVnn9OgHCmB2/IRxeo2yz/UjcQ7fZJboiezZ6NeXKf92obFN+28qBI8I235tejGk0zS+X49hxq sbYQ3PypmnFZSTbaDb89ueHTKLvRVYwkrQlplw/N1gzYw7peKzabnOBCzdPqcgpM0ru4wS1Ujh/ jPeFp+JbULkGMUGx5Uvc8x5O8jaY5Gh5PBYlIUBQynfemKmLQrkVFLG9/+ZIsIesUMikAr999nS 7nrVKJHd4YAXYq/lUJJeeen7di7PuEgfptsDhWWht/WZjYtAGF0G2pkD2keG+Zv3C/RwbUbrqlL ZycHj3Lrt07MGuNjeBc8g6CJxAvgT4Yne6te50UGcfA90xW5lg+KUg43yGy/Lcg7XHKCOabr3m4 YJQpKRtTH7UkYTg== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Commit 2e4955167ec5 ("firmware: qcom: scm: Fix __scm and waitq completion variable initialization") introduced a write barrier in probe function to store global '__scm' variable. We all known barriers are paired (see memory-barriers.txt: "Note that write barriers should normally be paired with read or address-dependency barriers"), therefore accessing it from concurrent contexts requires read barrier. Previous commit added such barrier in qcom_scm_is_available(), so let's use that directly. Lack of this read barrier can result in fetching stale '__scm' variable value, NULL, and dereferencing it. Fixes: ca61d6836e6f ("firmware: qcom: scm: fix a NULL-pointer dereference") Fixes: 449d0d84bcd8 ("firmware: qcom: scm: smc: switch to using the SCM allocator") Cc: Signed-off-by: Krzysztof Kozlowski --- drivers/firmware/qcom/qcom_scm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 246d672e8f7f0e2a326a03a5af40cd434a665e67..5d91b8e22844608f35432f1ba9c08d477d4ff762 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -217,7 +217,10 @@ static DEFINE_SPINLOCK(scm_query_lock); struct qcom_tzmem_pool *qcom_scm_get_tzmem_pool(void) { - return __scm ? __scm->mempool : NULL; + if (!qcom_scm_is_available()) + return NULL; + + return __scm->mempool; } static enum qcom_scm_convention __get_convention(void) From patchwork Tue Nov 19 18:33:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13880442 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 BAC591DA62E for ; Tue, 19 Nov 2024 18:33:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732041224; cv=none; b=FeOWcFEeY1r5wA76elPMXvtwGfHennH6wACohwV8IdGAysRweWsv9tNtYU/a2w1kYeHpyXN/VbDZgnzwM5KStEuEWWMrEklNB1t83peNfHYmPXypkQ0yQLHOK24R+kOI70PcjVELqMq5wN67zC5g65ID4Fk0hYL570NZnYvbqG4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732041224; c=relaxed/simple; bh=+bL1C3+EqmoCZ+3NSkbD7ohn35NupzZbKWkMvdBYXvo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GRlmnjVBXayfo610wklNzCe5ukdnjyZqHVANrfKINPEW0TR4xBYnm6iIEVjyFj2CL9RmQFwzL2c6C4U/PBNfNb1fKKddTCvfd8q4i7fqKUsVAlCxSrFgM6dJcHAK/73mPAH1V1Lk6qet8c0+nF7iV7bBOM/sUFBMp+wlaaIcS8A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=JC0Q/ApN; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="JC0Q/ApN" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4315855ec58so6464945e9.2 for ; Tue, 19 Nov 2024 10:33:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732041221; x=1732646021; 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=XGnb+IQjlD24kYzbmGgtXKwZCCe15sEsS5u15TpXOMs=; b=JC0Q/ApN22DQsN+3oTrGlyNHU0EAx4msDSF02+v9Jb6jVV2mgieCatZLClgUfyxWfe SLCgp+nQ3ZjCg5tF3x8cSaadoFNQ++e5mK3r0KcPlnt8vmaVgVhaKawVbTwCOiubWjNr 0YgtPViQ7ReTZyvGsw2UiPfPxaYaDxHPO51axUyvQ1LOLQyJ+opC70Ex9dHU610wLCTy oaYURX2Wx8gQjHNgXp0oF6bE37XyDy9YC50sxoZbeDdUicvJl1kmNvPuK6wRsVNBBiOG E33VDKJ1ZPlAHTwVK4cByIxKRncueJ9uiYnPLF3k/bBdTmUpH/N6XhCbLGL36Rfywwoe t3Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732041221; x=1732646021; 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=XGnb+IQjlD24kYzbmGgtXKwZCCe15sEsS5u15TpXOMs=; b=XmOuokiIa9u0l0aLrR7IWk10lV5TbDtWtsUYKVxcVewAxByZ3+8Fr4coTHc76F9J0+ eVMH3XUiK5uX0IDU4QUTiZL8OX/NyYoZSF0+BOJYbwCgQdgX3zOiHFnYGQPnIoWpTFxk 5HbzR0R7cHdGe97EpqfM53F0lFX7+OAJHQSS5yPRm5zh/RttQacy0wwFzoJRtcI/GUlx KXvYqZNhBy3np8j1INntyCQbHGuu4kynmCg1OCR85ApimfhQzsmE8IISg8aaSu1e2ZPo B7x/gCBRwf78UUewm61B8eKRiVXm9xqHuTalyZT9i/hdZ5quwhfMtM6FarexKtdvwk2L ZllQ== X-Gm-Message-State: AOJu0YwNJA8UlHh6XQB+9M9+G65eTtMU91MxuqaJGlMwefLWcXwv4Q3G VqU/md4dfz3bTK8F2O2bdLlE0j0h6CdEhz0m+U0Y7sdpeT4mifp5W/5W2XQQX5s= X-Gm-Gg: ASbGnctOLmb3vaMwsq6vZCfOd3NIkS3KWIGzNCphpkGPLTIRVwwMeGyPaj0LcfBN11a mc4e+cjj1D58xk/MeGdlxJLEY8a31DyfvL1iRvyPOkNIbfvy9jpSxY/ypedqhqNsd7AqnBO8Gdz usF27mBLZidBrTnOAe3LOfZjGopK4zoHcr1tM3oBXOcDtljtowbfd36/cwnM77S7l9hywiv13gN ZKR8zzZmKH5Y/XT85Dk55sJ4pJX7u29aT0IT1mNdK0gJsxUYYujFllR999jCMYjMQ== X-Google-Smtp-Source: AGHT+IGtUZSr+Po8pT92Az3nSWJsdQ3lxZTWxCYIy8qH3YtEpQSI3RE4JoZ1bMQ4vin5aZBryWJtKw== X-Received: by 2002:a05:600c:35c5:b0:42c:b870:c52e with SMTP id 5b1f17b1804b1-4334897bd44mr45295e9.1.1732041221063; Tue, 19 Nov 2024 10:33:41 -0800 (PST) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac1fb7asm201566805e9.42.2024.11.19.10.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 10:33:40 -0800 (PST) From: Krzysztof Kozlowski Date: Tue, 19 Nov 2024 19:33:19 +0100 Subject: [PATCH 3/6] firmware: qcom: scm: Handle various probe ordering for qcom_scm_assign_mem() Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-3-7056127007a7@linaro.org> References: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-0-7056127007a7@linaro.org> In-Reply-To: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-0-7056127007a7@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Mukesh Ojha , Dmitry Baryshkov , Stephan Gerhold , Bartosz Golaszewski , Kuldeep Singh , Elliot Berman , Andrew Halaney , Avaneesh Kumar Dwivedi , Andy Gross Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1373; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=+bL1C3+EqmoCZ+3NSkbD7ohn35NupzZbKWkMvdBYXvo=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnPNn6EH2hX35h9/DIDDrz2vClXDMpzR34zRb+m ebWhGXML26JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZzzZ+gAKCRDBN2bmhouD 15dXD/9sXw6qRxns/scm+8XBhzKT60H5knj3tAC1YBrpipYl1oA9Z21+F2kXwEKSQqQ8i9gXWE/ S46aOEU+x6znQ/G/PrjaDSk+auNX4Doqx/JH7v+03p1Tdin+An8PbRxtRGovYaDcBkYoASS44GQ Ls4365qeh/9EuCmkXis3RMiVri4GGvlX/9vC87xpqXA4ojJruDH8YaKPwkZOKomXOkT1/H2qABK lRkIEpa34xsSj16wvyX5SmFB81A4UU3RG4Ine4fXlmv6L6b0VMgWr0ZH5ifaevWrD7GHqY2tVjb LlleDaOeS3dM1hmwag1P9xuI/9UafbXLPui9naXLjrFNkdjX/eS2wK7f4Myg9wpLe4Xfwxdj/BT xwFkArEX25hpRjNuZOhTPJHqVXJqs6mKEWbSdvn3M/xTRn9thw9hoaZhnJFBH49lItJhTP8uvwg 3ZeW2fP9Otbq01aFxTJ/hyFgVQHMe2nHyXD1moqMZElJZQGta7eqXOIkgUkiX0/SAY30pw1fnkd 906Nc95t/z/w2fcl8EbjsVr24+XTJ/ErghsoTrlFA0r1pFvRAzciF2klRNIRSTkXrJiNEwk2Brm dcRu/vPfDudHoDBDwp2OYN5mMdViT2Dii/EsRKQzu/RZv+kzthQwiFtq/fiQzB0hQNblOqi9osZ 2YdGJpSsC9sL42g== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B The SCM driver can defer or fail probe, or just load a bit later so callers of qcom_scm_assign_mem() should defer if the device is not ready. This fixes theoretical NULL pointer exception, triggered via introducing probe deferral in SCM driver with call trace: qcom_tzmem_alloc+0x70/0x1ac (P) qcom_tzmem_alloc+0x64/0x1ac (L) qcom_scm_assign_mem+0x78/0x194 qcom_rmtfs_mem_probe+0x2d4/0x38c platform_probe+0x68/0xc8 Fixes: d82bd359972a ("firmware: scm: Add new SCM call API for switching memory ownership") Signed-off-by: Krzysztof Kozlowski --- I am not sure about commit introducing it (Fixes tag) thus not Cc-ing stable. --- drivers/firmware/qcom/qcom_scm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 5d91b8e22844608f35432f1ba9c08d477d4ff762..93212c8f20ad65ecc44804b00f4b93e3eaaf8d95 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -1075,6 +1075,9 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz, int ret, i, b; u64 srcvm_bits = *srcvm; + if (!qcom_scm_is_available()) + return -EPROBE_DEFER; + src_sz = hweight64(srcvm_bits) * sizeof(*src); mem_to_map_sz = sizeof(*mem_to_map); dest_sz = dest_cnt * sizeof(*destvm); From patchwork Tue Nov 19 18:33:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13880443 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 590DA1DACB1 for ; Tue, 19 Nov 2024 18:33:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732041226; cv=none; b=LvMLrIGMuhCpPz+hVMY/SWxzoVgChBa4Q9mRRC0BF+SEOO8lJet4ri77m6MZLBOR0bwUpXtGfB8ICDvHDO5YJfJkHVhDNyrE1qgfX4j5m8rGeDFH/YVOAmC9bw3d9YeQRIFOa8MMFShgz/esS3x0ww6mWrANq2TpQtQ2e83rkRI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732041226; c=relaxed/simple; bh=SFzZp8eV5NdRysv4pItOE6KXTNEtpasdX4AXT1ZOfnw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZFMFHGyP0KkD75jQ4neWtzxqRjvmskMlTvE65l7CNCopkkIUlX7MLrKZFLRDNQpudxyOJ1Rw9p/9HUZc7+/bAQuuy4qS6Ti0LFYsssfYhHn8UAelqUSpe06s/df+wTLmr3ptUYlaNjBDWKxSap6lISQwC1CY33q13l9/9xMItFw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=cf3/65uX; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="cf3/65uX" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4314ff68358so6472655e9.1 for ; Tue, 19 Nov 2024 10:33:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732041223; x=1732646023; 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=BoqecrL37/DAtjwT3AOqIAQnIPJQLIYmFQwUP6BSc1M=; b=cf3/65uX8b2nNZIQ1h9BaJyKYye9fkue9Ha1NNQ3C2YSvslBR5kN503ylNzh1FiT/s Sg4rF0pXsEVEZP+s4Ch3CisLI2QLB9Rf1ZEunEWZlLVqPoQha0ov7yEv/dGhz0U3pt3M Yh85miDS3VdZ4POyg/71bPfF+cotLI2FAgQ7YemYmdCjhZq1KEpp/jd1QUyaPY2A4l6K xHHoYWWfxwv2SEpLqQDO7x9Mz1eeh4/xj7WDRia1SJuu6/czZ1/Il3HtToUdjEY4U5Ea JO+oLF+mXnRx6/VI+NuS0r3tOP/iT7Jru3+ZrpX7GIXtysgAfsm3LFJKeoSwCHKZsQ0U kzbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732041223; x=1732646023; 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=BoqecrL37/DAtjwT3AOqIAQnIPJQLIYmFQwUP6BSc1M=; b=i2cJ1F+UNA1O9ybetydnsDlXe1lQjnqJbrtzUD34e/roqYj9MCuNuge3CC0NCT3/tU sg36LiDfT2J7nYfauBC/yTqFrtPUoKft5IwYC4kB8AXmQuWECPp8s8z8VDwXlwcpNbxj ufcsxkai1ypeC1zuu0PvDpO78zhl77xgx9gm7TBgElcpda43CPCKqHk6VH4RlQ9YxPah nKNzn8ihtm05fTzmBBWEeaqeyAJFtv9/oAWp8RU9LgGO3Jd9K8pJgt1MnzgVt1xQ2/3M oPaLIC3mvm8hKGA7hsfNxN7I8Ba/8P5Jgd+s3ntlFeBmuI61AhgiP7SaNaNjPnIvcmKp 5o/w== X-Gm-Message-State: AOJu0Ywf2q6mX8p07Ar2qb/6eNOlCruMlwZ1VWuG5C6qFE9hhkvk1nqO UnZlluER2CaSYqR1IT1pCrvOK/PhdPsdGa9xWh/1HzhJqnCLKgsXRst+XKF3Xl0= X-Gm-Gg: ASbGncsMc4V9KIsaMlYn0QQAv7GmRtg91BLqf3lyxoos9a09CerhC6ajWLcQB3nHeoQ kAebjEwwb1nZh95R1vs4hh7fauzRRPErqASucFUACY5lOM8jAXLr+JKZID/YRFp6MNyBLrJlORN Z31aP1PpcmIFiJ2SYMBDlK53yohm8NM0UIZUdb1eAUwpMl+nLGqjObc7rFMcahes3KxZ8Sj/zVy o+45ip7f4me4Foe1iPJXbiE5GHalQHSra5SmUlh5KIj7DVztqqpXf3C5QMAxSm6nQ== X-Google-Smtp-Source: AGHT+IHOrcjjHaLDMTLK8UxL9+wDArIxvlT1ACQkrO+kq/R2slaop5UZZub8bYHqNPV6OusAxfTTow== X-Received: by 2002:a05:600c:19cb:b0:431:4e33:98ae with SMTP id 5b1f17b1804b1-432df78f563mr65298605e9.5.1732041222793; Tue, 19 Nov 2024 10:33:42 -0800 (PST) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac1fb7asm201566805e9.42.2024.11.19.10.33.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 10:33:42 -0800 (PST) From: Krzysztof Kozlowski Date: Tue, 19 Nov 2024 19:33:20 +0100 Subject: [PATCH RFC/RFT 4/6] firmware: qcom: scm: Cleanup global '__scm' on probe failures Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-4-7056127007a7@linaro.org> References: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-0-7056127007a7@linaro.org> In-Reply-To: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-0-7056127007a7@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Mukesh Ojha , Dmitry Baryshkov , Stephan Gerhold , Bartosz Golaszewski , Kuldeep Singh , Elliot Berman , Andrew Halaney , Avaneesh Kumar Dwivedi , Andy Gross Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3699; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=SFzZp8eV5NdRysv4pItOE6KXTNEtpasdX4AXT1ZOfnw=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnPNn7p96iktcla4ydpDa30tUfiLwoJDStR88bR JTTZEbYodWJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZzzZ+wAKCRDBN2bmhouD 1/AFD/9b6VnCDvEdB9t0DB7B85gXFuJ6noDo1EPx0ViYulSeEa4+0dUYOMlTkFEGffWYloFBt3M aS+2EBKtd5IRmGuMef640tQHLOSBP3NUiOlRxyGZjHHVXVW4CA0V/fFEsmHJbx9MlZEIna3HyLm 63NP1g2M8dgWguJ6ODMsf4b1iIxPMKgd3+Cu2r0X72NxQHpVOXnikUwNCUDaRJgMIragj+Pk+ga 7v0QCnolSXlq3xvyER0TBEx+WiJ+4Ov4fAQM98GC/BhWi3Iqg/dTXUtqCzIY/BJjSXjw0zAqZve 5mzQ/3EVmlT7Ns0mJ/8h1jceO3XJS9xYO4QXBrYFanEsqxp9dtxTJUZ0e5khAotGKPUSIC/nn2W vxCEGoXhobWOD47ZIS0BMEx/+PiD1lgTijH/4gFcxSUuqZE+d6yY1s4Hn+z6MSQtEIEI3x8ivq6 bQ/UKILyPkHuTNnn2SHmPDBYbfwfA0n9V4RG6QubDThutCZPbGiY7VGbxsEIoGUoR5NdLxWPXKG g9Enx4457g+AxMdD3gKo6MpyYchGFuo70pyDzH+2CuDWCQ1PGi8azcWYgFvhFQvZjXG35tbii0t qzsMzn6e8HxZcsdkGij27VfPnoBYdo9ZlhA2iQzZfg1ZNbkn1B0HW0COtR4kJ9+1qfWLJfflHdn R+SfIUDamRuF0sg== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B If SCM driver fails the probe, it should not leave global '__scm' variable assigned, because external users of this driver will assume the probe finished successfully. For example TZMEM parts ('__scm->mempool') are initialized later in the probe, but users of it (__scm_smc_call()) rely on the '__scm' variable. This fixes theoretical NULL pointer exception, triggered via introducing probe deferral in SCM driver with call trace: qcom_tzmem_alloc+0x70/0x1ac (P) qcom_tzmem_alloc+0x64/0x1ac (L) qcom_scm_assign_mem+0x78/0x194 qcom_rmtfs_mem_probe+0x2d4/0x38c platform_probe+0x68/0xc8 Fixes: 40289e35ca52 ("firmware: qcom: scm: enable the TZ mem allocator") Signed-off-by: Krzysztof Kozlowski --- I am not really sure if authors wanted the cleanup at this point. Also, I am not sure about commit introducing it (Fixes tag) thus not Cc-ing stable. --- drivers/firmware/qcom/qcom_scm.c | 42 +++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 93212c8f20ad65ecc44804b00f4b93e3eaaf8d95..c6d526d055003a17a8f59471f93160bbccfc1658 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -2036,13 +2036,17 @@ static int qcom_scm_probe(struct platform_device *pdev) irq = platform_get_irq_optional(pdev, 0); if (irq < 0) { - if (irq != -ENXIO) - return irq; + if (irq != -ENXIO) { + ret = irq; + goto err; + } } else { ret = devm_request_threaded_irq(__scm->dev, irq, NULL, qcom_scm_irq_handler, IRQF_ONESHOT, "qcom-scm", __scm); - if (ret < 0) - return dev_err_probe(scm->dev, ret, "Failed to request qcom-scm irq\n"); + if (ret < 0) { + dev_err_probe(scm->dev, ret, "Failed to request qcom-scm irq\n"); + goto err; + } } __get_convention(); @@ -2061,14 +2065,18 @@ static int qcom_scm_probe(struct platform_device *pdev) qcom_scm_disable_sdi(); ret = of_reserved_mem_device_init(__scm->dev); - if (ret && ret != -ENODEV) - return dev_err_probe(__scm->dev, ret, - "Failed to setup the reserved memory region for TZ mem\n"); + if (ret && ret != -ENODEV) { + dev_err_probe(__scm->dev, ret, + "Failed to setup the reserved memory region for TZ mem\n"); + goto err; + } ret = qcom_tzmem_enable(__scm->dev); - if (ret) - return dev_err_probe(__scm->dev, ret, - "Failed to enable the TrustZone memory allocator\n"); + if (ret) { + dev_err_probe(__scm->dev, ret, + "Failed to enable the TrustZone memory allocator\n"); + goto err; + } memset(&pool_config, 0, sizeof(pool_config)); pool_config.initial_size = 0; @@ -2076,9 +2084,11 @@ static int qcom_scm_probe(struct platform_device *pdev) pool_config.max_size = SZ_256K; __scm->mempool = devm_qcom_tzmem_pool_new(__scm->dev, &pool_config); - if (IS_ERR(__scm->mempool)) - return dev_err_probe(__scm->dev, PTR_ERR(__scm->mempool), - "Failed to create the SCM memory pool\n"); + if (IS_ERR(__scm->mempool)) { + dev_err_probe(__scm->dev, PTR_ERR(__scm->mempool), + "Failed to create the SCM memory pool\n"); + goto err; + } /* * Initialize the QSEECOM interface. @@ -2094,6 +2104,12 @@ static int qcom_scm_probe(struct platform_device *pdev) WARN(ret < 0, "failed to initialize qseecom: %d\n", ret); return 0; + +err: + /* Paired with smp_load_acquire() in qcom_scm_is_available(). */ + smp_store_release(&__scm, 0); + + return ret; } static void qcom_scm_shutdown(struct platform_device *pdev) From patchwork Tue Nov 19 18:33:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13880444 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 97A851DC198 for ; Tue, 19 Nov 2024 18:33:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732041228; cv=none; b=kQpn4jWt1s0rE3fdFzNO34B/3+Cz4SwEYA5Hi5GNSHFwWSk4UohnK9JitRyEQj6xp7FWiDVXgWSeCALZRce5IXpek7NQ9PfJB0ZC1NBJRS/qv/Q9n8PIOuCAUK5/Q/qnitE3YQe+6wmVVaOakYE8A7MMZTxBdtcClGgNHXiPoP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732041228; c=relaxed/simple; bh=5TLlUUFMlxVBRA9LfgfySqW4/f430JBLZVgZXAnTFfw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Sx6ek9WYbYb2I3uOMlPHMlZ8k1P1u2pQtDgI6/q6D3JQ0ngkjBI9YGu7uVTNCg9xfVNK8wAPpbahMwvUHW/cJY58fYYsIvKwwLVX3lPKEBmvWk/akOEfDOXaIuZOiGYryoRHsY8iwJJObY+G5gY+wnpEKsIDm1p7IJ2ZsAIDRws= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=g7gJwu+o; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="g7gJwu+o" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-43159469053so3484275e9.2 for ; Tue, 19 Nov 2024 10:33:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732041225; x=1732646025; 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=krw1ZM4+VGT72qR1TvdXm8jH8NeT3h/uE5f54vAoMeM=; b=g7gJwu+oKeRSGGE9X8TsprElghS+LoJyAlDHbfOytpT9fu2YTbcx5qhAPBkJwju73W pFTd5JGLq/C+1BLrDL0FqMQ7gL4qzzIeoMhAmDgcN5kaBlu/tJIiY5aldOYxYMu7YyYi lxh2aFnCmDDKMTUzitGT0/zDV7Mj/mrctaFd4/onG8tr3/CwiZt3N+PCxZuItaFgZ0Fz 33s0kYvw72W3s1+0703gi2rmY/tmWqMM1nEOkYrLjPqxQ8UYc+BXWpeyO6cO/WJdvjQb u+uli13+BjzTm2tXwE5rz8axfNnuOxUaJ5kpQzg23w8wAOhChji9reKRdDDFokKTp0DN oJ+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732041225; x=1732646025; 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=krw1ZM4+VGT72qR1TvdXm8jH8NeT3h/uE5f54vAoMeM=; b=jV8ag1dEbN8bvuFKqzdVSupZdYzbRjLyVYmMbkjmeeo5h//ujxjzEsUkmzcOE8r5M9 SXr0B9RgETpy6iLGXeOFpb4e0NyLjy+l5XRriuYXu5dh7DSt3foxcaqKA6QHD9JOP2cx dhvvIhACEdUZqJooDAvrb61LU4xFJ2LXAVvSFRk5r7tzKO5B2/QhocxV0f5Fc1VR44BI Hj2NGnn49k8Y9RYBU69RSwPMIh7k806AANU7ZfzVSW1Ng29x+FuQFor3yoKvTH4xIO1w DLfbB4ENa8CHHCeRzfIrgb8I8ZZ3UMCuLmAq9WoqyM54RKtYjs2XbmxU/uuDZaGkE70+ SnNA== X-Gm-Message-State: AOJu0Yx3HWX1kDvombLKPh518oXhs410LsbnILi6nEw19obS64oGxPpD 39o8kdEc+nFuPS/E3pmfKC/cazun7ETMI+XV+n0jm9+eIJNk4W/AHxseWXc4CSo= X-Gm-Gg: ASbGnct0J8WDTwG05n0IoBTrlyzWLNx9817NtA6DPWsLdzLVqTitTxDhGTgV6/HjtUI sEvVd/jXFIBQan6nvJk3ZrLPMFJNt8U91bKNOAsrs3aZfuTQKKtg1Q69yXonLoQ638nlCwgsqyf DorRlWzg6jfdclY98sFualv1v6Neku+20FkkqmxCk88WJc/j76BITs/bbeiAuiSR73B+5I/8gEW FvlyCkdLkpt/TEfEpc2wOGYc3deUy8oJk6eiF4jbDmIVceD4RITgRL7QK1+DgU5Yw== X-Google-Smtp-Source: AGHT+IFKsT1DiSbpf5PXE5z3Wd3P4fsh4a8OVSAGjFSsPxYJz3NDmkZpyljk4ipR8meIpqAZqRhrBw== X-Received: by 2002:a05:600c:1c1f:b0:430:52ec:1e2a with SMTP id 5b1f17b1804b1-432df790752mr64864275e9.7.1732041224946; Tue, 19 Nov 2024 10:33:44 -0800 (PST) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac1fb7asm201566805e9.42.2024.11.19.10.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 10:33:44 -0800 (PST) From: Krzysztof Kozlowski Date: Tue, 19 Nov 2024 19:33:21 +0100 Subject: [PATCH 5/6] firmware: qcom: scm: smc: Handle missing SCM device Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-5-7056127007a7@linaro.org> References: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-0-7056127007a7@linaro.org> In-Reply-To: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-0-7056127007a7@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Mukesh Ojha , Dmitry Baryshkov , Stephan Gerhold , Bartosz Golaszewski , Kuldeep Singh , Elliot Berman , Andrew Halaney , Avaneesh Kumar Dwivedi , Andy Gross Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=985; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=5TLlUUFMlxVBRA9LfgfySqW4/f430JBLZVgZXAnTFfw=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnPNn7FzUgjn+Cac29NIvPhw3hxDzi8lbQQrhEq VIrozZ5IZmJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZzzZ+wAKCRDBN2bmhouD 1+pTD/9arhmbhIWwWWeIpDWqvzkFts1PjFJXdAfWSCfH3WDvOMhlhUTREATysuQnrP+DCg1E5rE jn1Ul1wQYfrMk44pXbDOozHS/vIer8FLRpaIMNYBYG/jsrgefeIBenN6PyMh1zfe9edb5GqdVNa G61OkT1aFhQEpR3gK0RFDNKcM8P1tU/pPs2f1WpBaM4GkVe0YDdvHE9TRritxqkoWHpKKiBDm7t pq96rTJp9h6KbUVAQ+GwMBhGaCiVtMzcaaV1ddAEy+H1kOae05s1QL4718gvvHQ/sxEpATbgLUF gCVXLlAPNKi+MserPmxE2e9t8wnSCqe3CXUE+Cy/jCRABUVBJQmsc+XQ9rXw4PXhVJ5ujm+ffmP JfLI359OrWOQCC8l6x05UPbaaLjvt36/4oY2X3o5ric8W/Jtwo4gyQx7LguyogZVh/LjT7wyE6q iLWifBHS7WhuLTVf3JQm/K86y/QCNMo9jA3v/dDpFogN2NFyUwVbhgiFVuTW/ky/VSnj3CM40dN 5amoX9FOtnsYuPkaoTfhREg1eMiWKiGdLxvorAPAx1n6BhPN9soE9/FBaum1wKtQxOrsIy/XsWx hEpbnVwIm41Do1fgmED9deO87p63GL08bcH5KPVRbaXFvliGXNh+Jt9qWZogi3tSEtZX1TLX2tH mzq2FHLKiPof37Q== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Commit ca61d6836e6f ("firmware: qcom: scm: fix a NULL-pointer dereference") makes it explicit that qcom_scm_get_tzmem_pool() can return NULL, therefore its users should handle this. Signed-off-by: Krzysztof Kozlowski --- drivers/firmware/qcom/qcom_scm-smc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/firmware/qcom/qcom_scm-smc.c b/drivers/firmware/qcom/qcom_scm-smc.c index 2b4c2826f57251f25a1bc37c3b467dde28e1268b..3f10b23ec941b558e1d91761011776bb5c9d11b5 100644 --- a/drivers/firmware/qcom/qcom_scm-smc.c +++ b/drivers/firmware/qcom/qcom_scm-smc.c @@ -173,6 +173,9 @@ int __scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc, smc.args[i + SCM_SMC_FIRST_REG_IDX] = desc->args[i]; if (unlikely(arglen > SCM_SMC_N_REG_ARGS)) { + if (!mempool) + return -EINVAL; + args_virt = qcom_tzmem_alloc(mempool, SCM_SMC_N_EXT_ARGS * sizeof(u64), flag); From patchwork Tue Nov 19 18:33:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13880445 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 592761DD877 for ; Tue, 19 Nov 2024 18:33:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732041234; cv=none; b=N6BRSrqowBGjrV26HG20sOKJU+gxQ9fejTFn6SjHjFBKa8RTqK+NjKyV5bD13unEacdfMvIhykehZ9TfGJK0yI3q/yE8M13KHIpGN58hD0kobLbxtDBZi3+/rhpex28rNRMgnJ6iSAtdbUkFXlrT/hmdBwmMRBaBZOuuGYI2Md4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732041234; c=relaxed/simple; bh=sXmaBm/EfJtd8mtGNHFuhr5vkWmohAC+J7HluLurjEY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DReNqXhMovQyDEaAGJj4H/17Ch0u9eyxIaEVtpkwaOKTSuhUYo7yiuJzVktQ1sDCYCKmxbPuDPvKRl/rk3BHk1+MUNsAUMIGR3aE4YvGLcboTW+Ge10CYDg+UUbuo0KrQrgPdkhl+OpLxbbDc+OWoq6/ETIoYdGOJel0DBSIR/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=ED5oRwHq; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ED5oRwHq" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-43160c5bad8so3484005e9.3 for ; Tue, 19 Nov 2024 10:33:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732041227; x=1732646027; 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=mEuzfplamO9MTc2aT52efgHBGucpvCvsmLRhDItr6G8=; b=ED5oRwHqp5TEGbotiLV9Uwg761XJSc8rW75PvZBrwGiQw7evVq9658JqyiLTcE7tH7 NF96BgtICU4qN3A3AY3CT023aoc70lO/C2ehdYXlCOMHuK0c6lxGeskml8ulYA0tOS6M Z6lQDArOKR0iuLOP6y3h1qDE4R5JcsxRMqI3S9FSyVep6ILGvrknPozguGyeYKUYEYLf byExR5K85wu2RQmdNnzypP4+yssfn2J/n/f1jqlk4eFXLBvHnCzUzAIjCyU7ZXYW05gZ 2C0EvqfmktLQBPYh0/+iwVKA7WdeRVLrr+EVW7OpHI/SKB02d7WW1FfVmiypPBAG9330 VmKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732041227; x=1732646027; 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=mEuzfplamO9MTc2aT52efgHBGucpvCvsmLRhDItr6G8=; b=UEMqKXYsmHoSdiH5vkj6GdZ6lR46goxJ1ae3J6uTr47KYFufoLetrOx/O0/hD/Genc 0hVOf4N/0xSF+gN/5jvfhbS8OCtWiEeCJq0/9XMM/ZIZNkNYXJtTX/dSyE0wb85p0I/9 X6LrmAKqR13zf1c+dpKrRAAya9DziRM4KxJgjcNH1vQbDXhORcQBljrddnciSrlWwCwF JsmBt18ktS9hhtieK96yXyoF8KGseC8Q2mKhpxYGyHelzCTal9/vxooO/iAo15tJNg0k iY9phnyv0KnI11K2XflsYtLP0wa1JQ2wcN3/zSQY7H9U5fDCtqqYTdwROQKpSNBNpaSM V4Mg== X-Gm-Message-State: AOJu0Yz5g3p8BUocXm/AAsKqDzCW1YRPhj0+VhFM90snmIdXLCKji1u5 TQcrIKXAMARdx4zHE51hO9Yj5jVIvwuNAhDmisJNrC6YNqUeGjv3PtBfpT9OrFk= X-Gm-Gg: ASbGncsai5g1Qe3MSYSC57hIKjvxqUr2W1CD/OwGoYc+ZpcpI9xxw5BwVBZM32VzgCH LErSU8hAaRbffEQeo0vG1lTJcyp9u2TBdOGMZyLMMbTnicQmRhLRmlZw/1WXmanhbvK4HdIEpkZ HGnl21VHGpTlnbU7gafhh6ElluVcBwAYzY2RE/9JiGlN//6x9mLy3nuwvBjIT+IPBN1+9p7tUaB jFhvK6eaUxlicCHHAJaeju/+0fvfwkg1gjz0IUonW5i/v2/P7j/q5Xoyq8nFz7PSg== X-Google-Smtp-Source: AGHT+IEbHBp77Yd6c68qIRswrIHwNemz/LP46FQZao0WEifvrkkZhQW6J5+adg160ciW6LtYS87ayQ== X-Received: by 2002:a05:600c:4f4f:b0:42c:bb35:b6d0 with SMTP id 5b1f17b1804b1-433489861cbmr48655e9.1.1732041226661; Tue, 19 Nov 2024 10:33:46 -0800 (PST) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac1fb7asm201566805e9.42.2024.11.19.10.33.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 10:33:46 -0800 (PST) From: Krzysztof Kozlowski Date: Tue, 19 Nov 2024 19:33:22 +0100 Subject: [PATCH 6/6] firmware: qcom: scm: smc: Narrow 'mempool' variable scope Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-6-7056127007a7@linaro.org> References: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-0-7056127007a7@linaro.org> In-Reply-To: <20241119-qcom-scm-missing-barriers-and-all-sort-of-srap-v1-0-7056127007a7@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Mukesh Ojha , Dmitry Baryshkov , Stephan Gerhold , Bartosz Golaszewski , Kuldeep Singh , Elliot Berman , Andrew Halaney , Avaneesh Kumar Dwivedi , Andy Gross Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1247; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=sXmaBm/EfJtd8mtGNHFuhr5vkWmohAC+J7HluLurjEY=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnPNn8rIB+XBSdKxZJHA0MgPDAuwj/K2aS2hOzc gDc2EAOQcOJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZzzZ/AAKCRDBN2bmhouD 11WiD/0br3gwbDJTHdnKByah6j9dURjMn3ou5Kz8DxwRZzqBfSfwonWfwXuC95p/xgLY/gAx/6R ytsnr6GGMaDtPH+djW51iLom1RFxUL+clgh7qe+6linxTxP+ZLHzFuvLRDxO1qZ8zNG0XlAA+Dh fBN+xjNW/tcu4Rkl8W96g5bJJNarojOtJrQNyz4w44rRTIA+ZrfTZ+lHqtVr5Kqsip17JllwRvx p6Xn8FMZMLnX/0D+1NjUvNBHQcRAZOjo1PioiGshRVuqh+X0u2BY8Qlgo5AH3v7Ax17jv4nrE2O QyxU8v3FnvnHxTZ3cjNY+k+l+4q5lN79w9s51FNJBBehh3BAsL8OekpRr4dEYu2OrLasQvJzQqp hc/kwvyiz5oCsMefFJjtyz4zaPJ5lD0+ZwcxxCRWqrDrhApZguP+krdtZ2vjKE4Zzh4E3RmIfFs KhZQvKFqFnXaFI1mPeYB/ttbivht5/ZVSYcmfUhS0Gs7qbqqim8073JoeP3KRZ7prrChSDZ/7C1 dvuFLmqy9ws/1ESJuZtdkh+FahWPtrU0yVvRnYLA3V4ayS8YKdxsdRi5owtV1jdmoGWH4kpBDLA SoWO6oVl5bmFruHPZm1cYdSOs9A8a9RpRZk10ljty7kb/JrlzuU970/45NWZLk7KLW1YWrXkFlq ycJH4MySyymhzHg== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Only part of the __scm_smc_call() function uses 'mempool' variable, so narrow the scope to make it more readable. Signed-off-by: Krzysztof Kozlowski --- drivers/firmware/qcom/qcom_scm-smc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/qcom/qcom_scm-smc.c b/drivers/firmware/qcom/qcom_scm-smc.c index 3f10b23ec941b558e1d91761011776bb5c9d11b5..574930729ddd72d98013770da97cc018a52554ff 100644 --- a/drivers/firmware/qcom/qcom_scm-smc.c +++ b/drivers/firmware/qcom/qcom_scm-smc.c @@ -152,7 +152,6 @@ int __scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc, enum qcom_scm_convention qcom_convention, struct qcom_scm_res *res, bool atomic) { - struct qcom_tzmem_pool *mempool = qcom_scm_get_tzmem_pool(); int arglen = desc->arginfo & 0xf; int i, ret; void *args_virt __free(qcom_tzmem) = NULL; @@ -173,6 +172,8 @@ int __scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc, smc.args[i + SCM_SMC_FIRST_REG_IDX] = desc->args[i]; if (unlikely(arglen > SCM_SMC_N_REG_ARGS)) { + struct qcom_tzmem_pool *mempool = qcom_scm_get_tzmem_pool(); + if (!mempool) return -EINVAL;