Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4590769rdb; Fri, 15 Sep 2023 06:56:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFH9qhDUR/eOHmE/HlC9BTj02Se360jA1BwLmJ10ZyTZ8/XV7vWDOckIMqNcNa8LLYzsrc7 X-Received: by 2002:a17:902:eaca:b0:1c3:ae56:4594 with SMTP id p10-20020a170902eaca00b001c3ae564594mr1687615pld.49.1694786170940; Fri, 15 Sep 2023 06:56:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694786170; cv=none; d=google.com; s=arc-20160816; b=afLdZS/CHFeE2qirVzkR3cuH2naI5oBQT0Toc8Gp9sO+1jLS6WfG7gF1OzAosiMeYT JSNsZe9BA5STe/ewShGXbbcfRdoqdoeTkkBXEmsTGiuVuMr48PFjN7kIK/hdBTq/l2M8 n6N9mcDRIyEO5SmYllrSpRHicyxDnGaWhXtjL+8D4aiHeOPxbsem2NqAu3wHxB6NC/xt PhqKhjHz4nxuBFPSZ5Hfdx5azhwKTRkpU1pH4ioJgzB8m53TjJwUL9xCwDtLchSg2DfC nw7WGFjxt6NnaGNNFFSd03cAX6Vv5Raq0LY+76FM/YxF5svRn9B0Gtsx3/Ek5rp7bA1m 7yQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=G7gSDZoI4sEqH2VruW2vcuYSTgnnacSUGs/AzU3emLo=; fh=d4QVL3mOiBaQM8WiBx72glU2q3KUTi+G37tAgFwlC+M=; b=kXXwyPB7xb3Y6RsOyz+WRqOCPOmtUJjCXq9qc6jUue5LeqSfUD3HiWhLE1iHVOtUJN /K0/XrOfYvg0RnxjfyIAIdIdBu7rsI+G+mRoJxtxGcfGQLILeD115s4OEtmlB/lbWCPm LZttL778t6Mtz3Ft0tY480opP0p7aYuHW51RmE11aQ7MB4mTanaszFVa4I3s/KO91NOh POA47OCG5IcLNv1gSbAhFC0i/Lm9W2Cv7sAJ/j2kqnUTtsu1tLERPuTVy7qSu0Fl0Xi7 fwgsAgOs48tYAakz1Zp7bSM6FkE6RCyD17Z+NegvEs8ZvQAiHEy//3u0KCiOHnEU3jwF CBZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=u9KaS3Ui; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id x8-20020a170902a38800b001bc63c38e17si3356706pla.244.2023.09.15.06.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 06:56:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=u9KaS3Ui; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 8ABF681E5D03; Thu, 14 Sep 2023 22:58:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232152AbjIOF6P (ORCPT + 99 others); Fri, 15 Sep 2023 01:58:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232120AbjIOF6O (ORCPT ); Fri, 15 Sep 2023 01:58:14 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E772F1BD0 for ; Thu, 14 Sep 2023 22:58:06 -0700 (PDT) Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 72AE53F66A for ; Fri, 15 Sep 2023 05:58:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1694757485; bh=G7gSDZoI4sEqH2VruW2vcuYSTgnnacSUGs/AzU3emLo=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=u9KaS3UiOPi2GaVQQG3FXo4z/5cacdXDdzqZjivoYHdujxLgRSrlJrh9cZUgmpkJ8 d8wQlA4ebxx42bmIxqdqyxAa5jExL9Ut0VURErTzQ46gsaCcda5BvCTE9rg3VNZDXV azAEs4SCy5LQdnOYnH8LA+7HaKE1cqtnlU7O0GO8sFeGJtPYtdUWNxW6ShH6PeQzKZ K9a6lbUsnykruTT1TkZnahP1MJV1lkaheMcAFvO9e9KJ8hwIMHEYRvA+rHwxuz07Gi SGWTZ56ZQuqV8X9ZXcooCVi2c7+6CEhvLjnbB5OUj9Z8gzwnFoSwreo5OI3OFTKOhv E8ZbzcRLcEqpw== Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-273983789adso1521944a91.0 for ; Thu, 14 Sep 2023 22:58:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694757483; x=1695362283; h=content-transfer-encoding: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=G7gSDZoI4sEqH2VruW2vcuYSTgnnacSUGs/AzU3emLo=; b=ffvcN/2jGSxTxtmPqjomEAnnJTPswu0dCp/r4xsazrOU8tndF75QUM8V5xLho0nsvD 9uySV/zRkrBOljIB6fSbMqavo9+n/TkvuI8z7yZ1/MS1Apye/8gx0MzIplNXK95WaN7B x46uVvEooSwRZ2qo1783DUrZirglJPUyqHis0DfMj7Vc6PHYRanPdSzCX9vLKibRWMmR gHuKEq9qR9k9460NJ3t0ikS2WVikrsVp58g4tx1EVWms3SjeNjCUoQhEE+jGWp2wuJWu 2IAHHF98F998e8uknxC2HMNIUqUWnTDSaTQNUquIzZS3K9pnmagRGrA4efCN4lFLfhMD RzQA== X-Gm-Message-State: AOJu0Yx52U+1C828SZgiRH6dkfMe+h+s9zE7OooApNqHZP4WBLp+J/O7 DsH/mdYHpA7BTwQnFHhM7Szv9qiliEikDeX4wpXmwq8lc4YExYmhkkXzJf+u4Xp4VCWIWT7lKBV PYR5w1WUU8lV54LJRQDSaio8jklcpqQh4o/lJqHGg1oMWEFKPi+ZPjHhCZw== X-Received: by 2002:a17:90a:fc89:b0:268:b0b:a084 with SMTP id ci9-20020a17090afc8900b002680b0ba084mr521093pjb.46.1694757483490; Thu, 14 Sep 2023 22:58:03 -0700 (PDT) X-Received: by 2002:a17:90a:fc89:b0:268:b0b:a084 with SMTP id ci9-20020a17090afc8900b002680b0ba084mr521077pjb.46.1694757483114; Thu, 14 Sep 2023 22:58:03 -0700 (PDT) MIME-Version: 1.0 References: <20230914041806.816741-1-kai.heng.feng@canonical.com> <20230914184249.GA74069@bhelgaas> In-Reply-To: <20230914184249.GA74069@bhelgaas> From: Kai-Heng Feng Date: Fri, 15 Sep 2023 13:57:50 +0800 Message-ID: Subject: Re: [PATCH] HID: intel-ish-hid: ipc: Rework EHL OOB wakeup To: Bjorn Helgaas Cc: srinivas.pandruvada@linux.intel.com, jikos@kernel.org, benjamin.tissoires@redhat.com, linux-pm@vger.kernel.org, linux-pci@vger.kernel.org, Jian Hui Lee , Even Xu , Zhang Lixu , Najumon Ba , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 14 Sep 2023 22:58:20 -0700 (PDT) On Fri, Sep 15, 2023 at 2:42=E2=80=AFAM Bjorn Helgaas = wrote: > > On Thu, Sep 14, 2023 at 12:18:05PM +0800, Kai-Heng Feng wrote: > > System cannot suspend more than 255 times because the driver doesn't > > have corresponding acpi_disable_gpe() for acpi_enable_gpe(), so the GPE > > refcount overflows. > > How can a user know they are seeing this problem? Is there a public > bug report for it? Here's the error when it happens: [46307.532037] intel_ish_ipc 0000:00:1d.0: enable ose_gpe failed The ticket was filed privately. > > > Since PCI core and ACPI core already handles PCI PME wake and GPE wake > > when the device has wakeup capability, use device_init_wakeup() to let > > them do the wakeup setting work. > > > > Also add a shutdown callback which uses pci_prepare_to_sleep() to let > > PCI and ACPI set OOB wakeup for S5. > > Is this logically required to be part of this patch, or could it be a > separate patch? Because that's what 2e23a70edabe ("HID: intel-ish-hid: ipc: finish power flow for EHL OOB") intended to do, to enable wakeup from S5. > > > Fixes: 2e23a70edabe ("HID: intel-ish-hid: ipc: finish power flow for EH= L OOB") > > Cc: Jian Hui Lee > > Signed-off-by: Kai-Heng Feng > > --- > > drivers/hid/intel-ish-hid/ipc/pci-ish.c | 59 +++++++------------------ > > 1 file changed, 15 insertions(+), 44 deletions(-) > > > > diff --git a/drivers/hid/intel-ish-hid/ipc/pci-ish.c b/drivers/hid/inte= l-ish-hid/ipc/pci-ish.c > > index 55cb25038e63..65e7eeb2fa64 100644 > > --- a/drivers/hid/intel-ish-hid/ipc/pci-ish.c > > +++ b/drivers/hid/intel-ish-hid/ipc/pci-ish.c > > @@ -119,42 +119,6 @@ static inline bool ish_should_leave_d0i3(struct pc= i_dev *pdev) > > return !pm_resume_via_firmware() || pdev->device =3D=3D CHV_DEVIC= E_ID; > > } > > > > -static int enable_gpe(struct device *dev) > > -{ > > -#ifdef CONFIG_ACPI > > - acpi_status acpi_sts; > > - struct acpi_device *adev; > > - struct acpi_device_wakeup *wakeup; > > - > > - adev =3D ACPI_COMPANION(dev); > > - if (!adev) { > > - dev_err(dev, "get acpi handle failed\n"); > > - return -ENODEV; > > - } > > - wakeup =3D &adev->wakeup; > > - > > - acpi_sts =3D acpi_enable_gpe(wakeup->gpe_device, wakeup->gpe_numb= er); > > - if (ACPI_FAILURE(acpi_sts)) { > > - dev_err(dev, "enable ose_gpe failed\n"); > > - return -EIO; > > - } > > - > > - return 0; > > -#else > > - return -ENODEV; > > -#endif > > -} > > - > > -static void enable_pme_wake(struct pci_dev *pdev) > > -{ > > - if ((pci_pme_capable(pdev, PCI_D0) || > > - pci_pme_capable(pdev, PCI_D3hot) || > > - pci_pme_capable(pdev, PCI_D3cold)) && !enable_gpe(&pdev->dev= )) { > > - pci_pme_active(pdev, true); > > - dev_dbg(&pdev->dev, "ish ipc driver pme wake enabled\n"); > > - } > > -} > > I LOVE the removal of all this code. Thanks for doing it! Thanks :) > > > /** > > * ish_probe() - PCI driver probe callback > > * @pdev: pci device > > @@ -225,7 +189,7 @@ static int ish_probe(struct pci_dev *pdev, const st= ruct pci_device_id *ent) > > > > /* Enable PME for EHL */ > > if (pdev->device =3D=3D EHL_Ax_DEVICE_ID) > > - enable_pme_wake(pdev); > > + device_init_wakeup(dev, true); > > > > ret =3D ish_init(ishtp); > > if (ret) > > @@ -248,6 +212,19 @@ static void ish_remove(struct pci_dev *pdev) > > ish_device_disable(ishtp_dev); > > } > > > > + > > +/** > > + * ish_shutdown() - PCI driver shutdown callback > > + * @pdev: pci device > > + * > > + * This function sets up wakeup for S5 > > + */ > > +static void ish_shutdown(struct pci_dev *pdev) > > +{ > > + if (pdev->device =3D=3D EHL_Ax_DEVICE_ID) > > + pci_prepare_to_sleep(pdev); > > There are only five drivers that use pci_prepare_to_sleep(), so I have > to ask what is special about this device that makes it necessary here? The idea is that use pci_enable_wake() and pci_set_power_state() in pci_prepare_to_sleep() to support S5 wakeup, by replacing the original enable_pme_wake(). > > It doesn't seem to match any of the scenarios mentioned in > Documentation/power/pci.rst for using pci_prepare_to_sleep(). > > Previously EHL_Ax_DEVICE_ID was used only in ish_probe(), > ish_resume(), and _dma_no_cache_snooping(). None of those look like > this, so this *looks* like new functionality that could/should be in a > separate patch. Because it's for S5 wakeup, so it's not a new functionality. Kai-Heng > > > +} > > + > > static struct device __maybe_unused *ish_resume_device; > > > > /* 50ms to get resume response */ > > @@ -370,13 +347,6 @@ static int __maybe_unused ish_resume(struct device= *device) > > struct pci_dev *pdev =3D to_pci_dev(device); > > struct ishtp_device *dev =3D pci_get_drvdata(pdev); > > > > - /* add this to finish power flow for EHL */ > > - if (dev->pdev->device =3D=3D EHL_Ax_DEVICE_ID) { > > - pci_set_power_state(pdev, PCI_D0); > > - enable_pme_wake(pdev); > > - dev_dbg(dev->devc, "set power state to D0 for ehl\n"); > > - } > > - > > ish_resume_device =3D device; > > dev->resume_flag =3D 1; > > > > @@ -392,6 +362,7 @@ static struct pci_driver ish_driver =3D { > > .id_table =3D ish_pci_tbl, > > .probe =3D ish_probe, > > .remove =3D ish_remove, > > + .shutdown =3D ish_shutdown, > > .driver.pm =3D &ish_pm_ops, > > }; > > > > -- > > 2.34.1 > >