From patchwork Sat Nov 4 13:32:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuai Xue X-Patchwork-Id: 161588 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1651617vqu; Sat, 4 Nov 2023 06:32:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGA0w2hZs1Pr9CDAmef9H0nonhyDJkhnHbylJGOlsqi/57NVRJBuUh5crjM33MMyehcO/OU X-Received: by 2002:a05:6871:4cc4:b0:1d6:57f0:7237 with SMTP id ya4-20020a0568714cc400b001d657f07237mr2393460oab.17.1699104770135; Sat, 04 Nov 2023 06:32:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699104770; cv=none; d=google.com; s=arc-20160816; b=vwQjrwK75AJTcLsrRHXnbbtgVLxX5ehX7vF3ogWuuVYkv/2IFbjf2plbtxqEh0dyOU pYaU48FtIXP1tt0s4pEvxt8vtaT1oyYVDiiWRM2vkpD/aWgOitKCnL4lLIR3iGJaP/mR k3yHLnXv2DlX79Qru8I0NSuhi0q79z4uBW3Rk+YHJpNjqHZM055gc4hbjzq+3ikmQ46J 6++U/IDCq4Y4XvdzbBVwaZonKoEkZPGeDYmM8x0xvsszuOgJu30DZ6GhaQ9rkKB0MYOK +Sh6rLOmbXhqZ9uF9Pes/oN6CYH0PYUfHl6z4IXc4M/1/jzAVeIMzXYJYRGLHAgRHnIz JXuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=XubGEykWcMvXxLXRijYprvDABNtx3rDgfmIFehYqOzc=; fh=JTFo9jksM3iJMk5d1s6bsW43YoyiK0Zjg5tW6S+IgPI=; b=sJGiqINBNfVtP3pRm1n/k6qPxCKZhczd9B9lAwGM6bqv3gM1CPRJaQWVXbZSlnv04s +92h1oYkxCFyl/cFY+K/s/YpniKQgnteiRtvbSlxzjsF97ROtvN88vyRmr+STuXmw0HU SQ149+o5e5immNVQqBwFBYT3U8w6/aK6+UQAYcrJYpkn7QxEtmGvN8ZZ4JdLSXF2O4uS 3dFOl4FuiiyqGE4Rmvk0ZHDiLoTFT6zDuwv5+Ot0r0/dBL4xm3ujO29+6JyHIhYXGeDp iE70KOuN21S08eHfiT9S+oPnmBdMIjXGhGHtWWy7mlz1yOeajJDyGlaAPuLzQU4UXJ/T fuYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id he25-20020a056870799900b001dd6b09d020si1573803oab.155.2023.11.04.06.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 06:32:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D75898040EBF; Sat, 4 Nov 2023 06:32:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232297AbjKDNcm (ORCPT + 35 others); Sat, 4 Nov 2023 09:32:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232234AbjKDNci (ORCPT ); Sat, 4 Nov 2023 09:32:38 -0400 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDE6ED42; Sat, 4 Nov 2023 06:32:33 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=xueshuai@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0VvcM-OX_1699104747; Received: from localhost.localdomain(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0VvcM-OX_1699104747) by smtp.aliyun-inc.com; Sat, 04 Nov 2023 21:32:28 +0800 From: Shuai Xue To: kaishen@linux.alibaba.com, helgaas@kernel.org, yangyicong@huawei.com, will@kernel.org, Jonathan.Cameron@huawei.com, baolin.wang@linux.alibaba.com, robin.murphy@arm.com Cc: chengyou@linux.alibaba.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, rdunlap@infradead.org, mark.rutland@arm.com, zhuo.song@linux.alibaba.com, xueshuai@linux.alibaba.com, renyu.zj@linux.alibaba.com Subject: [PATCH v10 3/5] PCI: move pci_clear_and_set_dword helper to pci header Date: Sat, 4 Nov 2023 21:32:14 +0800 Message-Id: <20231104133216.42056-4-xueshuai@linux.alibaba.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231104133216.42056-1-xueshuai@linux.alibaba.com> References: <20231104133216.42056-1-xueshuai@linux.alibaba.com> MIME-Version: 1.0 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Sat, 04 Nov 2023 06:32:48 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781640483378000012 X-GMAIL-MSGID: 1781640483378000012 The clear and set pattern is commonly used for accessing pci config, move the helper pci_clear_and_set_dword from aspm.c into pci header. Signed-off-by: Shuai Xue --- drivers/pci/access.c | 12 ++++++++++++ drivers/pci/pcie/aspm.c | 11 ----------- include/linux/pci.h | 2 ++ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/pci/access.c b/drivers/pci/access.c index 6554a2e89d36..526360481d99 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c @@ -598,3 +598,15 @@ int pci_write_config_dword(const struct pci_dev *dev, int where, return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val); } EXPORT_SYMBOL(pci_write_config_dword); + +void pci_clear_and_set_dword(const struct pci_dev *dev, int pos, + u32 clear, u32 set) +{ + u32 val; + + pci_read_config_dword(dev, pos, &val); + val &= ~clear; + val |= set; + pci_write_config_dword(dev, pos, val); +} +EXPORT_SYMBOL(pci_clear_and_set_dword); diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 1bf630059264..f4e64fedc048 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -423,17 +423,6 @@ static void pcie_aspm_check_latency(struct pci_dev *endpoint) } } -static void pci_clear_and_set_dword(struct pci_dev *pdev, int pos, - u32 clear, u32 set) -{ - u32 val; - - pci_read_config_dword(pdev, pos, &val); - val &= ~clear; - val |= set; - pci_write_config_dword(pdev, pos, val); -} - /* Calculate L1.2 PM substate timing parameters */ static void aspm_calc_l12_info(struct pcie_link_state *link, u32 parent_l1ss_cap, u32 child_l1ss_cap) diff --git a/include/linux/pci.h b/include/linux/pci.h index 8c7c2c3c6c65..271f30fd7ca4 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1213,6 +1213,8 @@ int pci_read_config_dword(const struct pci_dev *dev, int where, u32 *val); int pci_write_config_byte(const struct pci_dev *dev, int where, u8 val); int pci_write_config_word(const struct pci_dev *dev, int where, u16 val); int pci_write_config_dword(const struct pci_dev *dev, int where, u32 val); +void pci_clear_and_set_dword(const struct pci_dev *dev, int pos, + u32 clear, u32 set); int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val); int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val);