Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4073188ybg; Fri, 25 Oct 2019 12:56:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmC2M7EW5TpSHnB7fxf31vYOR+7W/qMl0VyAUy4+TAXa8de0/49X//zSFScAFkTVoyb75V X-Received: by 2002:a50:cb86:: with SMTP id k6mr5995073edi.270.1572033399655; Fri, 25 Oct 2019 12:56:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572033399; cv=none; d=google.com; s=arc-20160816; b=EL45gdi8LmQc9hB6Fvr7jnRS4lGh7UuPTWIEAn35QTlWsd+04dU2O4F+Yvp1gDHkoD SgLGKfjYkhWHtctDAD0Ax773AyL1cKKJosVhG2hQqkYw9wdz5YC46E/Yw7oPeqQMTz0h fQavd/OSjDJfoygDs0z3xLxP2jWBUcU4ixhR5N9PTd4RLhn84+KFunAP1e7OUQLZmIAB Fkr6OOzKsVlnbtr9gYGRpEQEtYbm1OagPs/weCL1V4tvFs44jsdCZ7sGgt6xqtV8I3Ec XHlEJveagKFG9YgZGqO4pHLprqES9qgDIA2zHMZCxOPFBHv7Smsh162iMSmiLDVfeuxp EK2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=cFHU09wBjpsgLwHf44LiEP8jLq8cbX4indFXQskgc2E=; b=ui2NNJVfYdoodGUusVN9O1VWZ1J18X6+A9ekjyNN83wXgMbelh4deW4Z3fmiLkR3J3 GmH3y1OaiN5/Q6m008G2zrnPFRfUWIIz7iaoM48isn+zoOuvdd0DK1xhWW7jbXZjIo8L JOEMEP/o/FaupwoeS7Vis9F2PvOovR2qGGAuuSKOZwTqBTuez/mLsahVyVMd7xY3OLqf ArxMHmz0n8wgYZyeT/9bdG5um5S7YVpQu5dmy6mArlWpZCtYdAyPGGaK1gPn+3+JYtJv Id/d+wPvIptE4xi1m29vyVKGo32xcvPOngcQQd/mwz6Msm3HX9NcV2uKHFv5s64vIPEy MJ+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rk26si1798696ejb.303.2019.10.25.12.56.13; Fri, 25 Oct 2019 12:56:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502143AbfJYLqh (ORCPT + 99 others); Fri, 25 Oct 2019 07:46:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44626 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502130AbfJYLqh (ORCPT ); Fri, 25 Oct 2019 07:46:37 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 37622859FE for ; Fri, 25 Oct 2019 11:46:36 +0000 (UTC) Received: by mail-wm1-f69.google.com with SMTP id o8so999443wmc.2 for ; Fri, 25 Oct 2019 04:46:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=cFHU09wBjpsgLwHf44LiEP8jLq8cbX4indFXQskgc2E=; b=WbleKMF+PCj/QZTmU6C6idMOsgnZUcYF5Flrvmekr9uojnG4n5K+ouRE6UIUFLJei9 ZpMItQdSsoz97sXTBZpnh5FaZErOtsC+CAp62DhmYPTP94bkzJJ3FXWt94Mj047LJb// t0ebcoDNuiDMZ99iuUJ+kVPT8m4dn1fqZ0gxgw267mW/WlE4IWlBg+4syVDlhaCBE9sK N3PPSWaKrn/UVRfOPPaxMHIA3migjjiyffGJVqJIicznlX7BR3fR/Gi58b+eP3LrvLnJ rKn35lZrgAqQu3TJosiT2ZfVEc0GO1WwYiAoznFkn7JZ3mC2fXDG5iCPbVc0zVCXNP2m nurg== X-Gm-Message-State: APjAAAXPPGnsx93ExkBQ0DZRiN9oAgmii6YS8vmFL1PRJ0GrjLLEL9iC QLLA1IhxJ2oMO1qTO/uRvrkzRnTR7ZhqGRcbEmSHcjhFkX9o04hU4Gv7MF/f5OJKgtW4D10f6zL hcvxfH0j8LJBQhVCOAcE0G8+SPWE= X-Received: by 2002:adf:ce87:: with SMTP id r7mr2609082wrn.307.1572003994711; Fri, 25 Oct 2019 04:46:34 -0700 (PDT) X-Received: by 2002:adf:ce87:: with SMTP id r7mr2609039wrn.307.1572003994334; Fri, 25 Oct 2019 04:46:34 -0700 (PDT) Received: from localhost.localdomain (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id q14sm2521539wre.27.2019.10.25.04.46.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 04:46:33 -0700 (PDT) Date: Fri, 25 Oct 2019 13:46:31 +0200 From: Lorenzo Bianconi To: Heiner Kallweit Cc: Lorenzo Bianconi , kvalo@codeaurora.org, linux-wireless@vger.kernel.org, nbd@nbd.name, sgruszka@redhat.com, oleksandr@natalenko.name, netdev@vger.kernel.org, "linux-pci@vger.kernel.org" , sean.wang@mediatek.com, ryder.lee@mediatek.com, royluo@google.com Subject: Re: [PATCH wireless-drivers 1/2] mt76: mt76x2e: disable pcie_aspm by default Message-ID: <20191025114631.GB2898@localhost.localdomain> References: <5924c8eb-7269-b8ef-ad0e-957104645638@gmail.com> <20191024215451.GA30822@lore-desk.lan> <9cac34a5-0bfe-0443-503f-218210dab4d6@gmail.com> <20191024230747.GA30614@lore-desk.lan> <1de75f53-ab28-9951-092c-19a854ef4907@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="cmJC7u66zC7hs+87" Content-Disposition: inline In-Reply-To: <1de75f53-ab28-9951-092c-19a854ef4907@gmail.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org --cmJC7u66zC7hs+87 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > On 25.10.2019 01:07, Lorenzo Bianconi wrote: > >> On 24.10.2019 23:54, Lorenzo Bianconi wrote: > >>>> On 24.10.2019 00:23, Lorenzo Bianconi wrote: > >>>>> On same device (e.g. U7612E-H1) PCIE_ASPM causes continuous mcu han= gs and > >>>>> instability and so let's disable PCIE_ASPM by default. This patch h= as > >>>>> been successfully tested on U7612E-H1 mini-pice card > >>>>> > >>>>> Signed-off-by: Felix Fietkau > >>>>> Signed-off-by: Lorenzo Bianconi > >>>>> --- > >>>>> drivers/net/wireless/mediatek/mt76/mmio.c | 47 +++++++++++++++= ++++ > >>>>> drivers/net/wireless/mediatek/mt76/mt76.h | 1 + > >>>>> .../net/wireless/mediatek/mt76/mt76x2/pci.c | 2 + > >>>>> 3 files changed, 50 insertions(+) > >>>>> > >>> > >>> [...] > >>> > >>>>> + > >>>>> + if (parent) > >>>>> + pcie_capability_clear_word(parent, PCI_EXP_LNKCTL, > >>>>> + aspm_conf); > >>>> > >>>> + linux-pci mailing list > >>> > >>> Hi Heiner, > >>> > >>>> > >>>> All this seems to be legacy code copied from e1000e. > >>>> Fiddling with the low-level PCI(e) registers should be left to the > >>>> PCI core. It shouldn't be needed here, a simple call to > >>>> pci_disable_link_state() should be sufficient. Note that this functi= on > >>>> has a return value meanwhile that you can check instead of reading > >>>> back low-level registers. > >>> > >>> ack, I will add it to v2 > >>> > >>>> If BIOS forbids that OS changes ASPM settings, then this should be > >>>> respected (like PCI core does). Instead the network chip may provide > >>>> the option to configure whether it activates certain ASPM (sub-)stat= es > >>>> or not. We went through a similar exercise with the r8169 driver, > >>>> you can check how it's done there. > >>> > >>> looking at the vendor sdk (at least in the version I currently have) = there are > >>> no particular ASPM configurations, it just optionally disables it wri= ting directly > >>> in pci registers. > >>> Moreover there are multiple drivers that are currently using this app= roach: > >>> - ath9k in ath_pci_aspm_init() > >>> - tg3 in tg3_chip_reset() > >>> - e1000e in __e1000e_disable_aspm() > >>> - r8169 in rtl_enable_clock_request()/rtl_disable_clock_request() > >>> > >> All these drivers include quite some legacy code. I can mainly speak f= or r8169: > >> First versions of the driver are almost as old as Linux. And even thou= gh I > >> refactored most of the driver still some legacy code for older chip ve= rsions > >> (like the two functions you mentioned) is included. > >> > >>> Is disabling the ASPM for the system the only option to make this min= ipcie > >>> work? > >>> > >> > >> No. What we do in r8169: > >> > >> - call pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_ST= ATE_L1) > >> - If it returns 0, then ASPM (including the L1 sub-states) is disabled. > >> - If it returns an errno, then disabling ASPM failed (most likely due = to > >> BIOS forbidding ASPM changes - pci_disable_link_state will spit out > >> a related warning). In this case r8169 configures the chip to not in= itiate > >> transitions to L0s/L1 (the other end of the link may still try to en= ter > >> ASPM states). See rtl_hw_aspm_clkreq_enable(). That's sufficient > >> to avoid the ASPM-related problems with certain versions of this chi= p. > >> Maybe your HW provides similar functionality. > >=20 > > yep, I looked at rtl_hw_aspm_clkreq_enable. This is more or less what I= did but > > unfortunately there is no specific code or documentation I can use for = mt76x2e. > > So as last chance I decided to disable ASPM directly (in this way the c= hip is > > working fine). > > Do you think a kernel parameter to disable ASPM directly would be accep= table? > >=20 > Module parameters are not the preferred approach, even though some mainta= iners > may consider it acceptable. I think it should be ok if you disable ASPM p= er > default. Who wants ASPM can enable the individual states via brand-new > sysfs attributes (provided BIOS allows OS to control ASPM). > However changing ASPM settings via direct register writes may cause > inconsistencies between PCI core and actual settings. > I'm not sure whether there's any general best practice how to deal with t= he > scenario that a device misbehaves with ASPM enabled and OS isn't allowed = to > change ASPM settings.=20 > Maybe the PCI guys can advise on these points. Hi Heiner, I reviewed the mtk sdk and it seems mt7662/mt7612/mt7602 series does not have hw pcie ps support (not sure if it just not implemented or so). In my scenario without disabling ASPM the card does not work at all, so I guess we can proceed with current approach and then try to understand if we can do something better. What do you think? @Ryder, Sean: do you have any hint on this topic? Regards, Lorenzo >=20 > > Regards, > > Lorenzo > >=20 > Heiner >=20 > >> > >>> Regards, > >>> Lorenzo > >>> > >> Heiner > >> > >>>> > >>>>> +} > >>>>> +EXPORT_SYMBOL_GPL(mt76_mmio_disable_aspm); > >>>>> + > >>>>> void mt76_mmio_init(struct mt76_dev *dev, void __iomem *regs) > >>>>> { > >>>>> static const struct mt76_bus_ops mt76_mmio_ops =3D { > >>>>> diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/ne= t/wireless/mediatek/mt76/mt76.h > >>>>> index 570c159515a0..962812b6247d 100644 > >>>>> --- a/drivers/net/wireless/mediatek/mt76/mt76.h > >>>>> +++ b/drivers/net/wireless/mediatek/mt76/mt76.h > >>>>> @@ -578,6 +578,7 @@ bool __mt76_poll_msec(struct mt76_dev *dev, u32= offset, u32 mask, u32 val, > >>>>> #define mt76_poll_msec(dev, ...) __mt76_poll_msec(&((dev)->mt76), = __VA_ARGS__) > >>>>> =20 > >>>>> void mt76_mmio_init(struct mt76_dev *dev, void __iomem *regs); > >>>>> +void mt76_mmio_disable_aspm(struct pci_dev *pdev); > >>>>> =20 > >>>>> static inline u16 mt76_chip(struct mt76_dev *dev) > >>>>> { > >>>>> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c b/driv= ers/net/wireless/mediatek/mt76/mt76x2/pci.c > >>>>> index 73c3104f8858..264bef87e5c7 100644 > >>>>> --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c > >>>>> +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c > >>>>> @@ -81,6 +81,8 @@ mt76pci_probe(struct pci_dev *pdev, const struct = pci_device_id *id) > >>>>> /* RG_SSUSB_CDR_BR_PE1D =3D 0x3 */ > >>>>> mt76_rmw_field(dev, 0x15c58, 0x3 << 6, 0x3); > >>>>> =20 > >>>>> + mt76_mmio_disable_aspm(pdev); > >>>>> + > >>>>> return 0; > >>>>> =20 > >>>>> error: > >>>>> > >>>> > >> >=20 --cmJC7u66zC7hs+87 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCXbLgkwAKCRA6cBh0uS2t rHfnAQCLoD02kio19gy+U8XToasZDcPIadAlFlX2/iy9cPWZRgEAnbBv05bpmG/K f3evMl5rOPE8S4PDCo5o/s6KV1rCHgg= =06x3 -----END PGP SIGNATURE----- --cmJC7u66zC7hs+87--