Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp121782lqt; Thu, 18 Apr 2024 10:01:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUANPyg4a6GRwktzHiNr8oSzPkRLm+coyFnTiVHT5HMqyg6oqka+ClRieEFZzFJVxqF0z8F8OuXPtFNw5e4RR9QZnvUnnkUhExUXScuDQ== X-Google-Smtp-Source: AGHT+IFuYX9GxxAVHByt3NkHluuxwt3bInZ59sRyZWoas9otJGTNay+wMxDVtE+iRCq7ur9jP2er X-Received: by 2002:a05:6871:80c:b0:229:fe6a:8516 with SMTP id q12-20020a056871080c00b00229fe6a8516mr4616990oap.22.1713459717801; Thu, 18 Apr 2024 10:01:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713459717; cv=pass; d=google.com; s=arc-20160816; b=be4CnXZPZZgMkFDnjjsLK8GOJCbjpPtQKhjZHid510oSNfS4+pN8Bv10nybcZmrvB7 6/iRNHZgFSZLeEA2emv9JNzGrBz+u4MeplwKbt5Alyj0SuLOV9snchpF3wV7uf062F5G w9AOiKONoC+Ek0tHEHXJnWCzCHGsTgqcLMmTQipBQdoeWBbaBKSSAFUFfcTbmyS9hISm wuXBVN/pUPyysWOd+ZOZMWdCu0gM8A7XIhHISmE7PEpZBclayTfTWybGR8OeU8QRLe1u LMXppFnLNGgY+aOEs+zllXQEEG3SJmdpJuuzR63Gv5m39efyY+EovMc/lOfTl0dZAudq V7/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=ytqcrFoVCWsXvoo0izClLachnxXGVVj6Kun6ubesPns=; fh=poqs9I+tWgOk+jhby0v/LUpDrk08LQ0Ye8zwgbZ2Lc8=; b=f0tTDjvtlY/MqMPNSqBhIgUnjjlHlMo+983fvC/VlQR8o5NqSVGPOSho51yZAULA/L LRzvyBHZe2NiXU4QU3m46lN6BacqU3CPG9/BYnzwcZD6gYdDX13Y4tg8PPDtbImfL2ej cgZzk7ZYJtfF81vTy1rLc8OoKdOYFPdS3oK5iWYvMX0NHwc2gaMPtTSWmB45vOsGQsWF tbcf/MSYv3avYr7WY2iPwW6bBwl7lMZp9rg3/N1AxlN3m/tR8hNmnrAkHyJH1gj4V8Vi XFuNMRA9FpicOVK8dluqu14+p51m3wWXRntsNj6qdA+Q7hibBbeS7ZSsb9z+A5DGGbEk VrEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=godjbVmY; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-bluetooth+bounces-3736-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-3736-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id gk9-20020a0568703c0900b0022e13cda7c8si751200oab.126.2024.04.18.10.01.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 10:01:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-3736-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=godjbVmY; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-bluetooth+bounces-3736-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-3736-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 617022833E7 for ; Thu, 18 Apr 2024 17:01:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 85210173359; Thu, 18 Apr 2024 17:00:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="godjbVmY" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35B04165FD9 for ; Thu, 18 Apr 2024 17:00:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713459650; cv=none; b=Cdf5zWnVywvIhilFhkK5qjpX3C+IbW+OncJVQajw17T+dmCz0gvmVg0lcu+907CQSgdplFUgIb5JScepkh+6N0JJkkEjoyfi2/7haZPh2G8dMHoajzf9Ewo+XKtk4Gikf1psOei5gRuy312nq3Gobz8b/blhC6Tfozly3rOd1zQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713459650; c=relaxed/simple; bh=VlsTMa4LVSmOeTJsnkfbraULAS0VDf+EyMpAs6Q3HsE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=FwdrJTRBcBoqpSQAiSULANmX+O3PSjaOj17UEmR+mPxdcZ2nPKP1YH1W5xWCFn+rAaOzxBseNKHpkUwnD3CAxTVeomthEIUR/UdB6RJw9hTEqmw5H+wMZCZ63lL8TsY6K9O4VOP2HgeEyZeNcdlpKfdoazrmCvTNuoH8OqbzcwU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=godjbVmY; arc=none smtp.client-ip=209.85.219.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-de467733156so1008495276.0 for ; Thu, 18 Apr 2024 10:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713459648; x=1714064448; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ytqcrFoVCWsXvoo0izClLachnxXGVVj6Kun6ubesPns=; b=godjbVmYsMUyiEt7Z7YAa2jHco4eREPuDDH98I1MM6eQjfkThpxj2tMDhu03UWh6sl RCqURsnW/jeJrr8mmVWxCcdxy0siljGLrd9VksCjjPQNZDb0B9fRQVbtcI1huN0b5YEo Ugg57iG+wuLbG153qbsrjGeAay7yhK+6iEKD6d0B0enXD9TnwF9PmtGx8muij2NlSKDD 94hVc6+A4K5MJW3NGggkuDQa8ltSsCBf9/4T7wTXVC3nrkcM+HR8tBxQozrDJ+MJdUVz 9DqT8VWvXtTjA3SEBkOd79FqkHCaLtRZVYgczajaUF0TY3gMKcmDLEinDXYYKRHgMrO0 a2yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713459648; x=1714064448; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ytqcrFoVCWsXvoo0izClLachnxXGVVj6Kun6ubesPns=; b=UI/1a0rcGSvBrO22c94JFt5r30cjcDOFcYgrqziaTrCzbvl/BPv8L1EwDaHKhGRKo+ 23EGx2zSyxHWnctPxboRgslEueizLgY5oelJTNVTXiaScJgmFqefHmRx6jf+eYWYLMdQ 2v2HB9W2JdLjcBfiM96narvJ86DYKpVY34G9pXhWgWt0bgvc06iOcPkVYFp7opuHSloO lDuwxmCltCz8C0EjafBy3NsMjJo2U1Ma+8cYvanGlUojG7bV93vY/Xlrtu7Hgx8kZTgQ HipwNcEpV5REbJozJIhyzjG4MFGPRSjZP7PAPCV1pELDusUue1Wm84P3q7rUfxWcFq9w BA4A== X-Forwarded-Encrypted: i=1; AJvYcCWsUhhYKKuQPR+GOISTAobJmv6EvTVrDsAD5wXlLiTDTWyrtU7PMWqZeNtCQ0WtlDnj4VFN+2337jRyrbdjCwH5WdGpX+n7TS5AvHjfKuXi X-Gm-Message-State: AOJu0YyKQM/oLILGITF0vro4IfG+3RS11Z/bke2l7UZ/RzwbvQHgNni2 JontHv2S5ljqzHW42s0WoBdY3Gl8BgjHkdxHEa93MPglWh+50Rr04g8S9RxY4lX+GSIutJF/qNN WDbvoNkQyY9UO/nNbdpN9i7KWCKO0RTIjd+brPg== X-Received: by 2002:a25:1107:0:b0:dcb:fb49:cb93 with SMTP id 7-20020a251107000000b00dcbfb49cb93mr3479260ybr.45.1713459648088; Thu, 18 Apr 2024 10:00:48 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <1713449192-25926-1-git-send-email-quic_zijuhu@quicinc.com> <1713449192-25926-2-git-send-email-quic_zijuhu@quicinc.com> In-Reply-To: <1713449192-25926-2-git-send-email-quic_zijuhu@quicinc.com> From: Bartosz Golaszewski Date: Thu, 18 Apr 2024 19:00:37 +0200 Message-ID: Subject: Re: [PATCH v1 1/2] Revert "Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()" To: Zijun Hu Cc: luiz.dentz@gmail.com, luiz.von.dentz@intel.com, marcel@holtmann.org, linux-bluetooth@vger.kernel.org, wt@penguintechs.org, krzysztof.kozlowski@linaro.org Content-Type: text/plain; charset="UTF-8" On Thu, 18 Apr 2024 at 16:06, Zijun Hu wrote: > > This reverts commit 56d074d26c5828773b00b2185dd7e1d08273b8e8. > > Commit 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() > with gpiod_get_optional()") will cause serious regression issue for > several QCA controllers such as QCA_WCN6750,QCA_WCN6855,QCA_ROME, > QCA_QCA6390 and QCA_QCA2066, the regression issue is that BT can't be > enabled any more once BT is disabled if BT reset pin is not configured > by DT or ACPI. > > if BT reset pin is not configured, devm_gpiod_get_optional() will return > NULL, and we should NOT set quirk HCI_QUIRK_NON_PERSISTENT_SETUP, but the > reverted commit SET the quirk since NULL is not a error case, and cause > qca_setup() call failure triggered by the 2nd and later BT enable > operations since there are no available BT reset pin to clear BT firmware > downloaded by the 1st enable operation, fixed by reverting the commit. > > Fixes: 56d074d26c58 ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()") > Reported-by: Wren Turkal > Link: https://bugzilla.kernel.org/show_bug.cgi?id=218726 > Link: https://lore.kernel.org/linux-bluetooth/ea20bb9b-6b60-47fc-ae42-5eed918ad7b4@quicinc.com/T/#m73d6a71d2f454bb03588c66f3ef7912274d37c6f > Signed-off-by: Zijun Hu > Tested-by: Wren Turkal > --- > drivers/bluetooth/hci_qca.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c > index 92fa20f5ac7d..160175a23a49 100644 > --- a/drivers/bluetooth/hci_qca.c > +++ b/drivers/bluetooth/hci_qca.c > @@ -2323,7 +2323,7 @@ static int qca_serdev_probe(struct serdev_device *serdev) > > qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable", > GPIOD_OUT_LOW); > - if (IS_ERR(qcadev->bt_en) && > + if (IS_ERR_OR_NULL(qcadev->bt_en) && > (data->soc_type == QCA_WCN6750 || > data->soc_type == QCA_WCN6855)) { > dev_err(&serdev->dev, "failed to acquire BT_EN gpio\n"); > @@ -2332,7 +2332,7 @@ static int qca_serdev_probe(struct serdev_device *serdev) > > qcadev->sw_ctrl = devm_gpiod_get_optional(&serdev->dev, "swctrl", > GPIOD_IN); > - if (IS_ERR(qcadev->sw_ctrl) && > + if (IS_ERR_OR_NULL(qcadev->sw_ctrl) && > (data->soc_type == QCA_WCN6750 || > data->soc_type == QCA_WCN6855 || > data->soc_type == QCA_WCN7850)) > @@ -2354,7 +2354,7 @@ static int qca_serdev_probe(struct serdev_device *serdev) > default: > qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable", > GPIOD_OUT_LOW); > - if (IS_ERR(qcadev->bt_en)) { > + if (IS_ERR_OR_NULL(qcadev->bt_en)) { > dev_warn(&serdev->dev, "failed to acquire enable gpio\n"); > power_ctrl_enabled = false; > } > -- > 2.7.4 > I told you under your yesterday's submission that you should instead consider bailing out from probe() if gpiod_get_optional() returns an error as right now if it returns EPROBE_DEFER (enable-gpios is there but the controller is not up yet), you will act like the GPIO was not even specified. gpiod_get_optional() returns NULL if the GPIO property is not there or an error if anything else goes wrong. In the latter case, you should abort probe. Bart