[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250928062756.2188329-2-yilun.xu@linux.intel.com>
Date: Sun, 28 Sep 2025 14:27:54 +0800
From: Xu Yilun <yilun.xu@...ux.intel.com>
To: linux-coco@...ts.linux.dev,
linux-pci@...r.kernel.org,
dan.j.williams@...el.com
Cc: yilun.xu@...el.com,
yilun.xu@...ux.intel.com,
baolu.lu@...ux.intel.com,
zhenzhong.duan@...el.com,
aneesh.kumar@...nel.org,
bhelgaas@...gle.com,
aik@....com,
linux-kernel@...r.kernel.org
Subject: [PATCH 1/3] PCI/IDE: Add/export mini helpers for platform TSM drivers
These mini helpers are mainly for platform TSM drivers to setup root
port side configuration. Root port side IDE settings may require
platform specific firmware calls (e.g. TDX Connect [1]) so could not use
pci_ide_stream_setup(), but may still share these mini helpers cause
they also refer to definitions in IDE specification.
[1]: https://lore.kernel.org/linux-coco/20250919142237.418648-28-dan.j.williams@intel.com/
Signed-off-by: Xu Yilun <yilun.xu@...ux.intel.com>
---
include/linux/pci-ide.h | 6 ++++++
drivers/pci/ide.c | 8 +++-----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/include/linux/pci-ide.h b/include/linux/pci-ide.h
index a30f9460b04a..5adbd8b81f65 100644
--- a/include/linux/pci-ide.h
+++ b/include/linux/pci-ide.h
@@ -6,6 +6,11 @@
#ifndef __PCI_IDE_H__
#define __PCI_IDE_H__
+#define PREP_PCI_IDE_SEL_RID_2(base, domain) \
+ (FIELD_PREP(PCI_IDE_SEL_RID_2_VALID, 1) | \
+ FIELD_PREP(PCI_IDE_SEL_RID_2_BASE, (base)) | \
+ FIELD_PREP(PCI_IDE_SEL_RID_2_SEG, (domain)))
+
enum pci_ide_partner_select {
PCI_IDE_EP,
PCI_IDE_RP,
@@ -61,6 +66,7 @@ struct pci_ide {
struct tsm_dev *tsm_dev;
};
+int pci_ide_domain(struct pci_dev *pdev);
struct pci_ide_partner *pci_ide_to_settings(struct pci_dev *pdev, struct pci_ide *ide);
struct pci_ide *pci_ide_stream_alloc(struct pci_dev *pdev);
void pci_ide_stream_free(struct pci_ide *ide);
diff --git a/drivers/pci/ide.c b/drivers/pci/ide.c
index 10603f2d2319..7633b8e52399 100644
--- a/drivers/pci/ide.c
+++ b/drivers/pci/ide.c
@@ -345,12 +345,13 @@ void pci_ide_stream_unregister(struct pci_ide *ide)
}
EXPORT_SYMBOL_GPL(pci_ide_stream_unregister);
-static int pci_ide_domain(struct pci_dev *pdev)
+int pci_ide_domain(struct pci_dev *pdev)
{
if (pdev->fm_enabled)
return pci_domain_nr(pdev->bus);
return 0;
}
+EXPORT_SYMBOL_GPL(pci_ide_domain);
struct pci_ide_partner *pci_ide_to_settings(struct pci_dev *pdev, struct pci_ide *ide)
{
@@ -420,10 +421,7 @@ void pci_ide_stream_setup(struct pci_dev *pdev, struct pci_ide *ide)
val = FIELD_PREP(PCI_IDE_SEL_RID_1_LIMIT, settings->rid_end);
pci_write_config_dword(pdev, pos + PCI_IDE_SEL_RID_1, val);
- val = FIELD_PREP(PCI_IDE_SEL_RID_2_VALID, 1) |
- FIELD_PREP(PCI_IDE_SEL_RID_2_BASE, settings->rid_start) |
- FIELD_PREP(PCI_IDE_SEL_RID_2_SEG, pci_ide_domain(pdev));
-
+ val = PREP_PCI_IDE_SEL_RID_2(settings->rid_start, pci_ide_domain(pdev));
pci_write_config_dword(pdev, pos + PCI_IDE_SEL_RID_2, val);
/*
--
2.25.1
Powered by blists - more mailing lists