From: Shuai Xue <xueshuai@linux.alibaba.com>
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 [thread overview]
Message-ID: <20231104133216.42056-4-xueshuai@linux.alibaba.com> (raw)
In-Reply-To: <20231104133216.42056-1-xueshuai@linux.alibaba.com>
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 <xueshuai@linux.alibaba.com>
---
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);
--
2.39.3
next prev parent reply other threads:[~2023-11-04 13:32 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-04 13:32 [PATCH v10 0/5] drivers/perf: add Synopsys DesignWare PCIe PMU driver support Shuai Xue
2023-11-04 13:32 ` [PATCH v10 1/5] docs: perf: Add description for Synopsys DesignWare PCIe PMU driver Shuai Xue
2023-11-04 13:32 ` [PATCH v10 2/5] PCI: Add Alibaba Vendor ID to linux/pci_ids.h Shuai Xue
2023-11-04 13:32 ` Shuai Xue [this message]
2023-11-07 15:03 ` [PATCH v10 3/5] PCI: move pci_clear_and_set_dword helper to pci header Bjorn Helgaas
2023-11-08 0:51 ` Shuai Xue
2023-11-04 13:32 ` [PATCH v10 4/5] drivers/perf: add DesignWare PCIe PMU driver Shuai Xue
2023-11-15 0:07 ` Ilkka Koskinen
2023-11-15 1:26 ` Shuai Xue
2023-11-16 0:48 ` Ilkka Koskinen
2023-11-16 3:50 ` Ilkka Koskinen
2023-11-16 8:02 ` Shuai Xue
2023-11-16 19:02 ` Ilkka Koskinen
2023-11-04 13:32 ` [PATCH v10 5/5] MAINTAINERS: add maintainers for " Shuai Xue
2023-11-16 0:57 ` [PATCH v10 0/5] drivers/perf: add Synopsys DesignWare PCIe PMU driver support Ilkka Koskinen
2023-11-16 1:49 ` Shuai Xue
2023-11-16 2:42 ` Ilkka Koskinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231104133216.42056-4-xueshuai@linux.alibaba.com \
--to=xueshuai@linux.alibaba.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=chengyou@linux.alibaba.com \
--cc=helgaas@kernel.org \
--cc=kaishen@linux.alibaba.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=rdunlap@infradead.org \
--cc=renyu.zj@linux.alibaba.com \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
--cc=yangyicong@huawei.com \
--cc=zhuo.song@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®