Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp358781lqb; Tue, 28 May 2024 19:06:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW7P6uwQMpqs8zd2JUdMstAk7elYD3PY/o9y9sAnY3XMYelj6yIuPQKo2fjMHaiVm4LyoBKyuWuu6GdWJMQ8pdRmH99i1GlasyZtXo8EQ== X-Google-Smtp-Source: AGHT+IHPs0BEaIDxHVCKmxFPXgABpAWaMxRk4rwuoVBai5tjQcJm5875cbsFC5f1ojHzP9JIQw/b X-Received: by 2002:ac8:5f89:0:b0:43e:26f5:7e5d with SMTP id d75a77b69052e-43fe10e36c5mr14179741cf.12.1716948411693; Tue, 28 May 2024 19:06:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716948411; cv=pass; d=google.com; s=arc-20160816; b=hLK9jDcWVXd0XDN6RTvnNFY9FfGPBskT1Z4OS+yVxLIGcVY68MdZeX4mxS6d6+PstL tDgAbsLF6t1iN3tsiJR0tXYNZYwinyzuX2TTzQYX1yOnu8U7PwTglUOtYvD4BSCevDUx p6CnDxGrbROYG1Q6Tg9bCV/KD7cAhazqjnv3cTXUp1/68oGt4p51zQB0l/NOw8c6xW6S kzYJ/MBVmagHsVhJJNLl9TQrex3eQjbnOrrdg6dgszoKVQKrSuOYxUMf18tPyWuRQxag 1cCm4iTpLrLFNZKWaDzzWZka4bwv6w7x9KMoTQzMvdlUc2mrmqml1CdIbSqw8nZIiNdH BZvQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Kd/Emi60h3QlJ3uTQcXIw4KLaS7d4ineeGjdZF5mRBM=; fh=tdJHIP+n/hVzzW9sRgRhPBD3YgTH4IUXB2IHn8IaaT4=; b=I3zO8m0Qoqr6XgHqOnydyGRUq9HgzU83ZPx1aaA9uAlEZz2O4t7zI0LfmgUCHKjhZQ /T/oIYaGRnkS6Jq9MbDMHtZ/Ad0ylRts94E4sU4o5LD4Wy0DzwaOSDM8oJfRTJeMO+CY KdAsXV58coOkaiRsPwh2tphG+8zP7mSGQmveXk35WBITdQvN6arlYoBu6DmV82hB2owT kybp/ZCpSMyZwFt105ZD5FaR0Q2A3mjOu3klfjTVznkPmGj8iu5CMKLJqgr69CHmMc26 i6u9k7JflpfypuI7NVTD4Ubzd4+t9jhNQ/sEjCuWRANeivvMLT/rCwO/LuSDQYWP30tB iBqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RKmBo7Vo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-193342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193342-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43fd57903c5si44181631cf.36.2024.05.28.19.06.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 19:06:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RKmBo7Vo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-193342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193342-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6E9571C235EE for ; Wed, 29 May 2024 02:06:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C1DB15B14E; Wed, 29 May 2024 02:04:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RKmBo7Vo" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 353A815ADA5; Wed, 29 May 2024 02:03:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716948239; cv=none; b=h8bFYmSujbVsZL0kT8I6v+0nfuUE/EfFwINmB7/SyhL43fMkBK/q2UHrG1oeT3DhJ+GfKE8YH2irp8l6nZVtErZ02gqSZxP/Im7JxQuC4Q792St2s3kpT0DQIrInMQrKH+8wUc/6foT5WWxx3Wmv+ZxxhReiPjqzMjx5yJExZ+k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716948239; c=relaxed/simple; bh=Amd0ZaKiTq3QW1olkeBFmUIFypfq2JePdZVnQMLo0YE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MbSmldZhzrk8A2nRSzEYKKtOwXOwolGzNChNuFpxDoFRtxEP3LPHfnqfC/VrMnxN/ik36Gbwl01Hhr7cgQlFPg1cbmxQyaC6E2M9ABY1ktDaH1aGMgcBSMLgRqjgA2BSe304x8pqAEhF8JhKi19whMMzQ06Nd6lRAxCSiRHwkz4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RKmBo7Vo; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6818C3277B; Wed, 29 May 2024 02:03:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716948239; bh=Amd0ZaKiTq3QW1olkeBFmUIFypfq2JePdZVnQMLo0YE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RKmBo7VoZo0QWHBlk6gDCjIU+Vi6tqjPRDaI/jj5fyDXqB0+JXlv1ucllDQUfvT0y XnptGk/6BmZOa3t/7xOGuE/uO2PuMDPrI6PellP01zajSilbyRhcXG3Y9G8OiZYnXh MyizDzWOBq3+TW0H/vCARzQrQQyIz8FUf3M02U0tOqz19MQgwLTfeSKPikAXrDfLeN uAYEOYb92zyDlHN05tUy9VcNPVOdS+Rsa7QN0+6iSVSS9qb6V8OfwBqLxXvFeu8Tl0 2Wu++IvFiQ/nPtgdgXqKGPbjoxBD7+Ma0zq1Ql/AoIa9NwO3d99MhOdRPLwUP+ivrV sW8yjTrb0CSOA== Date: Tue, 28 May 2024 19:08:41 -0700 From: Bjorn Andersson To: Chris Lew Cc: 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 , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: Re: [PATCH v2 3/4] soc: qcom: smem: Add qcom_smem_bust_hwspin_lock_by_host() Message-ID: References: <20240524-hwspinlock-bust-v2-0-fb88fd17ca0b@quicinc.com> <20240524-hwspinlock-bust-v2-3-fb88fd17ca0b@quicinc.com> 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=us-ascii Content-Disposition: inline In-Reply-To: On Tue, May 28, 2024 at 03:50:25PM -0700, Chris Lew wrote: > > > On 5/28/2024 2:55 PM, Bjorn Andersson wrote: > > On Fri, May 24, 2024 at 06:26:42PM GMT, Chris Lew wrote: > > > 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 | 28 ++++++++++++++++++++++++++++ > > > include/linux/soc/qcom/smem.h | 2 ++ > > > 2 files changed, 30 insertions(+) > > > > > > diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c > > > index 7191fa0c087f..683599990387 100644 > > > --- a/drivers/soc/qcom/smem.c > > > +++ b/drivers/soc/qcom/smem.c > ... > > > + * > > > + * Context: Process context. > > > + * > > > + * Returns: 0 on success, otherwise negative errno. > > > + */ > > > +int qcom_smem_bust_hwspin_lock_by_host(unsigned host) > > > +{ > > > + if (!__smem) > > > + return -EPROBE_DEFER; > > > > This would be called at a time where -EPROBE_DEFER isn't appropriate, > > the client should invoke qcom_smem_is_available() at probe time to guard > > against this. > > > > Should we keep the null pointer check to prevent null pointer dereference > and return 0? Or would it be better to allow the null pointer deference to > go through so we can catch misuse of the API and ask clients to use > qcom_smem_is_available()? > I like the helpful callstack you get from the NULL pointer dereference... Regards, Bjorn