From patchwork Fri Apr 19 14:00:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 790291 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.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 6F96212D1F9 for ; Fri, 19 Apr 2024 14:00:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713535244; cv=none; b=eYPXlczwqHwy8j0SMAc0BhdkmFV5sTUOMJrb9mnzontF78k7Okwj6s3Iy1nBv2OSOxDNr4pOVlCHXo0MrkE0A/Z13r0dRw/j7n93XH4ZBU73w0s806gFxKIROij+DLf9Qz88C9QZsh11qJ1/AMOIh6VRMIg85CNtom4I5r7tlSI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713535244; c=relaxed/simple; bh=OSaaTloV3qTUv65Q5MV+1+bKbdFYs/aBBRehChJIAYs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oMYlIq6vwVkUJ4NOi0X/bmawI+soGeAM8tHazf16EnJvf4vOyZAF9Ho7ZUP8wccqCO9WOMf5RT5TWm1GHJ5tZk+P9vC/F+YOkAXOJa2+LTB+hpIzBGobtNAPyX8yoGnkRmomjgX5nGMBmBxFqx4b2CBeCdrcEy+D8Ks9i7qLKlQ= 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=mHqG2q/U; arc=none smtp.client-ip=209.85.218.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="mHqG2q/U" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a555b203587so232755366b.3 for ; Fri, 19 Apr 2024 07:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713535240; x=1714140040; 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=ZVP3aG0NcRA85ZVF6oXusqwv7tzNPZN1nlYmyccmDwI=; b=mHqG2q/UgjQ8PwPt6xSHve/9rsTKyLJ6R1MN0cXGqY2+2Wrxs5yBhsYBsBBZZtcyl4 z2AhZw5rvKwdohPqc9cajF8CnGsJIG+D6OMKWl/iLVcmDhzGQSUrAMCxgPhcMde5DDBl KaQkXpGY1Wxc+kJ4i0g8LQnaff94FzeSW8k08DnLSBhA3nf1KwDa/nruMCUEAYmpaiNK 7Oi+ZdsDdxSUyCK9agsDsPy87NeU1TPld6aW+sQZT4AIJLTpOw6WBU8BOUfWZSL8sSAM Tcx13J2s3Af9/tDONUM3JgiayuwvhjLkJqzr5MCFWTY1nkvW2/XeyF/iKdkEqoLsjW4l zc+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713535240; x=1714140040; 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=ZVP3aG0NcRA85ZVF6oXusqwv7tzNPZN1nlYmyccmDwI=; b=GZmiYfeN7BqM1mhgDANIgP1daTe+Oy4O9tTTPgTaS4QJh1lMCGoL44+RcvvuCUrzlg NFT1DKpiSLjG/oca3mYrX2tu03DOZ3Y720xgAFphUitZK3jXyBinLN2tArMjYlnymHBn gqueeuxpbVs6rECIXj9WjqBzc67jcI7DKz3DRwpdsH5SdNAFkGJxjSurdWfIF2NQ43OF 7RleebUw/w3XM0qiPMJV4tBH1AGBent0yPJCUcqO/Ej4OHRISGp1qF9GKQFLMgKnA8Yn 3+Cl7rX6nAbvDG2cP0KV9Z0tfFppGJCSP12GaiiJItFN795QUWkWIRul0QtgO+hs/ghC MZGw== X-Gm-Message-State: AOJu0YxVi/WJlKoX0b+uwiyLqpf2I2TdhYmXGIwSAiouWn3t3p/ZCbPs 4yeHUhSVrF4Y389bTSUYbeXF4EPC4B6WyYBk7rTCSCexSS5UyhBRgRvOxK6U3gEk5GJwpHvBc58 A X-Google-Smtp-Source: AGHT+IFMET/c6wI5F2rOCAb6gPQKE3sYKz35vOmssqnyPXKgh0BTtzhpr22YzbcpMCix2hHBfQGvxw== X-Received: by 2002:a17:906:5643:b0:a55:648f:3f03 with SMTP id v3-20020a170906564300b00a55648f3f03mr1709428ejr.53.1713535240385; Fri, 19 Apr 2024 07:00:40 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id qy1-20020a170907688100b00a558be8bc03sm532390ejc.150.2024.04.19.07.00.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 07:00:39 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 19 Apr 2024 17:00:29 +0300 Subject: [PATCH v5 1/6] soc: qcom: pdr: protect locator_addr with the main mutex Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240419-qcom-pd-mapper-v5-1-e35b6f847e99@linaro.org> References: <20240419-qcom-pd-mapper-v5-0-e35b6f847e99@linaro.org> In-Reply-To: <20240419-qcom-pd-mapper-v5-0-e35b6f847e99@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Mathieu Poirier , Sibi Sankar Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, Johan Hovold , Xilin Wu , Neil Armstrong X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1515; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=OSaaTloV3qTUv65Q5MV+1+bKbdFYs/aBBRehChJIAYs=; b=owGbwMvMwMXYbdNlx6SpcZXxtFoSQ5pSJesRywzXVw1iRryyf9lZ9zcHS7qFXDAJYts0g102b rsA47pORmMWBkYuBlkxRRafgpapMZuSwz7smFoPM4iVCWQKAxenAEykcw77P7v907md5oToBhc9 +vJaNXOyu0Ego0++yYGA/vrEi2+vZN7d6sSwVn9v+oek1db3vM4mnOqqa2tLzv9+4ckWpc8mrm9 lT3D1Tr9XJbW0pjHacPKXo9si8p+98PV6yf7rBIvecVGmf1k9qyU2JnNvzpF8aXxNWsmca+UF87 SaV/+C8sTfbs6XO8ylpxz/cOreG/nVmza474zgNKtleZVq4VDZvWTz39bOOVU8zRG6nL71b7TtN /n+FzbT1JsvHcdwwuTkboHPxuHr2LrUPl/tbtqyeMHjjQulDnDZayaGWllNrjnO//9ljY3s8y8R QW3hzP2K97859tbbdp2X8Hh6r19M8N9y4Wlai/avWmwLAA== X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A If the service locator server is restarted fast enough, the PDR can rewrite locator_addr fields concurrently. Protect them by placing modification of those fields under the main pdr->lock. Fixes: fbe639b44a82 ("soc: qcom: Introduce Protection Domain Restart helpers") Tested-by: Neil Armstrong # on SM8550-QRD Signed-off-by: Dmitry Baryshkov --- drivers/soc/qcom/pdr_interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/soc/qcom/pdr_interface.c b/drivers/soc/qcom/pdr_interface.c index a1b6a4081dea..19cfe4b41235 100644 --- a/drivers/soc/qcom/pdr_interface.c +++ b/drivers/soc/qcom/pdr_interface.c @@ -76,12 +76,12 @@ static int pdr_locator_new_server(struct qmi_handle *qmi, locator_hdl); struct pdr_service *pds; + mutex_lock(&pdr->lock); /* Create a local client port for QMI communication */ pdr->locator_addr.sq_family = AF_QIPCRTR; pdr->locator_addr.sq_node = svc->node; pdr->locator_addr.sq_port = svc->port; - mutex_lock(&pdr->lock); pdr->locator_init_complete = true; mutex_unlock(&pdr->lock); @@ -104,10 +104,10 @@ static void pdr_locator_del_server(struct qmi_handle *qmi, mutex_lock(&pdr->lock); pdr->locator_init_complete = false; - mutex_unlock(&pdr->lock); pdr->locator_addr.sq_node = 0; pdr->locator_addr.sq_port = 0; + mutex_unlock(&pdr->lock); } static const struct qmi_ops pdr_locator_ops = { From patchwork Fri Apr 19 14:00:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 790738 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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 6C80B12D745 for ; Fri, 19 Apr 2024 14:00:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713535245; cv=none; b=L5XmnqiBy+A8/QKl5nW/o2r9SVAeOZtOxZN54qBP29LtRfN/qnHNueKtsBY1xi4j/a+Bv4ih5iRkD612jbLjSfXmOO1hcKcbQl3NoOzqgEBgRsdyf1njjRBeyE8Q75MV5BUUGZaizLUec0RA+OVZb/uY2O1M25W8uJtmtSo9AzU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713535245; c=relaxed/simple; bh=5hXnO01E2x9fmcS8/rZbJSCLl/2FJgazSpXgDUcXmNU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WbGgrZadG1M11jtIjlbJGgxMwQBE15lu5IjUT/tin7WOuhrETElWmQ1hVJC/AzcIC9+KuB0+AnXgtvZwVfTJbIPv6z5R8Q9FKdm3uuM2OjBn2HaSfW3RCH3oKfK2dHHxrpkRvvtXGH38ZpppelHJkp7CK/fsTiQfVkWrF/7ugjs= 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=vOehAlup; arc=none smtp.client-ip=209.85.167.51 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="vOehAlup" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-5196c755e82so2743166e87.0 for ; Fri, 19 Apr 2024 07:00:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713535241; x=1714140041; 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=TM1RhMLiz+lI7GOe6oFw/63N/y/J+ZLWylZ/Uc+1/88=; b=vOehAluptP4eMCR+ihZSGkW7sEUX6mVdce8FeMYIRcrLdO6iZQ86ii6ggUffzHEBeP V99wjimd2w9bgKVgjl59mGuhAa1uD8MgcGyPmlNYqmwsXqNsm99U7KT7SqbgS7QazMI/ Zb23AYyyl3h8E94T0qsS7/89lzPrAGh9EfEWqmoOGg1U4pIJhVZ/k7XnRmJszMFlcZ4e ruk8gsxL0PpgaoC6Cb73J8nNRLsE28S54fHKoKxDdwKC/yh8L4MZ3tW3hdPjLiTeP9SI oQEvAXN4HlG+DwLNM7MCXWug6acEuUUnlxh37S8XrIONfu3mP9AUXEV1xsMZn7abUIBr kPyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713535241; x=1714140041; 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=TM1RhMLiz+lI7GOe6oFw/63N/y/J+ZLWylZ/Uc+1/88=; b=VhIXYBWfAVUEN/ZBugahKDqkmASBl7tc9p8WpAD6R/Ew2f4jy4AjtVUU16SG5CPZH6 HoR89AMg48l0gOh1Au3Rg7/aZj4ouSnXmD70XjOr4OojqTNhaXjmz9YgTO+dCv+viCX2 0/Z5EKrdUjRTScYFWatz0r1t6mZOqmR89OMGzn2QJo2run9ydh0pAAc6bKy3F91kw8nM XYFSa79ndfuyx3HqWq47gNqp/Dm8IyxcU6x+r+OblxGm745ucUW1RU+rU6juAJ0sZgdb BjaWf4hEJFyxlHwevEMWyv3TbwMM7Krt9Poske8Dd84NYhXREOiECj+g0MK6WS7X2dL/ Ybww== X-Gm-Message-State: AOJu0Yx/j+rshRzUjvbmq1gJdSluQg45ynnNrR+GbsBkpacZKvLB9Ghc pypjZdXT8v4JgsakmiZPV7gccZfFq81e4a4R+ugwDxeaIH72XUT54RubXQI0DWa+ubhV29c6jXQ + X-Google-Smtp-Source: AGHT+IHVzIG5EHTGeGvnuJJI6QCeX9IkjlUAwpW6DnN9RujgIXqknzt//juew12rrQF6U6IkwjYzNA== X-Received: by 2002:a05:6512:2c88:b0:513:e63c:cfe7 with SMTP id dw8-20020a0565122c8800b00513e63ccfe7mr1620992lfb.66.1713535241283; Fri, 19 Apr 2024 07:00:41 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id qy1-20020a170907688100b00a558be8bc03sm532390ejc.150.2024.04.19.07.00.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 07:00:40 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 19 Apr 2024 17:00:30 +0300 Subject: [PATCH v5 2/6] soc: qcom: pdr: fix parsing of domains lists Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240419-qcom-pd-mapper-v5-2-e35b6f847e99@linaro.org> References: <20240419-qcom-pd-mapper-v5-0-e35b6f847e99@linaro.org> In-Reply-To: <20240419-qcom-pd-mapper-v5-0-e35b6f847e99@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Mathieu Poirier , Sibi Sankar Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, Johan Hovold , Xilin Wu X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1042; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=5hXnO01E2x9fmcS8/rZbJSCLl/2FJgazSpXgDUcXmNU=; b=owGbwMvMwMXYbdNlx6SpcZXxtFoSQ5pSJWvSTaOqMz9mluVcNZvU8ydQaPpi/6hv7MtzmfxeJ zGUMB3rZDRmYWDkYpAVU2TxKWiZGrMpOezDjqn1MINYmUCmMHBxCsBEYvzY/xf4PXqd47Z9bWKy 7ILUI+peTI3tkgV2N3bsTGlMWji7Jk0nJ3Md0yHbyz4TJbQjUyrC5Cw0bKSypqgLftppZXNr366 LPjEl4TmdPwPE1+mmShlwpDHFK5yXurXkyL9pHiw9Ic2vi89/sg2vuHdaRorfhi3it37wxyLjHv vrQUzS0kqL97Aa+b5dUX7Q/q1RNpPjrk8ZWZlrWPqfbqw5mqTr/+vWTq9TGSvrZ9woFXh0PNLo4 FeWOXe/7NE6lJKRyVf/eqN/79xz24tz9++cc9Xf/TODaLnxpQAhxat8ySFHGdakKMwt6Vk1Wcbm ddAjba4XG8+pv70r/OeCtUJQiLCaGGv/s1eKwSf2mfsAAA== X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A While parsing the domains list, start offsets from 0 rather than from domains_read. The domains_read is equal to the total count of the domains we have seen, while the domains list in the message starts from offset 0. Fixes: fbe639b44a82 ("soc: qcom: Introduce Protection Domain Restart helpers") Signed-off-by: Dmitry Baryshkov --- drivers/soc/qcom/pdr_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soc/qcom/pdr_interface.c b/drivers/soc/qcom/pdr_interface.c index 19cfe4b41235..3c6f2d21e5e4 100644 --- a/drivers/soc/qcom/pdr_interface.c +++ b/drivers/soc/qcom/pdr_interface.c @@ -415,7 +415,7 @@ static int pdr_locate_service(struct pdr_handle *pdr, struct pdr_service *pds) if (ret < 0) goto out; - for (i = domains_read; i < resp->domain_list_len; i++) { + for (i = 0; i < resp->domain_list_len; i++) { entry = &resp->domain_list[i]; if (strnlen(entry->name, sizeof(entry->name)) == sizeof(entry->name)) From patchwork Fri Apr 19 14:00:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 790290 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.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 8CFB612D755 for ; Fri, 19 Apr 2024 14:00:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713535247; cv=none; b=J6/VSHTJeSY03gg2wdu0YvrRSlvJr44iYntVjwVZRHCGaC/ETw7fJWkexCqtfqdZfCkTov6uzaA+hPFi1YJJJ/LpgCuqtl1Wnye0nNzN/U0NMIeovAgn85V6LZ5SgWFDEh+azDs0v/N3ysOpIDSzKXP9mHZO3trALGT/iXdus08= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713535247; c=relaxed/simple; bh=0UGx8QbSZGzg3ygb0mKScq092u7nk1gV2+OI8+zlovs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=U5D6Y8IHss+iqvgf/q2Csw23ByKWB7qBPuQv+Ir1Rpg1ts4JYXI28Yq9OptFQSuRBDLqZ4a6YTVzQ5eDxPOqIkKxsfi6CixqAizUaWFY1l6Uh6WVU4ukeIS2AnBoRkRSj7OnpBoTrOP4mCDfzvxtRqnXJcBgo1bFZaiGDD9iFt4= 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=jzmA7Ngn; arc=none smtp.client-ip=209.85.218.47 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="jzmA7Ngn" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a556d22fa93so245742966b.3 for ; Fri, 19 Apr 2024 07:00:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713535242; x=1714140042; 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=de3OEliaD40Rkp315y+pgQpCEPpvGZNu7ciUx+gH17c=; b=jzmA7NgnLZFZZkyIAi+yFPVGTMLUpooMKIdrHTk28lYdRARZdxozXMW5fafr4HR7KF H/gAvPJNu6gshYKBVK/TjdtN6MgPrH7XEKKQsAeuMYyozcqtIAJoT5qaGnaPUKS5JPxm fnmp3CU6T/eAa0DOib9cfWpLr9Y3paJPetThV8P25LAKx+YJaHW2WkGDnNxjoSPrxUIF nq4tRIPkQLmv4rSQWSZv+3m0Y+1w16kqp+UZwut+H9FjDNt1gMuV1GtawL/XM2+QVlcQ YXyEFxW0VXBqbhNifciqBV+dJl2MtQq9TN800r7vf7J+TcxusfRFyNLnOfWEcs/E+rFg 63DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713535242; x=1714140042; 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=de3OEliaD40Rkp315y+pgQpCEPpvGZNu7ciUx+gH17c=; b=KtRkGQloxX2N9l+SoQ1iVCuQfC7Qs0tsUm6vJisVMW4cq75o9u38LViO78bslx/ygm oirXfZs+ERUBjZ9YGvZKuSQ05Ib9QwWU0iuUMZb20aJCd66Vcs2QqFh2zc+csw4NdCVQ lmYTGpD6InWhue7zPrlWnkwbl3v5Oy3vhhAedqQaM7JDnaq/0qXi4GW3MxFyvzIDtX3q +AFl0rrorLAzWhTgI5IFFwa2ir/Xj1cDeC3iAgGiAmAzvNJ4h8OvtUmOQtIIjscgxGLp Ow2jwozFO1e4fqUSqN/5EANExOzBklfn7vvxpBktZkyKVfNt9305ouvTccTw+p5asKBQ g2eg== X-Gm-Message-State: AOJu0YxtbN1jtg3HMIkH56Xqy1XQzxcrd/IEBGrRUiUKHXuE5i+P/fkq QPu2iMGetWyvcA+z4TkQq+8XsGydox83I/oa5XLKDJYFm1FmMNTMZH2jktWADi64rTg/UX1nghY l X-Google-Smtp-Source: AGHT+IExGa8h6czJRpvNgWRMOPLS44arIeFcCpGpkcVGN2CHDj/CdrrI9i3dbEEQS+0Y8d07TomFKw== X-Received: by 2002:a17:907:7087:b0:a52:262d:d998 with SMTP id yj7-20020a170907708700b00a52262dd998mr1431663ejb.62.1713535242533; Fri, 19 Apr 2024 07:00:42 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id qy1-20020a170907688100b00a558be8bc03sm532390ejc.150.2024.04.19.07.00.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 07:00:41 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 19 Apr 2024 17:00:31 +0300 Subject: [PATCH v5 3/6] soc: qcom: pdr: extract PDR message marshalling data Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240419-qcom-pd-mapper-v5-3-e35b6f847e99@linaro.org> References: <20240419-qcom-pd-mapper-v5-0-e35b6f847e99@linaro.org> In-Reply-To: <20240419-qcom-pd-mapper-v5-0-e35b6f847e99@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Mathieu Poirier , Sibi Sankar Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, Johan Hovold , Xilin Wu X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=21659; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=0UGx8QbSZGzg3ygb0mKScq092u7nk1gV2+OI8+zlovs=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmInkFWg6MQ8jzxXxlTHph43v7Vi0VLXLtZ2+L+ BB5pafEJISJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZiJ5BQAKCRCLPIo+Aiko 1eQ1B/9pPYY0/LufCeCNUsYyfc2GTQi4W7HDIvFBBPF/+pVPML1jsPSst5VpB+ou8idr/GDGbv2 cIZY3Sda4egTO2LbdeGWG2Z2Corl0girSuXy7n8QS5MoW2CuArXkcPfezmD1GJR8wz2qV/n7J7L eIYMHnbM2WT5qLWfl+xpF3fzd3x4Tk3Y1nkJe395UZPEmav1ve6gXklKjQydErI4a+g9uZJEDLN vMLXhPNMbrCrZUwahm6V2h8s+eT3Yl7u60c0NTHMOB6aZ8Bpw7mKmkywWcvA4otumem0iYjkkTm lBS4TopQlZKBraUTutacHqBHrz9tMKsrgNHcdOt+3h1nG/cs X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A The in-kernel PD mapper is going to use same message structures as the QCOM_PDR_HELPERS module. Extract message marshalling data to separate module that can be used by both PDR helpers and by PD mapper. Signed-off-by: Dmitry Baryshkov Reviewed-by: Bryan O'Donoghue --- drivers/soc/qcom/Kconfig | 4 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/pdr_internal.h | 306 ++------------------------------------ drivers/soc/qcom/qcom_pdr_msg.c | 315 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 330 insertions(+), 296 deletions(-) diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index 5af33b0e3470..95973c6b828f 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -75,8 +75,12 @@ config QCOM_OCMEM config QCOM_PDR_HELPERS tristate select QCOM_QMI_HELPERS + select QCOM_PDR_MSG depends on NET +config QCOM_PDR_MSG + tristate + config QCOM_PMIC_PDCHARGER_ULOG tristate "Qualcomm PMIC PDCharger ULOG driver" depends on RPMSG diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index ca0bece0dfff..3110ac3288bc 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_QCOM_GSBI) += qcom_gsbi.o obj-$(CONFIG_QCOM_MDT_LOADER) += mdt_loader.o obj-$(CONFIG_QCOM_OCMEM) += ocmem.o obj-$(CONFIG_QCOM_PDR_HELPERS) += pdr_interface.o +obj-$(CONFIG_QCOM_PDR_MSG) += qcom_pdr_msg.o obj-$(CONFIG_QCOM_PMIC_GLINK) += pmic_glink.o obj-$(CONFIG_QCOM_PMIC_GLINK) += pmic_glink_altmode.o obj-$(CONFIG_QCOM_PMIC_PDCHARGER_ULOG) += pmic_pdcharger_ulog.o diff --git a/drivers/soc/qcom/pdr_internal.h b/drivers/soc/qcom/pdr_internal.h index 03c282b7f17e..7e5bb5a95275 100644 --- a/drivers/soc/qcom/pdr_internal.h +++ b/drivers/soc/qcom/pdr_internal.h @@ -28,83 +28,12 @@ struct servreg_location_entry { u32 instance; }; -static const struct qmi_elem_info servreg_location_entry_ei[] = { - { - .data_type = QMI_STRING, - .elem_len = SERVREG_NAME_LENGTH + 1, - .elem_size = sizeof(char), - .array_type = NO_ARRAY, - .tlv_type = 0, - .offset = offsetof(struct servreg_location_entry, - name), - }, - { - .data_type = QMI_UNSIGNED_4_BYTE, - .elem_len = 1, - .elem_size = sizeof(u32), - .array_type = NO_ARRAY, - .tlv_type = 0, - .offset = offsetof(struct servreg_location_entry, - instance), - }, - { - .data_type = QMI_UNSIGNED_1_BYTE, - .elem_len = 1, - .elem_size = sizeof(u8), - .array_type = NO_ARRAY, - .tlv_type = 0, - .offset = offsetof(struct servreg_location_entry, - service_data_valid), - }, - { - .data_type = QMI_UNSIGNED_4_BYTE, - .elem_len = 1, - .elem_size = sizeof(u32), - .array_type = NO_ARRAY, - .tlv_type = 0, - .offset = offsetof(struct servreg_location_entry, - service_data), - }, - {} -}; - struct servreg_get_domain_list_req { char service_name[SERVREG_NAME_LENGTH + 1]; u8 domain_offset_valid; u32 domain_offset; }; -static const struct qmi_elem_info servreg_get_domain_list_req_ei[] = { - { - .data_type = QMI_STRING, - .elem_len = SERVREG_NAME_LENGTH + 1, - .elem_size = sizeof(char), - .array_type = NO_ARRAY, - .tlv_type = 0x01, - .offset = offsetof(struct servreg_get_domain_list_req, - service_name), - }, - { - .data_type = QMI_OPT_FLAG, - .elem_len = 1, - .elem_size = sizeof(u8), - .array_type = NO_ARRAY, - .tlv_type = 0x10, - .offset = offsetof(struct servreg_get_domain_list_req, - domain_offset_valid), - }, - { - .data_type = QMI_UNSIGNED_4_BYTE, - .elem_len = 1, - .elem_size = sizeof(u32), - .array_type = NO_ARRAY, - .tlv_type = 0x10, - .offset = offsetof(struct servreg_get_domain_list_req, - domain_offset), - }, - {} -}; - struct servreg_get_domain_list_resp { struct qmi_response_type_v01 resp; u8 total_domains_valid; @@ -116,264 +45,49 @@ struct servreg_get_domain_list_resp { struct servreg_location_entry domain_list[SERVREG_DOMAIN_LIST_LENGTH]; }; -static const struct qmi_elem_info servreg_get_domain_list_resp_ei[] = { - { - .data_type = QMI_STRUCT, - .elem_len = 1, - .elem_size = sizeof(struct qmi_response_type_v01), - .array_type = NO_ARRAY, - .tlv_type = 0x02, - .offset = offsetof(struct servreg_get_domain_list_resp, - resp), - .ei_array = qmi_response_type_v01_ei, - }, - { - .data_type = QMI_OPT_FLAG, - .elem_len = 1, - .elem_size = sizeof(u8), - .array_type = NO_ARRAY, - .tlv_type = 0x10, - .offset = offsetof(struct servreg_get_domain_list_resp, - total_domains_valid), - }, - { - .data_type = QMI_UNSIGNED_2_BYTE, - .elem_len = 1, - .elem_size = sizeof(u16), - .array_type = NO_ARRAY, - .tlv_type = 0x10, - .offset = offsetof(struct servreg_get_domain_list_resp, - total_domains), - }, - { - .data_type = QMI_OPT_FLAG, - .elem_len = 1, - .elem_size = sizeof(u8), - .array_type = NO_ARRAY, - .tlv_type = 0x11, - .offset = offsetof(struct servreg_get_domain_list_resp, - db_rev_count_valid), - }, - { - .data_type = QMI_UNSIGNED_2_BYTE, - .elem_len = 1, - .elem_size = sizeof(u16), - .array_type = NO_ARRAY, - .tlv_type = 0x11, - .offset = offsetof(struct servreg_get_domain_list_resp, - db_rev_count), - }, - { - .data_type = QMI_OPT_FLAG, - .elem_len = 1, - .elem_size = sizeof(u8), - .array_type = NO_ARRAY, - .tlv_type = 0x12, - .offset = offsetof(struct servreg_get_domain_list_resp, - domain_list_valid), - }, - { - .data_type = QMI_DATA_LEN, - .elem_len = 1, - .elem_size = sizeof(u8), - .array_type = NO_ARRAY, - .tlv_type = 0x12, - .offset = offsetof(struct servreg_get_domain_list_resp, - domain_list_len), - }, - { - .data_type = QMI_STRUCT, - .elem_len = SERVREG_DOMAIN_LIST_LENGTH, - .elem_size = sizeof(struct servreg_location_entry), - .array_type = VAR_LEN_ARRAY, - .tlv_type = 0x12, - .offset = offsetof(struct servreg_get_domain_list_resp, - domain_list), - .ei_array = servreg_location_entry_ei, - }, - {} -}; - struct servreg_register_listener_req { u8 enable; char service_path[SERVREG_NAME_LENGTH + 1]; }; -static const struct qmi_elem_info servreg_register_listener_req_ei[] = { - { - .data_type = QMI_UNSIGNED_1_BYTE, - .elem_len = 1, - .elem_size = sizeof(u8), - .array_type = NO_ARRAY, - .tlv_type = 0x01, - .offset = offsetof(struct servreg_register_listener_req, - enable), - }, - { - .data_type = QMI_STRING, - .elem_len = SERVREG_NAME_LENGTH + 1, - .elem_size = sizeof(char), - .array_type = NO_ARRAY, - .tlv_type = 0x02, - .offset = offsetof(struct servreg_register_listener_req, - service_path), - }, - {} -}; - struct servreg_register_listener_resp { struct qmi_response_type_v01 resp; u8 curr_state_valid; enum servreg_service_state curr_state; }; -static const struct qmi_elem_info servreg_register_listener_resp_ei[] = { - { - .data_type = QMI_STRUCT, - .elem_len = 1, - .elem_size = sizeof(struct qmi_response_type_v01), - .array_type = NO_ARRAY, - .tlv_type = 0x02, - .offset = offsetof(struct servreg_register_listener_resp, - resp), - .ei_array = qmi_response_type_v01_ei, - }, - { - .data_type = QMI_OPT_FLAG, - .elem_len = 1, - .elem_size = sizeof(u8), - .array_type = NO_ARRAY, - .tlv_type = 0x10, - .offset = offsetof(struct servreg_register_listener_resp, - curr_state_valid), - }, - { - .data_type = QMI_SIGNED_4_BYTE_ENUM, - .elem_len = 1, - .elem_size = sizeof(enum servreg_service_state), - .array_type = NO_ARRAY, - .tlv_type = 0x10, - .offset = offsetof(struct servreg_register_listener_resp, - curr_state), - }, - {} -}; - struct servreg_restart_pd_req { char service_path[SERVREG_NAME_LENGTH + 1]; }; -static const struct qmi_elem_info servreg_restart_pd_req_ei[] = { - { - .data_type = QMI_STRING, - .elem_len = SERVREG_NAME_LENGTH + 1, - .elem_size = sizeof(char), - .array_type = NO_ARRAY, - .tlv_type = 0x01, - .offset = offsetof(struct servreg_restart_pd_req, - service_path), - }, - {} -}; - struct servreg_restart_pd_resp { struct qmi_response_type_v01 resp; }; -static const struct qmi_elem_info servreg_restart_pd_resp_ei[] = { - { - .data_type = QMI_STRUCT, - .elem_len = 1, - .elem_size = sizeof(struct qmi_response_type_v01), - .array_type = NO_ARRAY, - .tlv_type = 0x02, - .offset = offsetof(struct servreg_restart_pd_resp, - resp), - .ei_array = qmi_response_type_v01_ei, - }, - {} -}; - struct servreg_state_updated_ind { enum servreg_service_state curr_state; char service_path[SERVREG_NAME_LENGTH + 1]; u16 transaction_id; }; -static const struct qmi_elem_info servreg_state_updated_ind_ei[] = { - { - .data_type = QMI_SIGNED_4_BYTE_ENUM, - .elem_len = 1, - .elem_size = sizeof(u32), - .array_type = NO_ARRAY, - .tlv_type = 0x01, - .offset = offsetof(struct servreg_state_updated_ind, - curr_state), - }, - { - .data_type = QMI_STRING, - .elem_len = SERVREG_NAME_LENGTH + 1, - .elem_size = sizeof(char), - .array_type = NO_ARRAY, - .tlv_type = 0x02, - .offset = offsetof(struct servreg_state_updated_ind, - service_path), - }, - { - .data_type = QMI_UNSIGNED_2_BYTE, - .elem_len = 1, - .elem_size = sizeof(u16), - .array_type = NO_ARRAY, - .tlv_type = 0x03, - .offset = offsetof(struct servreg_state_updated_ind, - transaction_id), - }, - {} -}; - struct servreg_set_ack_req { char service_path[SERVREG_NAME_LENGTH + 1]; u16 transaction_id; }; -static const struct qmi_elem_info servreg_set_ack_req_ei[] = { - { - .data_type = QMI_STRING, - .elem_len = SERVREG_NAME_LENGTH + 1, - .elem_size = sizeof(char), - .array_type = NO_ARRAY, - .tlv_type = 0x01, - .offset = offsetof(struct servreg_set_ack_req, - service_path), - }, - { - .data_type = QMI_UNSIGNED_2_BYTE, - .elem_len = 1, - .elem_size = sizeof(u16), - .array_type = NO_ARRAY, - .tlv_type = 0x02, - .offset = offsetof(struct servreg_set_ack_req, - transaction_id), - }, - {} -}; - struct servreg_set_ack_resp { struct qmi_response_type_v01 resp; }; -static const struct qmi_elem_info servreg_set_ack_resp_ei[] = { - { - .data_type = QMI_STRUCT, - .elem_len = 1, - .elem_size = sizeof(struct qmi_response_type_v01), - .array_type = NO_ARRAY, - .tlv_type = 0x02, - .offset = offsetof(struct servreg_set_ack_resp, - resp), - .ei_array = qmi_response_type_v01_ei, - }, - {} -}; +extern const struct qmi_elem_info servreg_location_entry_ei[]; +extern const struct qmi_elem_info servreg_get_domain_list_req_ei[]; +extern const struct qmi_elem_info servreg_get_domain_list_resp_ei[]; +extern const struct qmi_elem_info servreg_register_listener_req_ei[]; +extern const struct qmi_elem_info servreg_register_listener_resp_ei[]; +extern const struct qmi_elem_info servreg_restart_pd_req_ei[]; +extern const struct qmi_elem_info servreg_restart_pd_resp_ei[]; +extern const struct qmi_elem_info servreg_state_updated_ind_ei[]; +extern const struct qmi_elem_info servreg_set_ack_req_ei[]; +extern const struct qmi_elem_info servreg_set_ack_resp_ei[]; #endif diff --git a/drivers/soc/qcom/qcom_pdr_msg.c b/drivers/soc/qcom/qcom_pdr_msg.c new file mode 100644 index 000000000000..a8867e8b1319 --- /dev/null +++ b/drivers/soc/qcom/qcom_pdr_msg.c @@ -0,0 +1,315 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 The Linux Foundation. All rights reserved. + */ + +#include + +#include "pdr_internal.h" + +const struct qmi_elem_info servreg_location_entry_ei[] = { + { + .data_type = QMI_STRING, + .elem_len = SERVREG_NAME_LENGTH + 1, + .elem_size = sizeof(char), + .array_type = NO_ARRAY, + .tlv_type = 0, + .offset = offsetof(struct servreg_location_entry, + name), + }, + { + .data_type = QMI_UNSIGNED_4_BYTE, + .elem_len = 1, + .elem_size = sizeof(u32), + .array_type = NO_ARRAY, + .tlv_type = 0, + .offset = offsetof(struct servreg_location_entry, + instance), + }, + { + .data_type = QMI_UNSIGNED_1_BYTE, + .elem_len = 1, + .elem_size = sizeof(u8), + .array_type = NO_ARRAY, + .tlv_type = 0, + .offset = offsetof(struct servreg_location_entry, + service_data_valid), + }, + { + .data_type = QMI_UNSIGNED_4_BYTE, + .elem_len = 1, + .elem_size = sizeof(u32), + .array_type = NO_ARRAY, + .tlv_type = 0, + .offset = offsetof(struct servreg_location_entry, + service_data), + }, + {} +}; +EXPORT_SYMBOL_GPL(servreg_location_entry_ei); + +const struct qmi_elem_info servreg_get_domain_list_req_ei[] = { + { + .data_type = QMI_STRING, + .elem_len = SERVREG_NAME_LENGTH + 1, + .elem_size = sizeof(char), + .array_type = NO_ARRAY, + .tlv_type = 0x01, + .offset = offsetof(struct servreg_get_domain_list_req, + service_name), + }, + { + .data_type = QMI_OPT_FLAG, + .elem_len = 1, + .elem_size = sizeof(u8), + .array_type = NO_ARRAY, + .tlv_type = 0x10, + .offset = offsetof(struct servreg_get_domain_list_req, + domain_offset_valid), + }, + { + .data_type = QMI_UNSIGNED_4_BYTE, + .elem_len = 1, + .elem_size = sizeof(u32), + .array_type = NO_ARRAY, + .tlv_type = 0x10, + .offset = offsetof(struct servreg_get_domain_list_req, + domain_offset), + }, + {} +}; +EXPORT_SYMBOL_GPL(servreg_get_domain_list_req_ei); + +const struct qmi_elem_info servreg_get_domain_list_resp_ei[] = { + { + .data_type = QMI_STRUCT, + .elem_len = 1, + .elem_size = sizeof(struct qmi_response_type_v01), + .array_type = NO_ARRAY, + .tlv_type = 0x02, + .offset = offsetof(struct servreg_get_domain_list_resp, + resp), + .ei_array = qmi_response_type_v01_ei, + }, + { + .data_type = QMI_OPT_FLAG, + .elem_len = 1, + .elem_size = sizeof(u8), + .array_type = NO_ARRAY, + .tlv_type = 0x10, + .offset = offsetof(struct servreg_get_domain_list_resp, + total_domains_valid), + }, + { + .data_type = QMI_UNSIGNED_2_BYTE, + .elem_len = 1, + .elem_size = sizeof(u16), + .array_type = NO_ARRAY, + .tlv_type = 0x10, + .offset = offsetof(struct servreg_get_domain_list_resp, + total_domains), + }, + { + .data_type = QMI_OPT_FLAG, + .elem_len = 1, + .elem_size = sizeof(u8), + .array_type = NO_ARRAY, + .tlv_type = 0x11, + .offset = offsetof(struct servreg_get_domain_list_resp, + db_rev_count_valid), + }, + { + .data_type = QMI_UNSIGNED_2_BYTE, + .elem_len = 1, + .elem_size = sizeof(u16), + .array_type = NO_ARRAY, + .tlv_type = 0x11, + .offset = offsetof(struct servreg_get_domain_list_resp, + db_rev_count), + }, + { + .data_type = QMI_OPT_FLAG, + .elem_len = 1, + .elem_size = sizeof(u8), + .array_type = NO_ARRAY, + .tlv_type = 0x12, + .offset = offsetof(struct servreg_get_domain_list_resp, + domain_list_valid), + }, + { + .data_type = QMI_DATA_LEN, + .elem_len = 1, + .elem_size = sizeof(u8), + .array_type = NO_ARRAY, + .tlv_type = 0x12, + .offset = offsetof(struct servreg_get_domain_list_resp, + domain_list_len), + }, + { + .data_type = QMI_STRUCT, + .elem_len = SERVREG_DOMAIN_LIST_LENGTH, + .elem_size = sizeof(struct servreg_location_entry), + .array_type = VAR_LEN_ARRAY, + .tlv_type = 0x12, + .offset = offsetof(struct servreg_get_domain_list_resp, + domain_list), + .ei_array = servreg_location_entry_ei, + }, + {} +}; +EXPORT_SYMBOL_GPL(servreg_get_domain_list_resp_ei); + +const struct qmi_elem_info servreg_register_listener_req_ei[] = { + { + .data_type = QMI_UNSIGNED_1_BYTE, + .elem_len = 1, + .elem_size = sizeof(u8), + .array_type = NO_ARRAY, + .tlv_type = 0x01, + .offset = offsetof(struct servreg_register_listener_req, + enable), + }, + { + .data_type = QMI_STRING, + .elem_len = SERVREG_NAME_LENGTH + 1, + .elem_size = sizeof(char), + .array_type = NO_ARRAY, + .tlv_type = 0x02, + .offset = offsetof(struct servreg_register_listener_req, + service_path), + }, + {} +}; +EXPORT_SYMBOL_GPL(servreg_register_listener_req_ei); + +const struct qmi_elem_info servreg_register_listener_resp_ei[] = { + { + .data_type = QMI_STRUCT, + .elem_len = 1, + .elem_size = sizeof(struct qmi_response_type_v01), + .array_type = NO_ARRAY, + .tlv_type = 0x02, + .offset = offsetof(struct servreg_register_listener_resp, + resp), + .ei_array = qmi_response_type_v01_ei, + }, + { + .data_type = QMI_OPT_FLAG, + .elem_len = 1, + .elem_size = sizeof(u8), + .array_type = NO_ARRAY, + .tlv_type = 0x10, + .offset = offsetof(struct servreg_register_listener_resp, + curr_state_valid), + }, + { + .data_type = QMI_SIGNED_4_BYTE_ENUM, + .elem_len = 1, + .elem_size = sizeof(enum servreg_service_state), + .array_type = NO_ARRAY, + .tlv_type = 0x10, + .offset = offsetof(struct servreg_register_listener_resp, + curr_state), + }, + {} +}; +EXPORT_SYMBOL_GPL(servreg_register_listener_resp_ei); + +const struct qmi_elem_info servreg_restart_pd_req_ei[] = { + { + .data_type = QMI_STRING, + .elem_len = SERVREG_NAME_LENGTH + 1, + .elem_size = sizeof(char), + .array_type = NO_ARRAY, + .tlv_type = 0x01, + .offset = offsetof(struct servreg_restart_pd_req, + service_path), + }, + {} +}; +EXPORT_SYMBOL_GPL(servreg_restart_pd_req_ei); + +const struct qmi_elem_info servreg_restart_pd_resp_ei[] = { + { + .data_type = QMI_STRUCT, + .elem_len = 1, + .elem_size = sizeof(struct qmi_response_type_v01), + .array_type = NO_ARRAY, + .tlv_type = 0x02, + .offset = offsetof(struct servreg_restart_pd_resp, + resp), + .ei_array = qmi_response_type_v01_ei, + }, + {} +}; +EXPORT_SYMBOL_GPL(servreg_restart_pd_resp_ei); + +const struct qmi_elem_info servreg_state_updated_ind_ei[] = { + { + .data_type = QMI_SIGNED_4_BYTE_ENUM, + .elem_len = 1, + .elem_size = sizeof(u32), + .array_type = NO_ARRAY, + .tlv_type = 0x01, + .offset = offsetof(struct servreg_state_updated_ind, + curr_state), + }, + { + .data_type = QMI_STRING, + .elem_len = SERVREG_NAME_LENGTH + 1, + .elem_size = sizeof(char), + .array_type = NO_ARRAY, + .tlv_type = 0x02, + .offset = offsetof(struct servreg_state_updated_ind, + service_path), + }, + { + .data_type = QMI_UNSIGNED_2_BYTE, + .elem_len = 1, + .elem_size = sizeof(u16), + .array_type = NO_ARRAY, + .tlv_type = 0x03, + .offset = offsetof(struct servreg_state_updated_ind, + transaction_id), + }, + {} +}; +EXPORT_SYMBOL_GPL(servreg_state_updated_ind_ei); + +const struct qmi_elem_info servreg_set_ack_req_ei[] = { + { + .data_type = QMI_STRING, + .elem_len = SERVREG_NAME_LENGTH + 1, + .elem_size = sizeof(char), + .array_type = NO_ARRAY, + .tlv_type = 0x01, + .offset = offsetof(struct servreg_set_ack_req, + service_path), + }, + { + .data_type = QMI_UNSIGNED_2_BYTE, + .elem_len = 1, + .elem_size = sizeof(u16), + .array_type = NO_ARRAY, + .tlv_type = 0x02, + .offset = offsetof(struct servreg_set_ack_req, + transaction_id), + }, + {} +}; +EXPORT_SYMBOL_GPL(servreg_set_ack_req_ei); + +const struct qmi_elem_info servreg_set_ack_resp_ei[] = { + { + .data_type = QMI_STRUCT, + .elem_len = 1, + .elem_size = sizeof(struct qmi_response_type_v01), + .array_type = NO_ARRAY, + .tlv_type = 0x02, + .offset = offsetof(struct servreg_set_ack_resp, + resp), + .ei_array = qmi_response_type_v01_ei, + }, + {} +}; +EXPORT_SYMBOL_GPL(servreg_set_ack_resp_ei); From patchwork Fri Apr 19 14:00:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 790737 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.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 7646212CDBF for ; Fri, 19 Apr 2024 14:00:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713535247; cv=none; b=sL18VpIkVuiLh3/uJwsbUkvNd0YTAI0hUS6aNXp6QXJmbbZiDW5PhO5NaBm3fcjdqnybgf/xi2FYvpC8jQ06vSOPPrMfuxc4RluQ22hfBVQfnHHQF+8owDMdiYyCj+wAuAei71kXFzTalcsQU/kToNc8MrkqfL9kFZMZkrcwl7w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713535247; c=relaxed/simple; bh=fvMToiiNdTZTq3/y+FkrPuwl0NqwcqEAFZtgK2uk0Fw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YMt2fSxVcRVm/o40XC3HdGxUhYzpSEy6xd9yTy8/JTRGfL+DomXx5oErRFIXknBYNsO8BNaZaS6Mvy3F8RYkHY8dLUbN8LoFNgXXZJlKjNfoli53psjPXAS+k5dwm0Qt2UCRWXqwskloxE3GY05kw2bb1xS27lQURtRLORyZb4M= 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=WDJ0HhW4; arc=none smtp.client-ip=209.85.218.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="WDJ0HhW4" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a44f2d894b7so201194866b.1 for ; Fri, 19 Apr 2024 07:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713535243; x=1714140043; 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=WKIDfr5zIf6Ah4i9hZjm4f94DXkgUa1CksRrZAM9u2Y=; b=WDJ0HhW4rdTZ+v5amiMrmTNWl8qSQe8XJWuqKdSpKTQQARI+M3WPO/OoNIsWsac9/o UAH6/1zTzaPlctSzB67hFDOfbcgUJR8NmL0v1Hl/wdKV9JQYLMSDVdDyl/9ZSkXrNDfm 5FG1IUuiQ0/8jzOnM5JZdICL7rl6yfLGGuI5oF6SCQkIqtSdpo/u+6b8lOqELxzrG3/w +iIUJIfU/kQ0e7U7dtjTVrlPiJeYQBBcqtLaY95xA8OYttEeyljI3rMYDkxdw7tyqRln EiFBMX/h58v6yA5IpkozATP8nYhlpm6rhxtqri9DqSce4nxV8ej9LinfalTK6u7H8y86 1URQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713535243; x=1714140043; 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=WKIDfr5zIf6Ah4i9hZjm4f94DXkgUa1CksRrZAM9u2Y=; b=gbrP/5+/4Fej7BA78toPD7Q9DzmoUIOvmQ/mJRjbAKaVq9BDr896SQ8q+zycKEOY5D Z+OKIGoEZeZUWtKRFajEH9rdYM9mbgf7HddxMbqYdjI1AIL64Rx5JNXrgox7w47Rd4js eYKHHIXL32mI5x8LU1wPOIdmhZbnlJDB35UQokZCvq0cNM55SYRbRpC+qSr3CxwoKNq+ KxWB4n8vuF39518263KkzNKjFDor24J8ogd7J47yNec8SlCoMd+TeGXH9E0OOfewjlLW gA8/0HoEW71tvq6tKFvpNSLi3pe1W456hDsOVhiyXf1dDamKZc/CKD0txG0ZlDsH+zyZ qT/Q== X-Gm-Message-State: AOJu0YwPcRy0mRzUvwhBmdbPb5W6FssIdPEG27eMGX32Bb+qqDfNPtqN 035fAc71AipmCEyQNjG2MjCacMIEziXUrmxwBgw5vabyPWXZjWmX9vf+TGhlO7H4mJewQhbGYqU R X-Google-Smtp-Source: AGHT+IEVjc8u/6CMXCh18nlEV2IsAlwDSWNsebqrey3ZuyUIfGppuT2uwNQtKyyywCatA0iGfyjYig== X-Received: by 2002:a17:906:300a:b0:a52:30d3:41dd with SMTP id 10-20020a170906300a00b00a5230d341ddmr1780096ejz.41.1713535243514; Fri, 19 Apr 2024 07:00:43 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id qy1-20020a170907688100b00a558be8bc03sm532390ejc.150.2024.04.19.07.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 07:00:43 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 19 Apr 2024 17:00:32 +0300 Subject: [PATCH v5 4/6] soc: qcom: qmi: add a way to remove running service Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240419-qcom-pd-mapper-v5-4-e35b6f847e99@linaro.org> References: <20240419-qcom-pd-mapper-v5-0-e35b6f847e99@linaro.org> In-Reply-To: <20240419-qcom-pd-mapper-v5-0-e35b6f847e99@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Mathieu Poirier , Sibi Sankar Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, Johan Hovold , Xilin Wu , Neil Armstrong X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3574; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=fvMToiiNdTZTq3/y+FkrPuwl0NqwcqEAFZtgK2uk0Fw=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmInkFJ52tJrxGxLCfkxdChR+qIeim1zAqR8x7M Abc0mo0VYWJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZiJ5BQAKCRCLPIo+Aiko 1dEkB/4onCYk6FRNy5bu8tLnMbjVnpIUvtSEIGwHXUDlO3vByHQlmrCtgUXaFDIaCCjJpEjGoo5 CqgD8qzyryAptkBR1D771qV26n7RsxqpvtXujYLslQ2gXeFIizyteTrD7IvSTkSG6wo3WpkaOXN 0M8HfjRBpaFtNFJKm57ElGwrzWJmAouWC42yd/CZ8IvMbS90P5jYLUeZwSIMxcpGMqwiisU4WIl hDVR7OihbXw+XBxl6HURZWKBXlLCKStc8GXtA1tJHTHgvgw9sNetYUqgHziK9UVkozufre+Xk81 DO08H96Yuf/0s762bmTXQ5unZjE4FUoZ5SnB7c9bKoWB3JmB X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Add qmi_del_server(), a pair to qmi_add_server(), a way to remove running server from the QMI socket. This is e.g. necessary for pd-mapper, which needs to readd a server each time the DSP is started or stopped. Tested-by: Neil Armstrong # on SM8550-QRD Signed-off-by: Dmitry Baryshkov --- drivers/soc/qcom/qmi_interface.c | 67 ++++++++++++++++++++++++++++++++++++++++ include/linux/soc/qcom/qmi.h | 2 ++ 2 files changed, 69 insertions(+) diff --git a/drivers/soc/qcom/qmi_interface.c b/drivers/soc/qcom/qmi_interface.c index bb98b06e87f8..18ff2015c682 100644 --- a/drivers/soc/qcom/qmi_interface.c +++ b/drivers/soc/qcom/qmi_interface.c @@ -289,6 +289,73 @@ int qmi_add_server(struct qmi_handle *qmi, unsigned int service, } EXPORT_SYMBOL_GPL(qmi_add_server); +static void qmi_send_del_server(struct qmi_handle *qmi, struct qmi_service *svc) +{ + struct qrtr_ctrl_pkt pkt; + struct sockaddr_qrtr sq; + struct msghdr msg = { }; + struct kvec iv = { &pkt, sizeof(pkt) }; + int ret; + + memset(&pkt, 0, sizeof(pkt)); + pkt.cmd = cpu_to_le32(QRTR_TYPE_DEL_SERVER); + pkt.server.service = cpu_to_le32(svc->service); + pkt.server.instance = cpu_to_le32(svc->version | svc->instance << 8); + pkt.server.node = cpu_to_le32(qmi->sq.sq_node); + pkt.server.port = cpu_to_le32(qmi->sq.sq_port); + + sq.sq_family = qmi->sq.sq_family; + sq.sq_node = qmi->sq.sq_node; + sq.sq_port = QRTR_PORT_CTRL; + + msg.msg_name = &sq; + msg.msg_namelen = sizeof(sq); + + mutex_lock(&qmi->sock_lock); + if (qmi->sock) { + ret = kernel_sendmsg(qmi->sock, &msg, &iv, 1, sizeof(pkt)); + if (ret < 0) + pr_err("send service deregistration failed: %d\n", ret); + } + mutex_unlock(&qmi->sock_lock); +} + +/** + * qmi_del_server() - register a service with the name service + * @qmi: qmi handle + * @service: type of the service + * @instance: instance of the service + * @version: version of the service + * + * Remove registration of the service with the name service. This notifies + * clients that they should no longer send messages to the client associated + * with @qmi. + * + * Return: 0 on success, negative errno on failure. + */ +int qmi_del_server(struct qmi_handle *qmi, unsigned int service, + unsigned int version, unsigned int instance) +{ + struct qmi_service *svc; + struct qmi_service *tmp; + + list_for_each_entry_safe(svc, tmp, &qmi->services, list_node) { + if (svc->service != service || + svc->version != version || + svc->instance != instance) + continue; + + qmi_send_del_server(qmi, svc); + list_del(&svc->list_node); + kfree(svc); + + return 0; + } + + return -EINVAL; +} +EXPORT_SYMBOL_GPL(qmi_del_server); + /** * qmi_txn_init() - allocate transaction id within the given QMI handle * @qmi: QMI handle diff --git a/include/linux/soc/qcom/qmi.h b/include/linux/soc/qcom/qmi.h index 469e02d2aa0d..5039c30e4bdc 100644 --- a/include/linux/soc/qcom/qmi.h +++ b/include/linux/soc/qcom/qmi.h @@ -241,6 +241,8 @@ int qmi_add_lookup(struct qmi_handle *qmi, unsigned int service, unsigned int version, unsigned int instance); int qmi_add_server(struct qmi_handle *qmi, unsigned int service, unsigned int version, unsigned int instance); +int qmi_del_server(struct qmi_handle *qmi, unsigned int service, + unsigned int version, unsigned int instance); int qmi_handle_init(struct qmi_handle *qmi, size_t max_msg_len, const struct qmi_ops *ops, From patchwork Fri Apr 19 14:00:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 790289 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (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 6A77C12D759 for ; Fri, 19 Apr 2024 14:00:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713535249; cv=none; b=jnKopvHnFue97ldfLzznqc+s9rDSsx5T/Oih4XRpf7MkryxN5if4frj1w7lt5FbbbSE6Ze+BLlaTzyfhaviwYkTC8UVpg+HvHN4+rWhZJc3NvKsb3dIASxqyQjWWK9m0GwyGRsy/wDtygFRkYyJHpSdtjSHIBjZw25TLCJCxJuI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713535249; c=relaxed/simple; bh=AYpzW+XVGpoMsYeJyRC3Fkd188sgOyxi1P7G4aDH0R4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rlZMJHwWFg8Skp7z9vN2PnkT96sFuidQFylLS9ALo9RJoRe7bqU0bzYBaLsK/FJWdC+0/BCuBazwKbOXYwXqVm5Lmh0l0ZZ/5jJdtPN5+fbcY/Mb/dPP8DZxM1EDy16qNjuNHtpXxbcdes9ePxu2Cam5kO4mLxjSysacsbWDfN8= 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=O9dfaM++; arc=none smtp.client-ip=209.85.218.42 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="O9dfaM++" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a519e1b0e2dso227227366b.2 for ; Fri, 19 Apr 2024 07:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713535244; x=1714140044; 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=lISmXDIryp/LfDcYeFb/+T7GoinbLodgM7sZVPRHDnU=; b=O9dfaM++rJIpnzYddpPFyNBSqc0R1cY+g8xJQ/y6eIgYWqQW/aOcxmxgQaF9X8JTWk r3UncamdFM6O4avsTOPB/+iA8Tt6RrnDA3Zc5Nbxhz3q3Wh+lJOPoEYLMCDw2KrAnaDT UlAznTdDAu90niwCxBNtsldDLd5EVAXX+INeLs0hxEB9L4hpS5RbZoyI7vTCLbDew6ZS drDUewsIYASmlxdOo/JETZGx91idQ9zGLtqufwbmVtGJRyACjDK9nbHVcMVYvkvf4laU JUI5uzwdkRrszv/8cKSvZSuhrB4uHZtquw6PJ5tFc2OzmXlIvJqvEGQef9uAdKL9Msfx i1bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713535244; x=1714140044; 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=lISmXDIryp/LfDcYeFb/+T7GoinbLodgM7sZVPRHDnU=; b=wwZ7tYUYLihsrHVw1ELdDRXggPHGzrbPteDTiHbSAUJTXVcC4JnHDjpWmWNy38DUZb KkAH3IYQCo0Brb+Fsipy5aGFaAtdQSXJ+h0yZWQq8FlNGQyGKr9QPAlhIwx3GaUS9om+ BuMW8vxhwOP72AvUgkaR/Y7jfDFj319y7fP3wVkW0TSTx9BBwWdIkpUnNEMyMZ5TuPgX LvyyAM9Cs3WiySIeaepLg3bqznXBi6GFfa/pYu4JgqeCDUDSNJ6Br98tI+1cnmW4FSEv WQvITUT7tGq4X5iynZGbNXaUGrT3pm/L8PUo1Ky1mYlmUl94byI0BwZuaGDRqEHFrgX5 sIqA== X-Gm-Message-State: AOJu0YyExmvFBj09UROKDuFE9eFtEjvvzmsY6zTr6lNEkMCtB5/w2rIo WWcT3QJarcifPFRr0HuwlVYi5Ip/cBuVP4mj4OiN99DdGF5DIs+LUOP+Qm9AlUS3xDrAqyWBO6v R X-Google-Smtp-Source: AGHT+IHoxn/jrySb7xWl7r3eIak2FdVGU6m9BnFXxBoxY+PhGELomWq7T2jpVcC1khilBKow9sME5g== X-Received: by 2002:a17:906:23e1:b0:a46:da57:6ee4 with SMTP id j1-20020a17090623e100b00a46da576ee4mr1657224ejg.73.1713535244475; Fri, 19 Apr 2024 07:00:44 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id qy1-20020a170907688100b00a558be8bc03sm532390ejc.150.2024.04.19.07.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 07:00:44 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 19 Apr 2024 17:00:33 +0300 Subject: [PATCH v5 5/6] soc: qcom: add pd-mapper implementation Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240419-qcom-pd-mapper-v5-5-e35b6f847e99@linaro.org> References: <20240419-qcom-pd-mapper-v5-0-e35b6f847e99@linaro.org> In-Reply-To: <20240419-qcom-pd-mapper-v5-0-e35b6f847e99@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Mathieu Poirier , Sibi Sankar Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, Johan Hovold , Xilin Wu X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=21257; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=AYpzW+XVGpoMsYeJyRC3Fkd188sgOyxi1P7G4aDH0R4=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmInkFZROG5hm32EVOvieLOfD+yK8+spcx7xGb1 2ookYo6Q7iJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZiJ5BQAKCRCLPIo+Aiko 1QilB/9WTgXeuzm+AUaSOHKoaxanBo5CeRf4rrxee0/75p/ief3O29KHQALZTORhvK2fyldR959 Oxm05QgC+aANtAK8IfC9G5niHmx9nVzgfFfwtupi8hxg8La+gNHiO3Rkto5MrcomuWAcaFW5bLc 9nnq4ix1n+xPgTRpN5A/WBvn0ItXQJByqp6qrRHsWN0Hk/BgXHd4/mj8lVtdbSzvDL257AajbeP qBtKRy2FOWS0FF2ZGtEMmz8AaWhiLYZMtlw0CvdnqHVerI6BhvU5aq6+x3kuyzcb+np2lqBfPLa YpqRnIrQFoWOHXtkxWwVz791JVTHV0l/dD9IYzor932PcaQC X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Existing userspace protection domain mapper implementation has several issue. It doesn't play well with CONFIG_EXTRA_FIRMWARE, it doesn't reread JSON files if firmware location is changed (or if firmware was not available at the time pd-mapper was started but the corresponding directory is mounted later), etc. Provide in-kernel service implementing protection domain mapping required to work with several services, which are provided by the DSP firmware. Signed-off-by: Dmitry Baryshkov --- drivers/soc/qcom/Kconfig | 11 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/pdr_internal.h | 14 + drivers/soc/qcom/qcom_pd_mapper.c | 632 +++++++++++++++++++++++++++++++++++++ drivers/soc/qcom/qcom_pdr_msg.c | 34 ++ include/linux/soc/qcom/pd_mapper.h | 28 ++ 6 files changed, 720 insertions(+) diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index 95973c6b828f..0a2f2bfd7863 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -72,6 +72,17 @@ config QCOM_OCMEM requirements. This is typically used by the GPU, camera/video, and audio components on some Snapdragon SoCs. +config QCOM_PD_MAPPER + tristate "Qualcomm Protection Domain Mapper" + select QCOM_QMI_HELPERS + depends on NET && QRTR + default QCOM_RPROC_COMMON + help + The Protection Domain Mapper maps registered services to the domains + and instances handled by the remote DSPs. This is a kernel-space + implementation of the service. It is a simpler alternative to the + userspace daemon. + config QCOM_PDR_HELPERS tristate select QCOM_QMI_HELPERS diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index 3110ac3288bc..d3560f861085 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_QCOM_COMMAND_DB) += cmd-db.o obj-$(CONFIG_QCOM_GSBI) += qcom_gsbi.o obj-$(CONFIG_QCOM_MDT_LOADER) += mdt_loader.o obj-$(CONFIG_QCOM_OCMEM) += ocmem.o +obj-$(CONFIG_QCOM_PD_MAPPER) += qcom_pd_mapper.o obj-$(CONFIG_QCOM_PDR_HELPERS) += pdr_interface.o obj-$(CONFIG_QCOM_PDR_MSG) += qcom_pdr_msg.o obj-$(CONFIG_QCOM_PMIC_GLINK) += pmic_glink.o diff --git a/drivers/soc/qcom/pdr_internal.h b/drivers/soc/qcom/pdr_internal.h index 7e5bb5a95275..8d17f7fb79e7 100644 --- a/drivers/soc/qcom/pdr_internal.h +++ b/drivers/soc/qcom/pdr_internal.h @@ -13,6 +13,8 @@ #define SERVREG_SET_ACK_REQ 0x23 #define SERVREG_RESTART_PD_REQ 0x24 +#define SERVREG_LOC_PFR_REQ 0x24 + #define SERVREG_DOMAIN_LIST_LENGTH 32 #define SERVREG_RESTART_PD_REQ_MAX_LEN 67 #define SERVREG_REGISTER_LISTENER_REQ_LEN 71 @@ -20,6 +22,7 @@ #define SERVREG_GET_DOMAIN_LIST_REQ_MAX_LEN 74 #define SERVREG_STATE_UPDATED_IND_MAX_LEN 79 #define SERVREG_GET_DOMAIN_LIST_RESP_MAX_LEN 2389 +#define SERVREG_LOC_PFR_RESP_MAX_LEN 10 struct servreg_location_entry { char name[SERVREG_NAME_LENGTH + 1]; @@ -79,6 +82,15 @@ struct servreg_set_ack_resp { struct qmi_response_type_v01 resp; }; +struct servreg_loc_pfr_req { + char service[SERVREG_NAME_LENGTH + 1]; + char reason[257]; +}; + +struct servreg_loc_pfr_resp { + struct qmi_response_type_v01 rsp; +}; + extern const struct qmi_elem_info servreg_location_entry_ei[]; extern const struct qmi_elem_info servreg_get_domain_list_req_ei[]; extern const struct qmi_elem_info servreg_get_domain_list_resp_ei[]; @@ -89,5 +101,7 @@ extern const struct qmi_elem_info servreg_restart_pd_resp_ei[]; extern const struct qmi_elem_info servreg_state_updated_ind_ei[]; extern const struct qmi_elem_info servreg_set_ack_req_ei[]; extern const struct qmi_elem_info servreg_set_ack_resp_ei[]; +extern const struct qmi_elem_info servreg_loc_pfr_req_ei[]; +extern const struct qmi_elem_info servreg_loc_pfr_resp_ei[]; #endif diff --git a/drivers/soc/qcom/qcom_pd_mapper.c b/drivers/soc/qcom/qcom_pd_mapper.c new file mode 100644 index 000000000000..b2a8b1f41964 --- /dev/null +++ b/drivers/soc/qcom/qcom_pd_mapper.c @@ -0,0 +1,632 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Qualcomm Protection Domain mapper + * + * Copyright (c) 2023 Linaro Ltd. + */ + +#include +#include +#include +#include +#include +#include + +#include "pdr_internal.h" + +#define SERVREG_QMI_VERSION 0x101 +#define SERVREG_QMI_INSTANCE 0 + +#define TMS_SERVREG_SERVICE "tms/servreg" + +struct qcom_pdm_domain_data { + const char *domain; + u32 instance_id; + /* NULL-terminated array */ + const char * services[]; +}; + +struct qcom_pdm_domain { + struct list_head list; + const char *name; + u32 instance_id; +}; + +struct qcom_pdm_service { + struct list_head list; + struct list_head domains; + const char *name; +}; + +static DEFINE_MUTEX(qcom_pdm_mutex); +static LIST_HEAD(qcom_pdm_services); +static int qcom_pdm_count; +static struct qmi_handle qcom_pdm_handle; + +static struct qcom_pdm_service *qcom_pdm_find(const char *name) +{ + struct qcom_pdm_service *service; + + list_for_each_entry(service, &qcom_pdm_services, list) { + if (!strcmp(service->name, name)) + return service; + } + + return NULL; +} + +static int qcom_pdm_add_service_domain(const char *service_name, + const char *domain_name, + u32 instance_id) +{ + struct qcom_pdm_service *service; + struct qcom_pdm_domain *domain; + + service = qcom_pdm_find(service_name); + if (service) { + list_for_each_entry(domain, &service->domains, list) { + if (!strcmp(domain->name, domain_name)) + return -EBUSY; + } + } else { + service = kzalloc(sizeof(*service), GFP_KERNEL); + if (!service) + return -ENOMEM; + + INIT_LIST_HEAD(&service->domains); + service->name = service_name; + + list_add_tail(&service->list, &qcom_pdm_services); + } + + domain = kzalloc(sizeof(*domain), GFP_KERNEL); + if (!domain) { + if (list_empty(&service->domains)) { + list_del(&service->list); + kfree(service); + } + + return -ENOMEM; + } + + domain->name = domain_name; + domain->instance_id = instance_id; + list_add_tail(&domain->list, &service->domains); + + return 0; +} + +static int qcom_pdm_add_domain(const struct qcom_pdm_domain_data *data) +{ + int ret; + int i; + + ret = qcom_pdm_add_service_domain(TMS_SERVREG_SERVICE, + data->domain, + data->instance_id); + if (ret) + return ret; + + for (i = 0; data->services[i]; i++) { + ret = qcom_pdm_add_service_domain(data->services[i], + data->domain, + data->instance_id); + if (ret) + return ret; + } + + return 0; + +} + +static void qcom_pdm_free_domains(void) +{ + struct qcom_pdm_service *service, *tservice; + struct qcom_pdm_domain *domain, *tdomain; + + list_for_each_entry_safe(service, tservice, &qcom_pdm_services, list) { + list_for_each_entry_safe(domain, tdomain, &service->domains, list) { + list_del(&domain->list); + kfree(domain); + } + + list_del(&service->list); + kfree(service); + } +} + +static void qcom_pdm_get_domain_list(struct qmi_handle *qmi, + struct sockaddr_qrtr *sq, + struct qmi_txn *txn, + const void *decoded) +{ + const struct servreg_get_domain_list_req *req = decoded; + struct servreg_get_domain_list_resp *rsp = kzalloc(sizeof(*rsp), GFP_KERNEL); + struct qcom_pdm_service *service; + u32 offset; + int ret; + + offset = req->domain_offset_valid ? req->domain_offset : 0; + + rsp->resp.result = QMI_RESULT_SUCCESS_V01; + rsp->resp.error = QMI_ERR_NONE_V01; + + rsp->db_rev_count_valid = true; + rsp->db_rev_count = 1; + + rsp->total_domains_valid = true; + rsp->total_domains = 0; + + mutex_lock(&qcom_pdm_mutex); + + service = qcom_pdm_find(req->service_name); + if (service) { + struct qcom_pdm_domain *domain; + + rsp->domain_list_valid = true; + rsp->domain_list_len = 0; + + list_for_each_entry(domain, &service->domains, list) { + u32 i = rsp->total_domains++; + + if (i >= offset && i < SERVREG_DOMAIN_LIST_LENGTH) { + u32 j = rsp->domain_list_len++; + + strscpy(rsp->domain_list[j].name, domain->name, + sizeof(rsp->domain_list[i].name)); + rsp->domain_list[j].instance = domain->instance_id; + + pr_debug("PDM: found %s / %d\n", domain->name, + domain->instance_id); + } + } + } + + pr_debug("PDM: service '%s' offset %d returning %d domains (of %d)\n", req->service_name, + req->domain_offset_valid ? req->domain_offset : -1, rsp->domain_list_len, rsp->total_domains); + + ret = qmi_send_response(qmi, sq, txn, SERVREG_GET_DOMAIN_LIST_REQ, + SERVREG_GET_DOMAIN_LIST_RESP_MAX_LEN, + servreg_get_domain_list_resp_ei, rsp); + if (ret) + pr_err("Error sending servreg response: %d\n", ret); + + mutex_unlock(&qcom_pdm_mutex); + + kfree(rsp); +} + +static void qcom_pdm_pfr(struct qmi_handle *qmi, + struct sockaddr_qrtr *sq, + struct qmi_txn *txn, + const void *decoded) +{ + const struct servreg_loc_pfr_req *req = decoded; + struct servreg_loc_pfr_resp rsp = {}; + int ret; + + pr_warn_ratelimited("PDM: service '%s' crash: '%s'\n", req->service, req->reason); + + rsp.rsp.result = QMI_RESULT_SUCCESS_V01; + rsp.rsp.error = QMI_ERR_NONE_V01; + + ret = qmi_send_response(qmi, sq, txn, SERVREG_LOC_PFR_REQ, + SERVREG_LOC_PFR_RESP_MAX_LEN, + servreg_loc_pfr_resp_ei, &rsp); + if (ret) + pr_err("Error sending servreg response: %d\n", ret); +} + +static const struct qmi_msg_handler qcom_pdm_msg_handlers[] = { + { + .type = QMI_REQUEST, + .msg_id = SERVREG_GET_DOMAIN_LIST_REQ, + .ei = servreg_get_domain_list_req_ei, + .decoded_size = sizeof(struct servreg_get_domain_list_req), + .fn = qcom_pdm_get_domain_list, + }, + { + .type = QMI_REQUEST, + .msg_id = SERVREG_LOC_PFR_REQ, + .ei = servreg_loc_pfr_req_ei, + .decoded_size = sizeof(struct servreg_loc_pfr_req), + .fn = qcom_pdm_pfr, + }, + { }, +}; + +static const struct qcom_pdm_domain_data adsp_audio_pd = { + .domain = "msm/adsp/audio_pd", + .instance_id = 74, + .services = { + "avs/audio", + NULL, + }, +}; + +static const struct qcom_pdm_domain_data adsp_charger_pd = { + .domain = "msm/adsp/charger_pd", + .instance_id = 74, + .services = { NULL }, +}; + +static const struct qcom_pdm_domain_data adsp_root_pd = { + .domain = "msm/adsp/root_pd", + .instance_id = 74, + .services = { NULL }, +}; + +static const struct qcom_pdm_domain_data adsp_root_pd_pdr = { + .domain = "msm/adsp/root_pd", + .instance_id = 74, + .services = { + "tms/pdr_enabled", + NULL, + }, +}; + +static const struct qcom_pdm_domain_data adsp_sensor_pd = { + .domain = "msm/adsp/sensor_pd", + .instance_id = 74, + .services = { NULL }, +}; + +static const struct qcom_pdm_domain_data msm8996_adsp_audio_pd = { + .domain = "msm/adsp/audio_pd", + .instance_id = 4, + .services = { NULL }, +}; + +static const struct qcom_pdm_domain_data msm8996_adsp_root_pd = { + .domain = "msm/adsp/root_pd", + .instance_id = 4, + .services = { NULL }, +}; + +static const struct qcom_pdm_domain_data cdsp_root_pd = { + .domain = "msm/cdsp/root_pd", + .instance_id = 76, + .services = { NULL }, +}; + +static const struct qcom_pdm_domain_data slpi_root_pd = { + .domain = "msm/slpi/root_pd", + .instance_id = 90, + .services = { NULL }, +}; + +static const struct qcom_pdm_domain_data slpi_sensor_pd = { + .domain = "msm/slpi/sensor_pd", + .instance_id = 90, + .services = { NULL }, +}; + +static const struct qcom_pdm_domain_data mpss_root_pd = { + .domain = "msm/modem/root_pd", + .instance_id = 180, + .services = { + NULL, + }, +}; + +static const struct qcom_pdm_domain_data mpss_root_pd_gps = { + .domain = "msm/modem/root_pd", + .instance_id = 180, + .services = { + "gps/gps_service", + NULL, + }, +}; + +static const struct qcom_pdm_domain_data mpss_root_pd_gps_pdr = { + .domain = "msm/modem/root_pd", + .instance_id = 180, + .services = { + "gps/gps_service", + "tms/pdr_enabled", + NULL, + }, +}; + +static const struct qcom_pdm_domain_data msm8996_mpss_root_pd = { + .domain = "msm/modem/root_pd", + .instance_id = 100, + .services = { NULL }, +}; + +static const struct qcom_pdm_domain_data mpss_wlan_pd = { + .domain = "msm/modem/wlan_pd", + .instance_id = 180, + .services = { + "kernel/elf_loader", + "wlan/fw", + NULL, + }, +}; + +static const struct qcom_pdm_domain_data *msm8996_domains[] = { + &msm8996_adsp_audio_pd, + &msm8996_adsp_root_pd, + &msm8996_mpss_root_pd, + NULL, +}; + +static const struct qcom_pdm_domain_data *msm8998_domains[] = { + &mpss_root_pd, + &mpss_wlan_pd, + NULL, +}; + +static const struct qcom_pdm_domain_data *qcm2290_domains[] = { + &adsp_audio_pd, + &adsp_root_pd, + &adsp_sensor_pd, + &mpss_root_pd_gps, + &mpss_wlan_pd, + NULL, +}; + +static const struct qcom_pdm_domain_data *qcs404_domains[] = { + &adsp_audio_pd, + &adsp_root_pd, + &adsp_sensor_pd, + &cdsp_root_pd, + &mpss_root_pd, + &mpss_wlan_pd, + NULL, +}; + +static const struct qcom_pdm_domain_data *sc7180_domains[] = { + &adsp_audio_pd, + &adsp_root_pd_pdr, + &adsp_sensor_pd, + &mpss_root_pd_gps_pdr, + &mpss_wlan_pd, + NULL, +}; + +static const struct qcom_pdm_domain_data *sc7280_domains[] = { + &adsp_audio_pd, + &adsp_root_pd_pdr, + &adsp_charger_pd, + &adsp_sensor_pd, + &cdsp_root_pd, + &mpss_root_pd_gps_pdr, + NULL, +}; + +static const struct qcom_pdm_domain_data *sc8180x_domains[] = { + &adsp_audio_pd, + &adsp_root_pd, + &adsp_charger_pd, + &cdsp_root_pd, + &mpss_root_pd_gps, + &mpss_wlan_pd, + NULL, +}; + +static const struct qcom_pdm_domain_data *sc8280xp_domains[] = { + &adsp_audio_pd, + &adsp_root_pd_pdr, + &adsp_charger_pd, + &cdsp_root_pd, + NULL, +}; + +static const struct qcom_pdm_domain_data *sdm660_domains[] = { + &adsp_audio_pd, + &adsp_root_pd, + &mpss_wlan_pd, + NULL, +}; + +static const struct qcom_pdm_domain_data *sdm670_domains[] = { + &adsp_audio_pd, + &adsp_root_pd, + &cdsp_root_pd, + &mpss_root_pd, + &mpss_wlan_pd, + NULL, +}; + +static const struct qcom_pdm_domain_data *sdm845_domains[] = { + &adsp_audio_pd, + &adsp_root_pd, + &cdsp_root_pd, + &mpss_root_pd, + &mpss_wlan_pd, + &slpi_root_pd, + &slpi_sensor_pd, + NULL, +}; + +static const struct qcom_pdm_domain_data *sm6115_domains[] = { + &adsp_audio_pd, + &adsp_root_pd, + &adsp_sensor_pd, + &cdsp_root_pd, + &mpss_root_pd_gps, + &mpss_wlan_pd, + NULL, +}; + +static const struct qcom_pdm_domain_data *sm6350_domains[] = { + &adsp_audio_pd, + &adsp_root_pd, + &adsp_sensor_pd, + &cdsp_root_pd, + &mpss_wlan_pd, + NULL, +}; + +static const struct qcom_pdm_domain_data *sm8150_domains[] = { + &adsp_audio_pd, + &adsp_root_pd, + &cdsp_root_pd, + &mpss_root_pd_gps, + &mpss_wlan_pd, + NULL, +}; + +static const struct qcom_pdm_domain_data *sm8250_domains[] = { + &adsp_audio_pd, + &adsp_root_pd, + &cdsp_root_pd, + &slpi_root_pd, + &slpi_sensor_pd, + NULL, +}; + +static const struct qcom_pdm_domain_data *sm8350_domains[] = { + &adsp_audio_pd, + &adsp_root_pd_pdr, + &adsp_charger_pd, + &cdsp_root_pd, + &mpss_root_pd_gps, + &slpi_root_pd, + &slpi_sensor_pd, + NULL, +}; + +static const struct qcom_pdm_domain_data *sm8550_domains[] = { + &adsp_audio_pd, + &adsp_root_pd, + &adsp_charger_pd, + &adsp_sensor_pd, + &cdsp_root_pd, + &mpss_root_pd_gps, + NULL, +}; + +static const struct of_device_id qcom_pdm_domains[] = { + { .compatible = "qcom,apq8096", .data = msm8996_domains, }, + { .compatible = "qcom,msm8996", .data = msm8996_domains, }, + { .compatible = "qcom,msm8998", .data = msm8998_domains, }, + { .compatible = "qcom,qcm2290", .data = qcm2290_domains, }, + { .compatible = "qcom,qcs404", .data = qcs404_domains, }, + { .compatible = "qcom,sc7180", .data = sc7180_domains, }, + { .compatible = "qcom,sc7280", .data = sc7280_domains, }, + { .compatible = "qcom,sc8180x", .data = sc8180x_domains, }, + { .compatible = "qcom,sc8280xp", .data = sc8280xp_domains, }, + { .compatible = "qcom,sda660", .data = sdm660_domains, }, + { .compatible = "qcom,sdm660", .data = sdm660_domains, }, + { .compatible = "qcom,sdm670", .data = sdm670_domains, }, + { .compatible = "qcom,sdm845", .data = sdm845_domains, }, + { .compatible = "qcom,sm6115", .data = sm6115_domains, }, + { .compatible = "qcom,sm6350", .data = sm6350_domains, }, + { .compatible = "qcom,sm8150", .data = sm8150_domains, }, + { .compatible = "qcom,sm8250", .data = sm8250_domains, }, + { .compatible = "qcom,sm8350", .data = sm8350_domains, }, + { .compatible = "qcom,sm8450", .data = sm8350_domains, }, + { .compatible = "qcom,sm8550", .data = sm8550_domains, }, + { .compatible = "qcom,sm8650", .data = sm8550_domains, }, + {}, +}; + +static int qcom_pdm_start(void) +{ + const struct of_device_id *match; + const struct qcom_pdm_domain_data * const *domains; + struct device_node *root; + int ret, i; + + pr_debug("PDM: starting service\n"); + + root = of_find_node_by_path("/"); + if (!root) + return -ENODEV; + + match = of_match_node(qcom_pdm_domains, root); + of_node_put(root); + if (!match) { + pr_notice("PDM: no support for the platform, userspace daemon might be required.\n"); + return 0; + } + + domains = match->data; + if (!domains) { + pr_debug("PDM: no domains\n"); + return 0; + } + + for (i = 0; domains[i]; i++) { + ret = qcom_pdm_add_domain(domains[i]); + if (ret) + goto free_domains; + } + + ret = qmi_handle_init(&qcom_pdm_handle, 1024, + NULL, qcom_pdm_msg_handlers); + if (ret) + goto free_domains; + + ret = qmi_add_server(&qcom_pdm_handle, SERVREG_LOCATOR_SERVICE, + SERVREG_QMI_VERSION, SERVREG_QMI_INSTANCE); + if (ret) { + pr_err("PDM: error adding server %d\n", ret); + goto release_handle; + } + + return 0; + +release_handle: + qmi_handle_release(&qcom_pdm_handle); + +free_domains: + qcom_pdm_free_domains(); + + return ret; +} + +static void qcom_pdm_stop(void) +{ + qmi_del_server(&qcom_pdm_handle, SERVREG_LOCATOR_SERVICE, + SERVREG_QMI_VERSION, SERVREG_QMI_INSTANCE); + + qmi_handle_release(&qcom_pdm_handle); + + qcom_pdm_free_domains(); + + WARN_ON(!list_empty(&qcom_pdm_services)); + + pr_debug("PDM: stopped service\n"); +} + +/** + * qcom_pdm_get() - ensure that PD mapper is up and running + */ +int qcom_pdm_get(void) +{ + int ret = 0; + + mutex_lock(&qcom_pdm_mutex); + + if (!qcom_pdm_count) + ret = qcom_pdm_start(); + + if (!ret) + ++qcom_pdm_count; + + mutex_unlock(&qcom_pdm_mutex); + + return ret; +} + +/** + * qcom_pdm_release() - possibly stop PD mapper service + */ +void qcom_pdm_release(void) +{ + mutex_lock(&qcom_pdm_mutex); + + if (qcom_pdm_count == 1) + qcom_pdm_stop(); + + if (qcom_pdm_count >= 1) + --qcom_pdm_count; + + mutex_unlock(&qcom_pdm_mutex); +} + +MODULE_DESCRIPTION("Qualcomm Protection Domain Mapper"); +MODULE_LICENSE("GPL"); diff --git a/drivers/soc/qcom/qcom_pdr_msg.c b/drivers/soc/qcom/qcom_pdr_msg.c index a8867e8b1319..bdebbe929468 100644 --- a/drivers/soc/qcom/qcom_pdr_msg.c +++ b/drivers/soc/qcom/qcom_pdr_msg.c @@ -313,3 +313,37 @@ const struct qmi_elem_info servreg_set_ack_resp_ei[] = { {} }; EXPORT_SYMBOL_GPL(servreg_set_ack_resp_ei); + +const struct qmi_elem_info servreg_loc_pfr_req_ei[] = { + { + .data_type = QMI_STRING, + .elem_len = SERVREG_NAME_LENGTH + 1, + .elem_size = sizeof(char), + .array_type = VAR_LEN_ARRAY, + .tlv_type = 0x01, + .offset = offsetof(struct servreg_loc_pfr_req, service) + }, + { + .data_type = QMI_STRING, + .elem_len = SERVREG_NAME_LENGTH + 1, + .elem_size = sizeof(char), + .array_type = VAR_LEN_ARRAY, + .tlv_type = 0x02, + .offset = offsetof(struct servreg_loc_pfr_req, reason) + }, + {} +}; +EXPORT_SYMBOL_GPL(servreg_loc_pfr_req_ei); + +const struct qmi_elem_info servreg_loc_pfr_resp_ei[] = { + { + .data_type = QMI_STRUCT, + .elem_len = 1, + .elem_size = sizeof_field(struct servreg_loc_pfr_resp, rsp), + .tlv_type = 0x02, + .offset = offsetof(struct servreg_loc_pfr_resp, rsp), + .ei_array = qmi_response_type_v01_ei, + }, + {} +}; +EXPORT_SYMBOL_GPL(servreg_loc_pfr_resp_ei); diff --git a/include/linux/soc/qcom/pd_mapper.h b/include/linux/soc/qcom/pd_mapper.h new file mode 100644 index 000000000000..d0dd3dfc8fea --- /dev/null +++ b/include/linux/soc/qcom/pd_mapper.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Qualcomm Protection Domain mapper + * + * Copyright (c) 2023 Linaro Ltd. + */ +#ifndef __QCOM_PD_MAPPER__ +#define __QCOM_PD_MAPPER__ + +#if IS_ENABLED(CONFIG_QCOM_PD_MAPPER) + +int qcom_pdm_get(void); +void qcom_pdm_release(void); + +#else + +static inline int qcom_pdm_get(void) +{ + return 0; +} + +static inline void qcom_pdm_release(void) +{ +} + +#endif + +#endif From patchwork Fri Apr 19 14:00:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 790736 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 4EE0D12D210 for ; Fri, 19 Apr 2024 14:00:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713535249; cv=none; b=XAuVOiaCH5cMSOyhqgwJmyeL9tNPoi1rAOksRxy0hERM/V4Hg8gcR1HkuBOgQBLfJiNw3b7aIC4MDwcBoXdq6FXVdcdVo9+OCKHK4vd+T280pexwR11s4l/O+i+noXaPap6FVdG3rdgDnSIV9wKekbkXMC5Drc4dFZlgk7Os8wI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713535249; c=relaxed/simple; bh=T1QckubuuDLKzfbwGOe4bGJUpGxvHjLrV7SRAZt0Ryk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nG6aJBwkElYDKlMoecUpaCaOXfrG/VCzYtpo2rMYSfonGCzHg2NUDtMiThMNz84eVn61sIFYUFkjeXUestucrres2BRiV1UAqKqS3B91oNa0aeGycte5PLr56ySYUSukhVQzO4vja0LqiWxVquF8pgoxO6d/IEXEVu+/i7QqCMI= 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=nRgcUanc; arc=none smtp.client-ip=209.85.218.45 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="nRgcUanc" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a555faf94fcso228223366b.0 for ; Fri, 19 Apr 2024 07:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713535245; x=1714140045; 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=gXhJgQXYH8h9D6bhtZp9PtGZt8VvzcZTxKbXRO0AyF0=; b=nRgcUancxsRzL8aZBMeTvnOnJdFc80dx9MCul99fpdqksk7kfmWDuorx89E/rHmled QU5M9+F+tPXuDPah5iZpIKwkPnmSE5vJRJvet+VdwU9gle04E0iEIl5jpgc82m76/3i2 fTCCbfwLUXAewI423uaqyB8IzPGy/57ACOEdAHR7HDWzRzmGEN48rWGrhE7NYJghZjGZ 7tkE5dgfLxYGTt9dSajzvMY2NZ+Jh/REe+JTZ9ess43MPc+jPCywinR1ZKL0IS5JVQPY bBtP3Q6BYR7lZLZHtTuk8wPaKRgtTrsWqSWu2uvB9K4Uin+OK8t/ouBJr4HEZLSTY7Ky xOtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713535245; x=1714140045; 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=gXhJgQXYH8h9D6bhtZp9PtGZt8VvzcZTxKbXRO0AyF0=; b=srs+rCb1Acqp9afzcB8U0cgyj23eYUeg/fG8xZDYqLLsmvQeQOFSiYQe8WqPRCDZG5 ADihp+gm0RiD9FqXeV51VlhHWAhxBbwkdZ0GHZV6MPDzsznA8LjyGWa/U4ufpPjL3MvM QVYYe7jWK/oibbuA/WBGSS7hXNs96iuf3elhynf91Mc/mVBb4JSRuwKEV0mK+2W/0FdU +bOU1lqFqcyM2M1UrjmSH9W2aeFA2SrIbpQ7MNMKrLnVOEXo2HE9fwiUGgapEs0CcG04 0pLa2OaglLI3pQ7Ptx9odJ/up76Qhqn9L8S5R0dQ5dxKxsDuYo7aBeo//cvClWAgTMGl DnRQ== X-Gm-Message-State: AOJu0YwLPDIm8QLWLw+bEChQqqep2LouvLFo4YXdXHWeKGS011MWU0/T uJmElUdn1O97TzSzccFV80uaR26KNzLYhXxv1AVztolcpTFjzaEAjNWb8CUxcckSQEodO4jMSt7 S X-Google-Smtp-Source: AGHT+IEBpoVn+rPVd97VIc+PrP3OBopoivhgD3YF2bfDmBFYnmHtYascQVGb/3nL5y3x6owBGUrXaQ== X-Received: by 2002:a17:907:bb97:b0:a55:661d:8ab1 with SMTP id xo23-20020a170907bb9700b00a55661d8ab1mr1642070ejc.39.1713535245451; Fri, 19 Apr 2024 07:00:45 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id qy1-20020a170907688100b00a558be8bc03sm532390ejc.150.2024.04.19.07.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 07:00:45 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 19 Apr 2024 17:00:34 +0300 Subject: [PATCH v5 6/6] remoteproc: qcom: enable in-kernel PD mapper Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240419-qcom-pd-mapper-v5-6-e35b6f847e99@linaro.org> References: <20240419-qcom-pd-mapper-v5-0-e35b6f847e99@linaro.org> In-Reply-To: <20240419-qcom-pd-mapper-v5-0-e35b6f847e99@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Mathieu Poirier , Sibi Sankar Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, Johan Hovold , Xilin Wu X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5226; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=T1QckubuuDLKzfbwGOe4bGJUpGxvHjLrV7SRAZt0Ryk=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmInkFvvRIYipbRMqCm8lKYQre6oKb3JdARLkSs rzmPUpIJWqJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZiJ5BQAKCRCLPIo+Aiko 1QE9B/9zJAYrwFz0VOLx/mahAvqLRwFBNj/9Ul9sn6p5hNgyo6T8Pncyta2rnT2AV1DflqUHP6G l79AK9FMEYLh+8fgZZEsDHqMf+E61/sOXEHGkUK2y0azrGiziosIlti0ltzvjQ/C8H9B/ASH3dy /C4JojilWTnnVZdO/bokkqj/1odp6nJPVICqxS3L9ym7PNdUG3FpZqWnjcBU7WF+percXoop7XS 7xA7uObiCAWFOlRT5xd+L+qALa8lO4iv4ZFnf3l4xsb9pWc+R1ROiTaQ1pNj5eQIB2nkfkBxdvf 8KcpWfFUL6xCPpBZBDZOJQgS/+91rmzfLdaJigfNsuVAO76y X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Request in-kernel protection domain mapper to be started before starting Qualcomm DSP and release it once DSP is stopped. Once all DSPs are stopped, the PD mapper will be stopped too. Signed-off-by: Dmitry Baryshkov --- drivers/remoteproc/qcom_q6v5_adsp.c | 11 ++++++++++- drivers/remoteproc/qcom_q6v5_mss.c | 10 +++++++++- drivers/remoteproc/qcom_q6v5_pas.c | 12 +++++++++++- drivers/remoteproc/qcom_q6v5_wcss.c | 11 ++++++++++- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/drivers/remoteproc/qcom_q6v5_adsp.c b/drivers/remoteproc/qcom_q6v5_adsp.c index 1d24c9b656a8..02d0c626b03b 100644 --- a/drivers/remoteproc/qcom_q6v5_adsp.c +++ b/drivers/remoteproc/qcom_q6v5_adsp.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -375,10 +376,14 @@ static int adsp_start(struct rproc *rproc) int ret; unsigned int val; - ret = qcom_q6v5_prepare(&adsp->q6v5); + ret = qcom_pdm_get(); if (ret) return ret; + ret = qcom_q6v5_prepare(&adsp->q6v5); + if (ret) + goto put_pdm; + ret = adsp_map_carveout(rproc); if (ret) { dev_err(adsp->dev, "ADSP smmu mapping failed\n"); @@ -446,6 +451,8 @@ static int adsp_start(struct rproc *rproc) adsp_unmap_carveout(rproc); disable_irqs: qcom_q6v5_unprepare(&adsp->q6v5); +put_pdm: + qcom_pdm_release(); return ret; } @@ -478,6 +485,8 @@ static int adsp_stop(struct rproc *rproc) if (handover) qcom_adsp_pil_handover(&adsp->q6v5); + qcom_pdm_release(); + return ret; } diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index 1779fc890e10..791f11e7adbf 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -1581,10 +1582,14 @@ static int q6v5_start(struct rproc *rproc) int xfermemop_ret; int ret; - ret = q6v5_mba_load(qproc); + ret = qcom_pdm_get(); if (ret) return ret; + ret = q6v5_mba_load(qproc); + if (ret) + goto put_pdm; + dev_info(qproc->dev, "MBA booted with%s debug policy, loading mpss\n", qproc->dp_size ? "" : "out"); @@ -1613,6 +1618,8 @@ static int q6v5_start(struct rproc *rproc) reclaim_mpss: q6v5_mba_reclaim(qproc); q6v5_dump_mba_logs(qproc); +put_pdm: + qcom_pdm_release(); return ret; } @@ -1627,6 +1634,7 @@ static int q6v5_stop(struct rproc *rproc) dev_err(qproc->dev, "timed out on wait\n"); q6v5_mba_reclaim(qproc); + qcom_pdm_release(); return 0; } diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c index 54d8005d40a3..653e54f975fc 100644 --- a/drivers/remoteproc/qcom_q6v5_pas.c +++ b/drivers/remoteproc/qcom_q6v5_pas.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -261,10 +262,14 @@ static int adsp_start(struct rproc *rproc) struct qcom_adsp *adsp = rproc->priv; int ret; - ret = qcom_q6v5_prepare(&adsp->q6v5); + ret = qcom_pdm_get(); if (ret) return ret; + ret = qcom_q6v5_prepare(&adsp->q6v5); + if (ret) + goto put_pdm; + ret = adsp_pds_enable(adsp, adsp->proxy_pds, adsp->proxy_pd_count); if (ret < 0) goto disable_irqs; @@ -356,6 +361,9 @@ static int adsp_start(struct rproc *rproc) /* Remove pointer to the loaded firmware, only valid in adsp_load() & adsp_start() */ adsp->firmware = NULL; +put_pdm: + qcom_pdm_release(); + return ret; } @@ -399,6 +407,8 @@ static int adsp_stop(struct rproc *rproc) if (handover) qcom_pas_handover(&adsp->q6v5); + qcom_pdm_release(); + return ret; } diff --git a/drivers/remoteproc/qcom_q6v5_wcss.c b/drivers/remoteproc/qcom_q6v5_wcss.c index 94f68c919ee6..33bd30e07bf0 100644 --- a/drivers/remoteproc/qcom_q6v5_wcss.c +++ b/drivers/remoteproc/qcom_q6v5_wcss.c @@ -240,13 +240,17 @@ static int q6v5_wcss_start(struct rproc *rproc) struct q6v5_wcss *wcss = rproc->priv; int ret; + ret = qcom_pdm_get(); + if (ret) + return ret; + qcom_q6v5_prepare(&wcss->q6v5); /* Release Q6 and WCSS reset */ ret = reset_control_deassert(wcss->wcss_reset); if (ret) { dev_err(wcss->dev, "wcss_reset failed\n"); - return ret; + goto put_pdm; } ret = reset_control_deassert(wcss->wcss_q6_reset); @@ -288,6 +292,9 @@ static int q6v5_wcss_start(struct rproc *rproc) wcss_reset: reset_control_assert(wcss->wcss_reset); +put_pdm: + qcom_pdm_release(); + return ret; } @@ -735,6 +742,8 @@ static int q6v5_wcss_stop(struct rproc *rproc) qcom_q6v5_unprepare(&wcss->q6v5); + qcom_pdm_release(); + return 0; }