Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp426666lqb; Tue, 4 Jun 2024 16:12:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7zhd46amk/VANqZwxa9rGzBglrHVyoGcVZSUVuaJbM7VK+Aoe7rOSr5EarUQbLxcP6D+WhXjHALmMYJ2i+bHmWzhQfKzYdmDWCI1VMQ== X-Google-Smtp-Source: AGHT+IGGdRrnxNbRh7/TtcxKYcHBUplpuldoe1PmFbcZVwVlN85wvf2BrQRB3bKUhbbNOCkYC5QV X-Received: by 2002:a2e:920b:0:b0:2e9:79a4:3d1a with SMTP id 38308e7fff4ca-2eac798d124mr3877441fa.8.1717542735756; Tue, 04 Jun 2024 16:12:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717542735; cv=pass; d=google.com; s=arc-20160816; b=nW5OhUzz2ghXqqH9w23basBcvHt+//ZzMd0hRIBEl0kuU5Cj86RUPFtjieOeA1m3+W ymcQQ7NVPkkIS2hfVf3MG5tI9fOhkp7REZQRzI6bXtovXit5KcI5AmDEpw0/WRrRud7T gy5r6TU6qUr4REl+0KVgxvRUghrXRkKNOLNECA77mnrQE4ePBfNDTcvCoVYJdpbvR2p0 QVPwsaD188iDdwKcnjxJeXBQi8lkMTEEFER/3cf5Eh/KGpjZwRL+R/A4feKuSFDwCM3T 4EqFMpiBha3ziuQNVndfcTSj7+phLAGX7JXXqt1iymqwujTgmPfvldfj2NVYey61IgoD 06tw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=7lQ0d0Nz+HbLsf7tMKwA36s0niKRTo9V+v6ebXU5h6Q=; fh=ae9Uy+oCyLsE0jWcJ+XT4Zxae+fh/WvsEouBgaiomqE=; b=u3oiLYNS004ZffdmeWIjyZ0bU/Z5u8yf3QFnpg3ERDn0Lt9ssG1NxjBQ9MW71of7Im g97l6GlCctze6viy1+rYp8saa4phvb0BLM9qzxw5zfa/0QwdkWYw6+lkDvqUR+Qhn3dN eiOjHWWNiMI2eBLm4kj1zCbpNr/Kh91B5ThG3dmifXoZ0qnCiDtaOxuO60o4S7z2SMku W6Mje3UHLHxv8TBA1M1qcjxtVQvuYKMPMySW5jL2YZzkjIPIcUGGLqwxPWq4cjO9Q+++ 9y+WGX2aqzOBF99oN65JLQdKHXVfV7MfizsiGyRJmQSPuo7UtChzIUAAou70FL06RlCU 9x2w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="TGmqu/Jb"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-8500-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8500-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 4fb4d7f45d1cf-57a31b80fb8si5649060a12.2.2024.06.04.16.12.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 16:12:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-8500-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=@kernel.org header.s=k20201202 header.b="TGmqu/Jb"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-8500-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8500-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 BF0391F233D2 for ; Tue, 4 Jun 2024 23:12:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5572614D2B8; Tue, 4 Jun 2024 23:12:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TGmqu/Jb" X-Original-To: linux-wireless@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2FEB214B077 for ; Tue, 4 Jun 2024 23:12:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717542733; cv=none; b=WiX3oc/Gvttj1Miz2alFPndL1rx/iPbtBcvYLCT8LTJqqMIt360oALqkZx0FffKYFD6rcv56bgvjr/vFaDzwwm//wq42vG547u4jAaJA9ZnY51UCJgjAScPw6IMs6lMrPVete0oFcN367KSwWZjHJTNTjdfQFx8QHgyzIaA2EDU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717542733; c=relaxed/simple; bh=Nncx+VVQYs0qKAe+KYVC/Kq04OFO3sM0r6o5Yfj4L+Y=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=r0yU4YTS6Dlp6hoNm9cwmKWC1Or2+4Ku9S8kfy8UvrJtU3D33mlBl92xuQgU8PvO5+3VC3vhWC+1ZhV+wlAexsAZkFAFoGtKdXpwad75YHROviylbQp7NuZNKop6xJBjOoIUFdbstdIFHZiWegSxpWQVCHimIdW4M6IxgmzvqlQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TGmqu/Jb; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFB3FC4AF08 for ; Tue, 4 Jun 2024 23:12:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717542732; bh=Nncx+VVQYs0qKAe+KYVC/Kq04OFO3sM0r6o5Yfj4L+Y=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=TGmqu/JbAds/BOUP6NJv9uDpQdDc/BI2Phd0s9JNPrcmBLG2b00Ut5yLxZHbL7SSB krisyQgobjXaZorWf4l7kqFMtC+Od9Zts3EgMdfjex8DS3FmGHFvSdyAojCYOrl0ox bW3YgkUNt/eCOBfMRZxWUmcKMDnyOT4z5w42AYSLicrupkQ023phB9VeWrRXzrm5j6 bN6d4b4NkRj3xE3WVZWNKCvVIcEtd+0+g2LrdApNE85ph2nWB1gwLoDqzFxTtqBvNH H9oFsM9keKhxve5qd7O18oO+7T0TDa3+pkPg7ZaHuIW4d+tFXpH0QfGBWRyGUK+mk1 QAZeW5Wu62EUQ== Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-57a861f8faaso134060a12.0 for ; Tue, 04 Jun 2024 16:12:12 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCXqERhc89Orvgs86eUcDFBOAfKloV1Rb6yrSJ3+p7hbEj/2Yg2Op+CuqNRM8s+PjekVcJDkR5OeJ37TvG+bW3o4fhkb1T7w7KZ0VpQZHLg= X-Gm-Message-State: AOJu0YwMJN8g/CS+f96NMRpyyAzJcjhzqlBREKWWgZ8XttnYItqjhUNt ZpnSbzkZFUlEXdmoxWO+bZogSVtM+D/nQY6HRHOyKl0+XBL4tiMbMyQv9ipTo6OPZLcR9OtHBue Mzf++i0wje04uLt+OSszohZBDnrg= X-Received: by 2002:a17:907:90d5:b0:a68:5676:275d with SMTP id a640c23a62f3a-a69a026fc59mr36867566b.6.1717542731220; Tue, 04 Jun 2024 16:12:11 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240523112131.31437-1-mingyen.hsieh@mediatek.com> In-Reply-To: <20240523112131.31437-1-mingyen.hsieh@mediatek.com> From: Sean Wang Date: Tue, 4 Jun 2024 16:11:58 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] wifi: mt76: mt792x: fix scheduler interference in drv own process To: Mingyen Hsieh Cc: nbd@nbd.name, lorenzo@kernel.org, deren.wu@mediatek.com, Sean.Wang@mediatek.com, Soul.Huang@mediatek.com, Leon.Yen@mediatek.com, Eric-SY.Chang@mediatek.com, km.lin@mediatek.com, robin.chiu@mediatek.com, ch.yeh@mediatek.com, posh.sun@mediatek.com, Quan.Zhou@mediatek.com, Ryder.Lee@mediatek.com, Shayne.Chen@mediatek.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org, Michael Lo Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Thu, May 23, 2024 at 4:21=E2=80=AFAM Mingyen Hsieh wrote: > > From: Michael Lo > > Add some time to wait for LP engine to complete its operation > before polling pmctrl register. > > Signed-off-by: Michael Lo > Signed-off-by: Ming Yen Hsieh The new patch is an improvement over v1 as it avoids unnecessary waiting in specific cases, such as when users are forced to disable ASPM or when the host doesn't support ASPM as I suggested in v1. Thus, Acked-by: Sean Wang > --- > v2: change funcion and variable naming. > --- > > drivers/net/wireless/mediatek/mt76/mt76.h | 1 + > .../net/wireless/mediatek/mt76/mt7921/pci.c | 3 +++ > .../net/wireless/mediatek/mt76/mt7925/pci.c | 3 +++ > drivers/net/wireless/mediatek/mt76/mt792x.h | 1 + > .../net/wireless/mediatek/mt76/mt792x_core.c | 4 ++++ > drivers/net/wireless/mediatek/mt76/pci.c | 23 +++++++++++++++++++ > 6 files changed, 35 insertions(+) > > diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wire= less/mediatek/mt76/mt76.h > index 11b9f22ca7f3..4168104fa141 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt76.h > +++ b/drivers/net/wireless/mediatek/mt76/mt76.h > @@ -1081,6 +1081,7 @@ bool ____mt76_poll_msec(struct mt76_dev *dev, u32 o= ffset, u32 mask, u32 val, > > void mt76_mmio_init(struct mt76_dev *dev, void __iomem *regs); > void mt76_pci_disable_aspm(struct pci_dev *pdev); > +bool mt76_pci_aspm_supported(struct pci_dev *pdev); > > static inline u16 mt76_chip(struct mt76_dev *dev) > { > diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/ne= t/wireless/mediatek/mt76/mt7921/pci.c > index f768e9389ac6..ca54ae7deb54 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c > +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c > @@ -339,6 +339,9 @@ static int mt7921_pci_probe(struct pci_dev *pdev, > bus_ops->rmw =3D mt7921_rmw; > dev->mt76.bus =3D bus_ops; > > + if (!mt7921_disable_aspm && mt76_pci_aspm_supported(pdev)) > + dev->aspm_supported =3D true; > + > ret =3D mt792xe_mcu_fw_pmctrl(dev); > if (ret) > goto err_free_dev; > diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/pci.c b/drivers/ne= t/wireless/mediatek/mt76/mt7925/pci.c > index 07b74d492ce1..2449b3e6c396 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt7925/pci.c > +++ b/drivers/net/wireless/mediatek/mt76/mt7925/pci.c > @@ -373,6 +373,9 @@ static int mt7925_pci_probe(struct pci_dev *pdev, > bus_ops->rmw =3D mt7925_rmw; > dev->mt76.bus =3D bus_ops; > > + if (!mt7925_disable_aspm && mt76_pci_aspm_supported(pdev)) > + dev->aspm_supported =3D true; > + > ret =3D __mt792x_mcu_fw_pmctrl(dev); > if (ret) > goto err_free_dev; > diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wi= reless/mediatek/mt76/mt792x.h > index 20578497a405..c2c42e5d650a 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt792x.h > +++ b/drivers/net/wireless/mediatek/mt76/mt792x.h > @@ -190,6 +190,7 @@ struct mt792x_dev { > bool fw_assert:1; > bool has_eht:1; > bool regd_in_progress:1; > + bool aspm_supported:1; > wait_queue_head_t wait; > > struct work_struct init_work; > diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/n= et/wireless/mediatek/mt76/mt792x_core.c > index a405af8d9052..588b24edfdd9 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c > +++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c > @@ -766,6 +766,10 @@ int __mt792xe_mcu_drv_pmctrl(struct mt792x_dev *dev) > > for (i =3D 0; i < MT792x_DRV_OWN_RETRY_COUNT; i++) { > mt76_wr(dev, MT_CONN_ON_LPCTL, PCIE_LPCR_HOST_CLR_OWN); > + > + if (dev->aspm_supported) > + usleep_range(2000, 3000); > + > if (mt76_poll_msec_tick(dev, MT_CONN_ON_LPCTL, > PCIE_LPCR_HOST_OWN_SYNC, 0, 50, 1= )) > break; > diff --git a/drivers/net/wireless/mediatek/mt76/pci.c b/drivers/net/wirel= ess/mediatek/mt76/pci.c > index 4c1c159fbb62..b5031ca7f73f 100644 > --- a/drivers/net/wireless/mediatek/mt76/pci.c > +++ b/drivers/net/wireless/mediatek/mt76/pci.c > @@ -45,3 +45,26 @@ void mt76_pci_disable_aspm(struct pci_dev *pdev) > aspm_conf); > } > EXPORT_SYMBOL_GPL(mt76_pci_disable_aspm); > + > +bool mt76_pci_aspm_supported(struct pci_dev *pdev) > +{ > + struct pci_dev *parent =3D pdev->bus->self; > + u16 aspm_conf, parent_aspm_conf =3D 0; > + bool result =3D true; > + > + pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &aspm_conf); > + aspm_conf &=3D PCI_EXP_LNKCTL_ASPMC; > + if (parent) { > + pcie_capability_read_word(parent, PCI_EXP_LNKCTL, > + &parent_aspm_conf); > + parent_aspm_conf &=3D PCI_EXP_LNKCTL_ASPMC; > + } > + > + if (!aspm_conf && (!parent || !parent_aspm_conf)) { > + /* aspm already disabled */ > + result =3D false; > + } > + > + return result; > +} > +EXPORT_SYMBOL_GPL(mt76_pci_aspm_supported); > -- > 2.18.0 > >