Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp922684lqp; Thu, 23 May 2024 04:21:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWMiCUNISih6ugqwJ/EJ7bY06+NkU5ujquEWDUBSg1s2eSWZcRcDybJEOlGRuhzt13iGqRdGDoCboM7iMrhoTigX7w2J0OeIWxjrzCYeQ== X-Google-Smtp-Source: AGHT+IE5xi5z86DcBL4zGZ47JGupdEuMeBJL8xWaIYKj8Ux4KZoPJGjlQaPj5BqYMXlaElukVer5 X-Received: by 2002:a5b:992:0:b0:de5:5706:b958 with SMTP id 3f1490d57ef6-df4e0d598a7mr4897383276.38.1716463310624; Thu, 23 May 2024 04:21:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716463310; cv=pass; d=google.com; s=arc-20160816; b=jvAcY1dISc6Cn2oK8Tmp7I/6cqUMU1dYWc+DIA7Gb12GEBxTEBF2Dj4HRz4Dcchlq3 uP85ilzS7JIRn890HYRd7p7Sts67Gp8SC6Pf6Oojj2a3fzfUjPfnUV8S2c8ZHZzdQ1sH 5LMowvwZXLMyPW8u79KPMG84TSUKKAar3/hXa3XWAosWy3LkLfvn1lKHuwt+ajLCeUCC DDUdvdEfZRavL3riZXBbDZrLl/1KR86cIH4bRxIgE8P9SFlpu/vDt5fq3SSYh5+7sJU0 mBUhwWUN9x8LFc662Hw3X7LW0FwI0dugLligG0ez4bc9inDTLM52y8mhtmWHA6N80TJX AAKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from:dkim-signature; bh=MH6Kz0kTC3Ij/F9zYIlY7zkjiUFQcykeZ8kvq7UsVlE=; fh=4hAlqv/CEM5vo41/lVk0pILVyMzVJJ9DxLu4wHTBsNY=; b=t8bOlNhtuqzmPcsjk+HNUitC6dIqBL76tHwZsxfOkaLT6wUSmqf4ecyivONd7361wR KmIABawpxCR9ynbSiZQ5hNsWJhEm6cgqSUGd0GeWhpMkLnTfPUOMoGWbB4pnGSWegX/k xEQqtrBPTz8xHCM+/71y5JjLDiHj8oiu9w58Cv9RGG6m6+KBheCCTL+Gv6SmwGeYsUcd KFcnnYBwrvMBEre4iJh2NPO/Sp/sWNnvDtpx2iLeHijI6LCHzmwBxX2QtzHGmRRdxpKA IxQpPACB1xxl0K5pLPkFt50APPkmmlGGnT4xxobmEF0nBqvv1y07zNt5F4pPUQYIFnwl Hnkg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=BpQuPZEX; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-wireless+bounces-8005-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8005-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6aaf719b085si91954286d6.145.2024.05.23.04.21.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 04:21:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-8005-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=BpQuPZEX; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-wireless+bounces-8005-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8005-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 380EB1C2143D for ; Thu, 23 May 2024 11:21:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0855413C908; Thu, 23 May 2024 11:21:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="BpQuPZEX" X-Original-To: linux-wireless@vger.kernel.org Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 5D1122746F for ; Thu, 23 May 2024 11:21:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716463307; cv=none; b=pEGB6BWJE++kQN0KZHwKA+SosllxtD0e172RySy3han+NpDt/bxzPUiAEpcKCd+KXp0CD+wNMwW845kgGO16Xh6FqbZSGIRNjz93DvjnyjoER6B2Vjcmrvt21R0qZrJTEDrQZOkHi/vfxuJUY83HRapYSdSHuORvegvn8ubQsHc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716463307; c=relaxed/simple; bh=THjxO916dpNvAyHb0Ny7wskUlRlvM7Fw7RI/2XFiQaA=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=VvB8Se2bN/Tk9JCf299v8ky3GoSjNdNKDARtTPGKO8YUZKfnRogvO8ee75lOyu5Ea+bFElkeZ0Ptwls8NWUzMwyGIDmeKMgs70593375srJc9NhJYAwyps2h6oCmGiPxy+bTPcAXeNYSw2WMYgHNl6zIaiTDY8ITSrls4TDY1Fo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=BpQuPZEX; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com X-UUID: 9d2c8c1818f611ef8c37dd7afa272265-20240523 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=MH6Kz0kTC3Ij/F9zYIlY7zkjiUFQcykeZ8kvq7UsVlE=; b=BpQuPZEXuAWrEKaPZvwFWBT+dMO+BGjKRF2Wa1eDKcdM5wjXxptE3S4Go3lrXSEqylEknUSBQVo8Tu29ENcZciPcm0PTpFu1DFiGCQITog0xahRJUc+G2J5Oo3aIwX78fBk2gNwz9pnNrTjjRrJD3SzCkMhNlaY/acXqDwfQfxE=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.38,REQID:5fc588b4-77a7-4d42-ae5f-392847828c88,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:82c5f88,CLOUDID:6c803984-4f93-4875-95e7-8c66ea833d57,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1, SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 9d2c8c1818f611ef8c37dd7afa272265-20240523 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1088471961; Thu, 23 May 2024 19:21:34 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 23 May 2024 19:21:33 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 23 May 2024 19:21:33 +0800 From: Mingyen Hsieh To: , CC: , , , , , , , , , , , , , , Michael Lo , Ming Yen Hsieh Subject: [PATCH v2] wifi: mt76: mt792x: fix scheduler interference in drv own process Date: Thu, 23 May 2024 19:21:31 +0800 Message-ID: <20240523112131.31437-1-mingyen.hsieh@mediatek.com> X-Mailer: git-send-email 2.18.0 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain 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 --- 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/wireless/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 offset, 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/net/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 = mt7921_rmw; dev->mt76.bus = bus_ops; + if (!mt7921_disable_aspm && mt76_pci_aspm_supported(pdev)) + dev->aspm_supported = true; + ret = mt792xe_mcu_fw_pmctrl(dev); if (ret) goto err_free_dev; diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/pci.c b/drivers/net/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 = mt7925_rmw; dev->mt76.bus = bus_ops; + if (!mt7925_disable_aspm && mt76_pci_aspm_supported(pdev)) + dev->aspm_supported = true; + ret = __mt792x_mcu_fw_pmctrl(dev); if (ret) goto err_free_dev; diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/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/net/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 = 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/wireless/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 = pdev->bus->self; + u16 aspm_conf, parent_aspm_conf = 0; + bool result = true; + + pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &aspm_conf); + aspm_conf &= PCI_EXP_LNKCTL_ASPMC; + if (parent) { + pcie_capability_read_word(parent, PCI_EXP_LNKCTL, + &parent_aspm_conf); + parent_aspm_conf &= PCI_EXP_LNKCTL_ASPMC; + } + + if (!aspm_conf && (!parent || !parent_aspm_conf)) { + /* aspm already disabled */ + result = false; + } + + return result; +} +EXPORT_SYMBOL_GPL(mt76_pci_aspm_supported); -- 2.18.0