Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp291033lqt; Thu, 18 Apr 2024 15:42:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVfvAgM66AmvUHD7qEh4U+k9Oxu1tiWcS/eL+aTONrpIPgl5oc3N62Q3Ikq+zr0lvbsMKjgKVacDCnSL3DG6ZYnmrafzhSlG55D2+B2JQ== X-Google-Smtp-Source: AGHT+IFoK4osN/VMsqiMUEcKJ3xk+KsO/CqwFW49Mm1eQNpe9TIP8Sdpy3sIYMg3dGZrQWtQbUAA X-Received: by 2002:a17:906:a24c:b0:a51:fec0:23ec with SMTP id bi12-20020a170906a24c00b00a51fec023ecmr295178ejb.25.1713480152620; Thu, 18 Apr 2024 15:42:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713480152; cv=pass; d=google.com; s=arc-20160816; b=IVV/mDLTcYj2xPQwTa3VJww895AVgPtHQVx2HwHMSnI+NaSCNQA9Wu6Yh71BTLboVl 3dWmKmsrjPGP96vB9XFa/1cX9n9vTAF8oW47bfgvBqCiFxWnDn3QZabYRq04TDPTFq8T Zla4YPN6B9Uw32vAWMxccZZMLOMWz9aNN95XPd5dAPD4i5wO97OtOPyU7e9M75jRIM+m b8JxGd4+j5yT5deO8Vnx0hehYCLuIh0ZRJQdGFNyqLx5X69mjZqXsAEAeEyI/qTvGQ01 4Rs4o3XjjoU3M3h1/ngyJLYzShjpIliPqVjfwZeCiRhHswrZMo30/n1UchJfqZSD9GsC eaaA== 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=bKfUSYksKTj72yPLq/023/BuzyeQn6Zc0JBtcx79h2Q=; fh=TvYhwMuu60GZ3+EF6kfWOS6Bxu3ihk4J8a39ICheHkE=; b=G0fQHVi3PE1/wsR2eS4Q4EKsDYxUxXHBEgcdHURF6iHsURYbbGKpCnAtU3TjmvZnCs VA6PYEaPnWClz4czwQ3oONsjplDgYPUuCTj61G0g1SE82SeI3BLYqFLcA/2wEN2I3eKj 17kq4L2gZ0h8Zu8a18K203rA5sMVWFLss7cJbWdKZc0COyhB60UVIw2Uf65SZ/sLjuvu ZqFAn/jauMnQNgevnx/KsYWsFaHLDnlSAuuEyp/SJ/72UUNO9lsdxaBRwwywxTimBlW9 YavOaZrN2Mfgn9sg3NpnWvqxk+gxKeNaggbXoRZ8y9lngKUV+8bNniBhmp7YbgD5vwQI NYbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MA9CPR5P; 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-3748-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-3748-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 r19-20020a1709067fd300b00a526826db11si1451473ejs.153.2024.04.18.15.42.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 15:42:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-3748-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=@linaro.org header.s=google header.b=MA9CPR5P; 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-3748-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-3748-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5C60A1F22988 for ; Thu, 18 Apr 2024 22:42:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35CDF29424; Thu, 18 Apr 2024 22:42:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="MA9CPR5P" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) (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 F05C9382 for ; Thu, 18 Apr 2024 22:42:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713480146; cv=none; b=cIRNCS9+65LIbqHmfFON0i2lxbSJg/nktNKwmpmScJzKGSgXXUO9/TK3e6k8a4GYfiFzLCgtnhDQFnd79Kt4sgUqVX+jfk8tj0xvhQ3vIBcVxUJUsjtyay7KaieBrf/HyHpm0A/1qCt3Hj/NYEK8rcE2Ilp0tv4G85LXxiaCeK4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713480146; c=relaxed/simple; bh=5ZZjnf4R7D6z0h/Jvshc73SfEjkxffQ0YBV8zgfj9KU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=dMB51Ztf0YuI4RYL46gQr9KH87v2Ji/BDaoMoEzO+d3EB/pxYwUunbkyv0isxr+O7LtY4fSpsemXdzvFsuyMTizQPXQXz63izm+HVKQkKMVD3b5J345GgEdh+TKiLPZa61TPE7O1zWR/XavWHzGQpHpLcXBxe9v0YlJi5U4nzCw= 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=MA9CPR5P; arc=none smtp.client-ip=209.85.219.172 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-f172.google.com with SMTP id 3f1490d57ef6-dc25e12cc63so2445906276.0 for ; Thu, 18 Apr 2024 15:42:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713480144; x=1714084944; 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=bKfUSYksKTj72yPLq/023/BuzyeQn6Zc0JBtcx79h2Q=; b=MA9CPR5PX7rdz2OoyMP+tsuTJwv2SLKru+4qubFWNSVvP8cgv1u54PA7zq63T8UigL cNsLR6+KO1rsKVPGZ8hSthePt2Wqg0YtkBWvuY8RIBFkADioeJ8dSYdBUWAIJffxzRyr Uefxr/q6b+qGbHIIlUjbbpaS0Il19V1Ry8u4ztAQ1R7vqJvNXN6aWmsJwFvjroAi7t27 hvFyZHWozdUnAeqUtew2Rbsa92SsHC1YOyWyCkpCPcbb+xkJMWQkZuiYxZdVseHVpPDZ xAHv/iGThuYtGs2qvT7niGu7giVAZcwBmxAXA/QqpNbRtISnxZuYndrjqX1rAYUIxtdV 7eRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713480144; x=1714084944; 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=bKfUSYksKTj72yPLq/023/BuzyeQn6Zc0JBtcx79h2Q=; b=OUncMBpO3PFxr5djlANyVnfg9TMDQLdkqgLwM/3FPPMbzQ023wy/SGY6WzsL6ZgEVv q41FtpmZZUnz7Jml7TTsGCWkq5mj3hrsMtYSp6cT57iM/oF8VYPyVgg0XecTxC8k2Hxc n6YwC05M4bS2JqN2H1uurOEvpz6jnY9C25yE0URz3k5BLfUdWiO5YyZ2YYdWzI+2NwfS 7XoCWJ5okhtjB20qWjvklQa9SXGDHlCyj8iw1+sClYf7/w1shAJrU3YAIS8Mdm3v1JBg 1JA50LkiPwtnxdBrTucZ4PW4N9f4/mj06lt/pFf7rvddy1biIw/TbIqq1iUarp7T3You mKqA== X-Forwarded-Encrypted: i=1; AJvYcCVhJDN8HhssqdzyQS/KweZB7Gb/nSPPSsy4FFtiFOcHk4n+UwzjPGGI7ERiGiiiAl/a5Y4asZQQ344WbgMEQEZchdZQs7xTZhPDX9rWJhi5 X-Gm-Message-State: AOJu0Yw9A6MgDKbMEVpnTOv56+tQhJYwnbSvhkjU2M7ZnKxwhv44BO/m JDWxJp8uPWYYaqf4mASGZ9oBFJa9y6Wy/ZXEeqN9MJbIQo5xn0cPCwuRDyh2c/8l6aquw4YMsRx G+soSHacufdHWYL8ra14/AHCQiYpuWYlijxBGbw== X-Received: by 2002:a25:c78f:0:b0:de0:ee2c:b828 with SMTP id w137-20020a25c78f000000b00de0ee2cb828mr488631ybe.25.1713480143715; Thu, 18 Apr 2024 15:42:23 -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> <1ab7e6fd-68f2-4952-b5d5-bc244b8b7eb3@quicinc.com> In-Reply-To: <1ab7e6fd-68f2-4952-b5d5-bc244b8b7eb3@quicinc.com> From: Bartosz Golaszewski Date: Fri, 19 Apr 2024 00:42:12 +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: quic_zijuhu 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 23:43, quic_zijuhu wrote: > > On 4/19/2024 1:00 AM, Bartosz Golaszewski wrote: > > 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. > > > > 1) do you meet the case that EPROBE_DEFER is returned ? > It doesn't matter. It's about correct usage of a programming interface. > 2) does the reverted change solve above issue you mentioned? > What? > 3) does the reverted change solve any functionality issue you actually meet ? > What? > 4) BT still is able to work fine by clearing the quirk even if getting preferred H/W reset way failure, why do we need to bail-out and return dev_err_probe() ? > The only acceptable "failure" for gpiod_get_optional() is when it returns NULL. I should have fixed it when I sent the patch you're reverting but I didn't spot it right away. Proceeding on any other error makes no sense and will result in inconsistent behavior. > we will fix it by right way if EPROBE_DEFER is reported. > What? > this change is to solve the issue mentioned by commit message regardless other issues. > it is not possible for every commit to fix any other potential issues as long as the fix > doesn't introduce new issue. > What I mean is: don't revert a logically sound commit. Instead: improve the situation on top of it. In this case: bail out on error. And like Krzysztof said: right now the GPIO is required according to bindings so using gpiod_get_optional() doesn't even make sense as far as bindings go. Bart