Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1197962lqb; Sat, 25 May 2024 09:46:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXtos5l0c2EKTLZaVo4Qx+FqWQanqUCuh0ev7BXKeoTRtXl9Ev06MfqjBtDoQzOmH/8x9J685Aeny+oy/UNeYIbPH7CUsqSGVR+gEhFKw== X-Google-Smtp-Source: AGHT+IHBAOy4NS+yKvjAyMP5fTGWWKAa5eYVepN8hyTnZmiblNmfCfI/J2+gyahf2+WVP8ZYWohu X-Received: by 2002:a17:906:f9c9:b0:a5a:f16:32b1 with SMTP id a640c23a62f3a-a62641cfb1dmr368499066b.31.1716655572842; Sat, 25 May 2024 09:46:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716655572; cv=pass; d=google.com; s=arc-20160816; b=NxzzZk6APCw+z37cv+JNqNCZs094kNlYWTDQIFpruWvXAJ70uqc326UpxzCtoYsMvI 2tnuaOSoxKBPOtKbOccyJiWDYAGGjAqxVndrGUlrvE9G9s3ghQsw51yllBC2q19vvecg OmBWDDptMxN/mno9K+ikComc0hIuI/oALi4uP4sNWvcxLaRJ7Ad8eV9+w+GUfDAxEx+o O3FH2W2ycQE8Nev2/bOZP0vLh1sBYNchHrjOAugB18vzpQ30S+p0ZE8QIO+mfhao8CvY 0JrO+RNGHgmhVp4ReI3ZGpZeeknyi/IWymEb4MrxxrPjTxf0pPmGvGvYhK4+SUF34bRv Du7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=UZTnVB1bgkue0OUl2k7Uf4kknRWqys8iI6Gkb9uay4s=; fh=1pmxUqZOrLC+ET/vbT4HX7o4aqZ3hyssPJAZ1N/L1J4=; b=yPVDdncZYZpOGm6XxhGYov2cYED8VX5jYSP5X7jxO1yMHNE5nfHuOHuqRQ++EqeN8y ieOu7vmIa6v97xJqCkRLkTGyFdELGHoR7/PB2anYrnW0jPOh2Vu0qq2Xj60uYikikBUZ IxSY+thKBvXLm7HRYoP0g5wgPlezPqq4ZwM7lx+mYWb5x/nii5HfHjp5G1ed2TuflEBG iE0J0ZBVDV/3bFltJkJhIO187NqQ5u6gZDxwaYECsEdj7bpU757OT/CHJqUG0njhtBoj /ZfDdDpVuZiTmjTukl07rwPYF2SG5UO9l4odGnkBWNMfdwHvxu5GJz2Em7BWfnqC5tyf tNqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SYX5D08o; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-189452-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189452-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a628749be07si141640966b.615.2024.05.25.09.46.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 May 2024 09:46:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189452-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SYX5D08o; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-189452-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189452-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 65CC61F2175A for ; Sat, 25 May 2024 16:46:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94A0186621; Sat, 25 May 2024 16:46:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SYX5D08o" 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 79EA0F4FC; Sat, 25 May 2024 16:46:02 +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=1716655562; cv=none; b=fStTkuFQa8H6ctqpBVKj2UjguF7CaFa1FvgBlqlwsrIm1OqV8Uv51Afsvjf8OHzis7HMb7bPqX8uq8/M8tiyCX/53IfLWn1x29k7cCrbpD8gpFDmtV70IAVHlbYKSJgHE8spxfrNfG0dnVRicJjXU5WjF/OzRbAp239naRI/AVI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716655562; c=relaxed/simple; bh=rpJb9ufSOqQvGtI1L3Z0XIm/GwLfEIO5aOLPxpga49w=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qlb2VunVICcI8j6s6pOpOJR8EOqPR1++NOGBq4jRugAdwgojrb7hQYLz5zQDj80JQmsK3wgQZM4CZbYlw6ohET7VVBoVM9ARAd/AiXNmoGO6tl2S5kDsdWiMBkCraA6xbx8MSf5twBCuswCTWYsE3txCe7N8wc6tXVMHc2Hc2Mk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SYX5D08o; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0742BC2BD11; Sat, 25 May 2024 16:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716655562; bh=rpJb9ufSOqQvGtI1L3Z0XIm/GwLfEIO5aOLPxpga49w=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=SYX5D08onJBpVQ0l1x8JMjv0c4uyhIDVRKjWvhX40JnIinzy9zsLG9+KIOqcxYTOb gqtJGmLOl//Vxb+xZySwEn1BiGFqpUV2Gy8npwPOPeYmhO8BBy9PYQGJLwGRhxzXRP VVKzo09UjONo82nh42uILilKpLIw8bha4Wsg13ce02UqWPCT7tUn2aXrOzzHI0Y1mm NIoqZjiGTONCFignxTZ1wCYxvRVUvhqncPJQg5f2zQu4SxewOtu2Z4TVIKIqweZ0ZP ged4LTMSWFkJMb4tLwu17bsbhk+yqLMEHpr62adXlIAhTMaNy3RB7HCaKi7a9q2dCa HzJB9s2E2MNdg== Message-ID: <27151624-0c3c-43da-9983-5de86f431d82@kernel.org> Date: Sat, 25 May 2024 18:45:54 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 5/7] dt-bindings: remoteproc: qcom,pas: Add hwlocks To: Bjorn Andersson Cc: Chris Lew , 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 , 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 References: <20240516-hwspinlock-bust-v1-0-47a90a859238@quicinc.com> <20240516-hwspinlock-bust-v1-5-47a90a859238@quicinc.com> <3521519f-34b8-472d-be37-f0e64bba24fc@kernel.org> <92dcd555-69b1-4111-92dd-debe5107d526@kernel.org> From: Krzysztof Kozlowski Content-Language: en-US Autocrypt: addr=krzk@kernel.org; keydata= xsFNBFVDQq4BEAC6KeLOfFsAvFMBsrCrJ2bCalhPv5+KQF2PS2+iwZI8BpRZoV+Bd5kWvN79 cFgcqTTuNHjAvxtUG8pQgGTHAObYs6xeYJtjUH0ZX6ndJ33FJYf5V3yXqqjcZ30FgHzJCFUu JMp7PSyMPzpUXfU12yfcRYVEMQrmplNZssmYhiTeVicuOOypWugZKVLGNm0IweVCaZ/DJDIH gNbpvVwjcKYrx85m9cBVEBUGaQP6AT7qlVCkrf50v8bofSIyVa2xmubbAwwFA1oxoOusjPIE J3iadrwpFvsZjF5uHAKS+7wHLoW9hVzOnLbX6ajk5Hf8Pb1m+VH/E8bPBNNYKkfTtypTDUCj NYcd27tjnXfG+SDs/EXNUAIRefCyvaRG7oRYF3Ec+2RgQDRnmmjCjoQNbFrJvJkFHlPeHaeS BosGY+XWKydnmsfY7SSnjAzLUGAFhLd/XDVpb1Een2XucPpKvt9ORF+48gy12FA5GduRLhQU vK4tU7ojoem/G23PcowM1CwPurC8sAVsQb9KmwTGh7rVz3ks3w/zfGBy3+WmLg++C2Wct6nM Pd8/6CBVjEWqD06/RjI2AnjIq5fSEH/BIfXXfC68nMp9BZoy3So4ZsbOlBmtAPvMYX6U8VwD TNeBxJu5Ex0Izf1NV9CzC3nNaFUYOY8KfN01X5SExAoVTr09ewARAQABzSVLcnp5c3p0b2Yg S296bG93c2tpIDxrcnprQGtlcm5lbC5vcmc+wsGVBBMBCgA/Ah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wBvYll2buKod4qYntmNKEicoHGU+x91Gcan8mCoqhJkbqrL7+nXG2 5Q/GS5M9RFWS+nYyJh+c3OcfKqVcZQNANItt7+ULzdNJuhvTRRdC3g9hmCEuNSr+CLMdnRBY fv0= In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 24/05/2024 21:23, Bjorn Andersson wrote: > On Thu, May 23, 2024 at 08:15:54AM +0200, Krzysztof Kozlowski wrote: >> On 22/05/2024 19:50, Bjorn Andersson wrote: >>>>>>> >>>>>>> We did consider tying this to the SMEM instance, but the entitiy >>>>>>> relating to firmware is the remoteproc instance. >>>>>> >>>>>> I still do not understand why you have to add hwlock to remoteproc, even >>>>>> though it is not directly used. Your driver problem looks like lack of >>>>>> proper driver architecture - you want to control the locks not from the >>>>>> layer took the lock, but one layer up. Sorry, no, fix the driver >>>>>> architecture. >>>>>> >>>>> >>>>> No, it is the firmware's reference to the lock that is represented in >>>>> the remoteproc node, while SMEM deals with Linux's reference to the lock. >>>>> >>>>> This reference would be used to release the lock - on behalf of the >>>>> firmware - in the event that the firmware held it when it >>>>> stopped/crashed. >>>> >>>> I understood, but the remoteproc driver did not acquire the hardware >>>> lock. It was taken by smem, if I got it correctly, so you should poke >>>> smem to bust the spinlock. >>>> >>> >>> The remoteproc instance is the closest representation of the entity that >>> took the lock (i.e. the firmware). SMEM here is just another consumer of >>> the same lock. >>> >>>> The hwlock is not a property of remote proc, because remote proc does >>>> not care, right? Other device cares... and now for every smem user you >>>> will add new binding property? >>>> >>> >>> Right, the issue seen relates to SMEM, because the remote processor (not >>> the remoteproc driver) took the lock. >>> >>>> No, you are adding a binding based on your driver solution. >>> >>> Similar to how hwspinlocks are used in other platforms (e.g. TI) the >>> firmware could take multiple locks, e.g. to synchronize access to other >>> shared memory mechanism (i.e. not SMEM). While I am not aware of such >>> use case today, my expectation was that in such case we just list all >>> the hwlocks related to the firmware and bust those from the remoteproc >>> instance. >>> >>> Having to export APIs from each one of such drivers and make the >>> remoteproc identify the relevant instances and call those APIs does >>> indeed seem inconvenient. >>> SMEM is special here because it's singleton, but this would not >>> necessarily be true for other cases. >> >> I don't think that exporting such API is unreasonable, but quite >> opposite - expected. The remote processor crashed, so the remoteproc >> driver is supposed to call some sort of smem_cleanup() or >> smem_cleanup_on_crash() and call would bust/release the lock. That way >> lock handling is encapsulated entirely in one driver which already takes >> and releases the lock. >> > > I don't agree. > > SMEM does indeed acquire and release the same, shared, lock. But the > SMEM driver instance on our side is not involved in taking the lock for > the firmware. > > There exist an equivalent SMEM driver instance in the firmware that > crashed and that's the thing that needs to be released. Then please include relevant explanation in the commit msg. > > > We're also not tearing down, or cleaning up anything in our SMEM > instance. It is simply "when remoteproc id N died, check if N is holding > the lock and if so force a release of the lock - so that others can grab > it". > >> Just like freeing any memory. remoteproc driver does not free other >> driver's memory only because processor crashed. >> > > That's a good comparison. Because when the firmware running on the > remote processor crashes, it is indeed the job of the remoteproc driver > to clean up the memory allocated to run the remote processor. Best regards, Krzysztof