Received: by 2002:ac8:7315:0:b0:429:955e:b7c6 with SMTP id x21csp211030qto; Fri, 26 Jan 2024 16:24:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHrcoPDsoJu/0Zxlw3On9miUBZXwudc0xk/kZKqI73MGCRlqEEJwmYqcAu9Cl8AlLLL8ln7 X-Received: by 2002:a2e:3309:0:b0:2cf:ef1:b263 with SMTP id d9-20020a2e3309000000b002cf0ef1b263mr611084ljc.6.1706315042090; Fri, 26 Jan 2024 16:24:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706315042; cv=pass; d=google.com; s=arc-20160816; b=FwCCPw8Sj45UPJpGECicJKLRQm0//WSYJALSR+5mcxd0CKS1ieboAvC8jyolmu0bIK 3EdOMXuhVPXGBG9UGPLldo/HqqyyJMND3eap/kYIhycnHSSjE50BIt5aeIzsoDX1nvCm eZRL1ss8XjmAMF58rNhMISyCSZoO1HZgP9PGP/Lv1aCkl5+ANGqFQJ4ZIKhQfTC/Eg7a kTfHmI4fCVPBkpc3/kbWFjxZAqP2P63iMM/8MgrcDlungRNV5nvsxB0Vl6tNftdSw66f Irt7d2LoKwpWgGW63FjEYuvLyAXjhqkbTBmw99hfEL9IyU0MSLDwuh29hpJS2QHs5W7o Etlw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=Z+fT7nX6OH5oPLL8NPSq+oI9rB13qgCcJghaZper11g=; fh=m2sHQ18QK0FypTC5WfuWK12lj8CrKmrhEZIDMqkbECE=; b=lN6qSkVvIfoXGahAVWuaroI3odtku1l7OSvrORvfPzrXIJYAL022zYg7cd//w+435x D1D6ee3kf/R+yeW38I0MTf0B2U2f+G6TqSAF2Xo9g8HU2pTbIXqtEHxt3jEnhk1LNFH5 ePLhiEdDc+Auti0Tt3ZKou5Wc0DOkO+Xjzn3zlZiLyD4ozB4w9vll9pJzSa1pjwAnnev k20IEU/jDUUmFDtJAD8NNj0mygM1CeV4/8m7+aa8fXAbIi5M0sldPbn84+yKsjUorNzZ lrpe6RDNYtH3Rpi/PjS5c2gYWAjGGcfNv83kEX8gK8LVd6CPFwDPKAyfXDO6IeluVwY+ eNBg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=n4srbI9Y; 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-40933-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40933-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id el15-20020a056402360f00b0055d3c70e498si839376edb.177.2024.01.26.16.24.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 16:24:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40933-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=n4srbI9Y; 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-40933-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40933-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 am.mirrors.kernel.org (Postfix) with ESMTPS id AB1291F22CE9 for ; Sat, 27 Jan 2024 00:24:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC157647; Sat, 27 Jan 2024 00:23:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="n4srbI9Y" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 85D6E19A; Sat, 27 Jan 2024 00:23:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706315032; cv=none; b=VDrm0223RlFC2C46+QKWN+g8qh4FbtFhN/28uHPU2XzWigKlwwJ6MqZe1e2efMojitD7t9sG7GalkLJUbVXQIdhlHa0IIb+1mNMxNg5cH+p94r/xsD/mFnCLzBj/6qfaPhYwfEWqiequ2Wb8rLOgKJsaZOMn1Sn5b5rT77m5H9U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706315032; c=relaxed/simple; bh=7LnmKXAMJFU1obVIBSv+V0d5UNbewL3dVnUcxEli3Bg=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=WLeBmES2WGOmknigAS7OWCnLhU7fX17yK0cBkaw4xvm3GBFXWTawM6S5lPKKWCJABnyL+gHYNaeJ6NipwdtAAWWEjyMowKlTb5RFza349DWp+viTBqZd/fQNCq12PegBXj0arQT904GZP3Mwt9Ioonsod+6fqQP6HdwV3cT2uoo= 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=n4srbI9Y; arc=none smtp.client-ip=205.220.168.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 (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40QNdOQs005928; Sat, 27 Jan 2024 00:23:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=Z+fT7nX6OH5oPLL8NPSq+oI9rB13qgCcJghaZper11g=; b=n4 srbI9YhH5VOPx+E8pd60BRpu70CDNvlP6TWIIfixX2gECAZAzPIhFHtlWROLubB6 VIUW3/xxa8/Dv2LQou30pry4SnpnwYf7kKYcM7ZU9v26mYlLCoWTfcFi4/JqA/Zy 9VtFB+eb7jt12Jb4qHTQ53w+3wrxkNcOXq3fg4NwTW936vXU4vxw2EWhS3bdHX5V IY/KsYhq5RWQQ10UixJ+9hnktyytamGwcfIBGAVioemzfhc8+jAhMyNWJO0ju6Q3 t3cLOJLRMWHjEi1D5OAY3o69QJUJ5tyLdh9RL4S6bzoTsf8yJIKDqA3MUwP25M3c JWICW7ma7oj9goaeNvIA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vvjbg8hm1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 27 Jan 2024 00:23:47 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40R0Nlse009696 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 27 Jan 2024 00:23:47 GMT Received: from [10.110.53.178] (10.80.80.8) 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.1118.40; Fri, 26 Jan 2024 16:23:44 -0800 Message-ID: <065cbefc-031e-7595-9d48-f869585dfcd3@quicinc.com> Date: Fri, 26 Jan 2024 16:23:43 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH] qcom: smem: remove hwspinlock from item get routine Content-Language: en-US To: Tao Zhang , , CC: , , References: <20240102022512.999635-1-quic_taozhan@quicinc.com> From: Chris Lew In-Reply-To: <20240102022512.999635-1-quic_taozhan@quicinc.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: r15WZgRvOezgLEJuW8c6LBQVddXzlR5v X-Proofpoint-ORIG-GUID: r15WZgRvOezgLEJuW8c6LBQVddXzlR5v X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-25_14,2024-01-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 priorityscore=1501 mlxlogscore=885 phishscore=0 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401270001 On 1/1/2024 6:25 PM, Tao Zhang wrote: > During an SSR(Sub-System Restart) process, the remoteproc driver will > try to read the crash reason from SMEM. The qcom_smem_get() backing such > operations does however take the hwspinlock (tcsr mutex), which might be > held by the dying remoteproc. > > The associated timeout on the hwspin_lock_timeout_irqsave() would take > care of the system not hanging forever, but the get operation will fail, > unnecessarily delaying the process for the 'HWSPINLOCK_TIMEOUT' duration > (currently is '1s'), and finally resulting in failure to get crash > information from SMEM. > > This timeout can be avoided by removing the hwspinlock in the > qcom_smem_get routine. SMEM ensures that the allocated item will only be > visible after the new item is safe to use by following a specific order > of updates. > > In the private partition case, qcom_smem_get_private() will use > 'offset_free_uncached' as a loop boundary when looking for existing > allocated items. The corresponding allocation will only update > offset_free_uncached once the item is fully initialized. > > hdr->canary = SMEM_PRIVATE_CANARY; > hdr->item = cpu_to_le16(item); > hdr->size = cpu_to_le32(ALIGN(size, 8)); > hdr->padding_data = cpu_to_le16(le32_to_cpu(hdr->size) - size); > hdr->padding_hdr = 0; > > wmb(); > le32_add_cpu(&phdr->offset_free_uncached, alloc_size); > > The global partition is similar but uses the "entry->allocated" variable > to ensure the item is not visible to qcom_smem_get_global(). > > Signed-off-by: Tao Zhang > --- Reviewed-by: Chris Lew