Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1225761rbb; Mon, 26 Feb 2024 02:53:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXP37n/SScs1x8IiYL+KSSQEGoEYK2UAPyc1d14hgk+TI1J5k0C6NkTVyrlHfQ6WDasl1fyaRnT9mwkn7pbdooxs8BCc1xBtmjQUlxuFA== X-Google-Smtp-Source: AGHT+IH6VAxDU5ZIFDW1LzzPKd1L6naDb9ZOFx3VHQtaKfUzljOxsqBYdcBovSYWP0ZUgOV1GdKu X-Received: by 2002:a05:6214:2f03:b0:68f:e925:ada6 with SMTP id od3-20020a0562142f0300b0068fe925ada6mr11319073qvb.30.1708944819462; Mon, 26 Feb 2024 02:53:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708944819; cv=pass; d=google.com; s=arc-20160816; b=mTf+qjymOIhWQNF7KHqS/mdfU2ut1kPylzWJvswQKXhYWryvzMggRP14DOz/0rng0F 9NmbbMCy1/VN3yKpFaegrO47K/X4VeuGgjkUAZN6n+7cYadDdVkXSpHXf7d8iNvB9GCC rUGW4rs+0RgA5YMNILMur88+fs7YhgfRJKKUmGDsySQUPnAnQTnr4DJMM8Mqt9JGAid2 hnfsYqVqy7xQwcsga8sRsRFvKcnVyrHcz1+0cThsCs+gpn+QFFvoq6e6O+XMOphehSy4 tjMYa5aKOm/DU+quOd3SnorJFL8X/XtNjxy2jbvXDYIuVsiQWTUbb/dGrGrfCVQuCiU9 c5zg== 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=w9TyoGpOCvRQv/gJUy7+mFP1pj5Rw37oykK8RZNDLt8=; fh=hVT8bKmOZnFnXrvb5ykBRUZpSsGJea9slN4jwxtnHpk=; b=0ElV1uVvyv2N+L7zwPLpWC4hzSdXmcMVwLKarg+xWek8mgytGuSf7wdjDB0djFTF5H 070baxW3x8nL8ZS37AZ/2aDij1U5YBi65wSdJvJTnHvRSXxGSMRCgrPbiekjsDnHtCi4 jhA+acBj1r4IVZ7R4TZ/SJL5P6VV5N75g+3zEQnz+LKt6FBQNO2SfscUKvWJ2OO4dFzY Wad98+jO8J8O/tIspjX3WPpdjN3ollS+1DA0ZmcJky+UEzWQlweZjag14MwCeb7KKB+8 ss60B3DJM9FnU+eqLU8r2UjBciulscRQls0x0O7YbhgDZ6oYrZ2Ro8R0ayP0MpNbuxz3 /13A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=F1oiaveG; 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-81212-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81212-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a3-20020ad45c43000000b0068fef9b4468si4629956qva.279.2024.02.26.02.53.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 02:53:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81212-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=@quicinc.com header.s=qcppdkim1 header.b=F1oiaveG; 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-81212-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81212-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 494B71C25400 for ; Mon, 26 Feb 2024 10:53:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 57BF84CB55; Mon, 26 Feb 2024 10:49:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="F1oiaveG" 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 F118F249F5; Mon, 26 Feb 2024 10:49:27 +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=1708944569; cv=none; b=KQ/yEUherz9iwntY/uMbe3rcheEL7guWznyflRPnHRSJKEPEuhYYK4KR01uBFfGzNJPz+1MFIk2gqSCFOGKs9rcHX9nX91ci+Hplz3Qi4BoWmBeI/tIpGl2dqxxBWqFau/e/1K8dxkvUZoPP1iJoCaxJ/X+O+PIzlE9zUwieYAg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708944569; c=relaxed/simple; bh=z8/tQg16Mj4QPFaSnOVlLDwmLI2YQNbI1hMXpNdN8aw=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=HIIm1M9hhePp/hV4Ofp5bmoAfQ5nlXS0gZPNwvoOhQWPdvK4UrfZMTQB2BDXcpBwHpEEZPOonLbwyypbQxw3Bl65yxkMUtkaU6bWgKVsyYqIPPHXTo2hVILG/DZp48bCmE1zumdyz9UUQl7NUl68f4o0sdt6xI2GwnvqERITSFg= 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=F1oiaveG; 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 (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41Q5d3LM005307; Mon, 26 Feb 2024 10:49:22 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=w9TyoGpOCvRQv/gJUy7+mFP1pj5Rw37oykK8RZNDLt8=; b=F1 oiaveGESwo0VHyX4IWey4qAvMd2F//vUdugkWNibELdC9dBczrj6k5d/lLzZSSKx vDdLCZvXMyb1j+X5NUMH2EEf17SdUOa05+0r/zVZP5HZDkdzxJTELJ3gY2d0ZdtF LcUgz0XyggfQVCXCd0xkc6UuvebcIeJSs+6wD9XOPn7tajEHJPCeK/aU/EiU0oL9 gjptgGAcswTrwc6yvCfKeyf3YM6UnIdxbttuSUQtkQVkIHNfj81p3pc797GmLPE8 +Jmrh4Rv+XpBmkHPsxZiG/e078Pl3q5YS6tzDUBj2g4drKhgRN52e4Au8XSvac5/ 0H73wICntUTF5Tbyo6PA== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wgkxmgp38-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 10:49:22 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41QAnLYX014322 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 10:49:21 GMT Received: from [10.216.40.60] (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 26 Feb 2024 02:49:19 -0800 Message-ID: Date: Mon, 26 Feb 2024 16:19:16 +0530 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] soc: qcom: llcc: Add llcc device availability check Content-Language: en-US To: Mukesh Ojha , , CC: , References: <20240220122805.9084-1-quic_mojha@quicinc.com> From: Sahil Chandna In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: qJ9hNCjc6XPSDviz-XC4N3SeuJOVusRD X-Proofpoint-ORIG-GUID: qJ9hNCjc6XPSDviz-XC4N3SeuJOVusRD 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-02-26_07,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 impostorscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 lowpriorityscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2402260082 On 2/26/2024 4:02 PM, Mukesh Ojha wrote: > > > On 2/22/2024 11:37 PM, Sahil Chandna wrote: >> On 2/20/2024 5:58 PM, Mukesh Ojha wrote: >>> When llcc driver is enabled  and llcc device is not >>> physically there on the SoC, client can get >>> -EPROBE_DEFER on calling llcc_slice_getd() and it >>> is possible they defer forever. >>> >>> Let's add a check device availabilty and set the >>> appropriate applicable error in drv_data. >>> >>> Signed-off-by: Mukesh Ojha >>> --- >>>   drivers/soc/qcom/llcc-qcom.c | 23 ++++++++++++++++++++++- >>>   1 file changed, 22 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/soc/qcom/llcc-qcom.c b/drivers/soc/qcom/llcc-qcom.c >>> index 4ca88eaebf06..cb336b183bba 100644 >>> --- a/drivers/soc/qcom/llcc-qcom.c >>> +++ b/drivers/soc/qcom/llcc-qcom.c >>> @@ -769,6 +769,27 @@ static const struct qcom_sct_config >>> x1e80100_cfgs = { >>>   }; >>>   static struct llcc_drv_data *drv_data = (void *) -EPROBE_DEFER; >>> +static DEFINE_MUTEX(dev_avail); >> what is the requirement for mutex lock here? Since we are only trying >> to find if node present or not > > I was trying to avoid two parallel call from llcc_slice_getd() calling > parallel call to of_find_node_by_name() as it should be one time search > for device presence to find a node and check if device is present or > not. > > -Mukesh > Got it, but of_find_node_by_name () is holding a raw_spin_lock_irqsave () for concurrency, right ? please correct me if understanding is wrong. >>> + >>> +static bool is_llcc_device_available(void) >>> +{ >>> +    static struct llcc_drv_data *ptr; >>> + >>> +    mutex_lock(&dev_avail); >>> +    if (!ptr) { >>> +        struct device_node *node; >>> + >>> +        node = of_find_node_by_name(NULL, "system-cache-controller"); >>> +        if (!of_device_is_available(node)) { >>> +            pr_warn("llcc-qcom: system-cache-controller node not >>> found\n"); >>> +            drv_data = ERR_PTR(-ENODEV); >>> +        } >>> +        of_node_put(node); >>> +        ptr = drv_data; >>> +    } >>> +    mutex_unlock(&dev_avail); >>> +    return (PTR_ERR(ptr) != -ENODEV) ? true : false; >>> +} >>>   /** >>>    * llcc_slice_getd - get llcc slice descriptor >>> @@ -783,7 +804,7 @@ struct llcc_slice_desc *llcc_slice_getd(u32 uid) >>>       struct llcc_slice_desc *desc; >>>       u32 sz, count; >>> -    if (IS_ERR(drv_data)) >>> +    if (!is_llcc_device_available() || IS_ERR(drv_data)) Also, thinking about this, should the status of device present or not be saved in static variable instead of function call for each client ? >>>           return ERR_CAST(drv_data); >>>       cfg = drv_data->cfg; >> Regards, Sahil