Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp814258lqb; Wed, 29 May 2024 11:13:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV4ZbtWQpYlMP/oZC92KjmdvrbH3vBG/MbrzQdPEY1u19XRi/9xi6oCLnC1q/KhzZxDkdfPxiLwdMR6k2mv4ziGRTlmgCvQLPcyuWCkvA== X-Google-Smtp-Source: AGHT+IFXRF9hL40vKG6yI3P6hVBOGMwpfqmvm+BU7wThEkRVi9LdybqQiJB+cZ8TA2kiA7qqFmmt X-Received: by 2002:a17:90b:4d89:b0:2c1:961c:790 with SMTP id 98e67ed59e1d1-2c1961c0873mr1499944a91.30.1717006398926; Wed, 29 May 2024 11:13:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717006398; cv=pass; d=google.com; s=arc-20160816; b=odORZbCVjghNoUpIOen0Q6fGLlAsPdEC76utmBHWAm43zQPNTXbY9EuyNk709XPR2q ODo6NHVNswlBVunQctgKggYatbvD2FnmbjFn5pFMTMmdd5jNsbJlv3Jhhc0iLKhqudCe rlKTfF3YRLEApYH07ngJwMBCSG4lT8Kx0C8rBexm82ibVve31XHpWtzMzC6W37hzLdZm weMXs34qIdEspJoHhDT9E5VJoFvzQEQd2BXTN/PSiSMV4mUtKoxxXZMc5XwLQ2eVuHRz izZHHhSzfMFh4tIBcQEWGqiup8hOLlCpqpwCLwoELSZqf6ZhP8LGhIYvCeRerakdEa3B H9cA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=B1bFvicHobFbigotDFpVBAah8hOJ3e+zH7AfuuLx4GE=; fh=oiRZx2zGXBzrwJyIRAOvi7r9CuPURKL5PNqMJCC8xR8=; b=y+432mDTVql7pAhN6YCNI1RrxWmC8/kvDbFcgZkTcmq+prycuNkD71mjldltOlqNto lAZ5wogKsybsmafToEy2q7DW40CAnz2t2333n0QyY8CDsbKQ11x7Q0HbqM+x9xHiJlRI 3gzQd1q5Ic+M/kqUE6PvPTSs/tG9qNKVfzkkyeZye8nvjsJsP+yjcDfRUXwO9eoAJS+v Byd5dPzWzCQSz1pBzLXwUoi+Rnz4r/lMNqsVZTd2yV1EE3H9mMs7slI0GHD2d3gviSF6 zy4B1337d7KUdT+Aot9pFeMy+Gh4kq705yybZ9L6si3xT+Iy3HsjASbeRWg7qcSD5EdH c2hQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Ub72SK2O; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-194556-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194556-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c1a77b6252si86814a91.121.2024.05.29.11.13.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 11:13:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194556-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Ub72SK2O; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-194556-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194556-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 1198BB23AD7 for ; Wed, 29 May 2024 18:10:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7471F1C230C; Wed, 29 May 2024 18:10:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="Ub72SK2O" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D37C15B57F; Wed, 29 May 2024 18:10:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717006220; cv=none; b=gR4Bk8pnziz+EYbGy+7rmlc4dUSSePlLACSr2dOVkDHzyHAAtmPpezHVo5yzMXpnwq4xu3WDeQU1yAOunxyttd2zjxVPT9H0HEWJkgxgcmaWR8sgdYDVakck1ynJ17hRvd0js6hR6Rn3z96EOF2HhlR+HAYMyc3WJrg/utZ4nTI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717006220; c=relaxed/simple; bh=mOSE2ntqu4Rot7ryHq21ynAVLd53KCm+8J+0kl8CtRg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=OKQIuK035r2K+FKedlFaqmIZ/VaINL+SYU9j1nj8hgtER1iQDPoV/9WPgP5l/VN68KbsFkfKxbTjaK9S1wVBEKI3rezIYuN6STJIFGUnNaqQxxovizjjxfJ2awN/WJOCsqvLS2tOVQBxiIpqtPsz4y77scBaN4cytipzLqtgoqQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=Ub72SK2O; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44TEoGDg021695; Wed, 29 May 2024 18:10:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= B1bFvicHobFbigotDFpVBAah8hOJ3e+zH7AfuuLx4GE=; b=Ub72SK2OLkSM4mb8 +cpuicCTh5VeMzK5T5KVBU8f+20xbPJVmYJ3Wk9Fu4o87h6YJBnhlUWaEhXnC+K5 NvOB5jBL6aod4lOjEtFwwUYgc5zwe1izrQoRJNb1ModnfiyUBMfzPSH4AwXVhv/Y XPmmo8tyxL3zlIatK4oiNQS9inXMFaa+Zsri3he9ic0WvrLtiAJhsWovWLIaPxGI DCgXnyehPo1lb9XOsmdP7E34SsuRI3jfAcQMycuJ95Td9U+CX+vfgs0Ov8mdDrik 1w3vsv0Mks4jhWHDYCUMblZVpCRuw6LINhMq8ibS3sOirfYkRq04fTn7wA1NDdJ0 A4kCxQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3yba2n1sw7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 May 2024 18:10:02 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 44TIA0V4023051 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 May 2024 18:10:00 GMT Received: from hu-clew-lv.qualcomm.com (10.49.16.6) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 29 May 2024 11:10:00 -0700 From: Chris Lew Date: Wed, 29 May 2024 11:09:57 -0700 Subject: [PATCH v3 3/4] soc: qcom: smem: Add qcom_smem_bust_hwspin_lock_by_host() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20240529-hwspinlock-bust-v3-3-c8b924ffa5a2@quicinc.com> References: <20240529-hwspinlock-bust-v3-0-c8b924ffa5a2@quicinc.com> In-Reply-To: <20240529-hwspinlock-bust-v3-0-c8b924ffa5a2@quicinc.com> To: Bjorn Andersson , Baolin Wang , Peter Zijlstra , "Ingo Molnar" , Will Deacon , Waiman Long , Boqun Feng , Jonathan Corbet , Mathieu Poirier , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Manivannan Sadhasivam , Konrad Dybcio CC: , , , , , Chris Lew X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1717006199; l=2281; i=quic_clew@quicinc.com; s=20240508; h=from:subject:message-id; bh=mOSE2ntqu4Rot7ryHq21ynAVLd53KCm+8J+0kl8CtRg=; b=J5VmdTHtRwClyZU6R0zZg0eoETdLuXbAjOGrMLgKrap88rP1pHlEGdeovFeMqEJrq6N+CZGMU HKCFy7uVx+eBmqM7ESQV2zcRa3v8ATJOk4WgmWJ/FyDarrtZ+EY8bD7 X-Developer-Key: i=quic_clew@quicinc.com; a=ed25519; pk=lEYKFaL1H5dMC33BEeOULLcHAwjKyHkTLdLZQRDTKV4= X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: OBXwHtGWxJS7lzLEBCf3flCeqnFuNAXD X-Proofpoint-ORIG-GUID: OBXwHtGWxJS7lzLEBCf3flCeqnFuNAXD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-29_14,2024-05-28_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2405290127 Add qcom_smem_bust_hwspin_lock_by_host to enable remoteproc to bust the hwspin_lock owned by smem. In the event the remoteproc crashes unexpectedly, the remoteproc driver can invoke this API to try and bust the hwspin_lock and release the lock if still held by the remoteproc device. Signed-off-by: Chris Lew --- drivers/soc/qcom/smem.c | 26 ++++++++++++++++++++++++++ include/linux/soc/qcom/smem.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 7191fa0c087f..50039e983eba 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -359,6 +359,32 @@ static struct qcom_smem *__smem; /* Timeout (ms) for the trylock of remote spinlocks */ #define HWSPINLOCK_TIMEOUT 1000 +/* The qcom hwspinlock id is always plus one from the smem host id */ +#define SMEM_HOST_ID_TO_HWSPINLOCK_ID(__x) ((__x) + 1) + +/** + * qcom_smem_bust_hwspin_lock_by_host() - bust the smem hwspinlock for a host + * @host: remote processor id + * + * Busts the hwspin_lock for the given smem host id. This helper is intended + * for remoteproc drivers that manage remoteprocs with an equivalent smem + * driver instance in the remote firmware. Drivers can force a release of the + * smem hwspin_lock if the rproc unexpectedly goes into a bad state. + * + * Context: Process context. + * + * Returns: 0 on success, otherwise negative errno. + */ +int qcom_smem_bust_hwspin_lock_by_host(unsigned int host) +{ + /* This function is for remote procs, so ignore SMEM_HOST_APPS */ + if (host == SMEM_HOST_APPS || host >= SMEM_HOST_COUNT) + return -EINVAL; + + return hwspin_lock_bust(__smem->hwlock, SMEM_HOST_ID_TO_HWSPINLOCK_ID(host)); +} +EXPORT_SYMBOL_GPL(qcom_smem_bust_hwspin_lock_by_host); + /** * qcom_smem_is_available() - Check if SMEM is available * diff --git a/include/linux/soc/qcom/smem.h b/include/linux/soc/qcom/smem.h index a36a3b9d4929..03187bc95851 100644 --- a/include/linux/soc/qcom/smem.h +++ b/include/linux/soc/qcom/smem.h @@ -14,4 +14,6 @@ phys_addr_t qcom_smem_virt_to_phys(void *p); int qcom_smem_get_soc_id(u32 *id); +int qcom_smem_bust_hwspin_lock_by_host(unsigned int host); + #endif -- 2.25.1