2021-07-22 11:21:28

by Cai,Huoqing

[permalink] [raw]
Subject: [PATCH 0/2] PCI: Make use of PCI_DEVICE_XXX() helper function

Could make use of PCI_DEVICE_XXX() helper function

Cai Huoqing (2):
PCI: Make use of PCI_DEVICE_SUB/_CLASS() helper function
PCI: vmd: Make use of PCI_DEVICE_DATA() helper function

drivers/pci/controller/vmd.c | 38 +++++++++++++++----------------
drivers/pci/hotplug/cpqphp_core.c | 13 ++---------
drivers/pci/search.c | 14 ++----------
include/linux/pci_ids.h | 2 ++
4 files changed, 25 insertions(+), 42 deletions(-)

--
2.25.1


2021-07-22 11:21:47

by Cai,Huoqing

[permalink] [raw]
Subject: [PATCH 1/2] PCI: Make use of PCI_DEVICE_SUB/_CLASS() helper function

We could make use of PCI_DEVICE_SUB/CLASS() helper function

Signed-off-by: Cai Huoqing <[email protected]>
---
drivers/pci/hotplug/cpqphp_core.c | 13 ++-----------
drivers/pci/search.c | 14 ++------------
2 files changed, 4 insertions(+), 23 deletions(-)

diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index f99a7927e5a8..407206a233c8 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -1357,18 +1357,9 @@ static void __exit unload_cpqphpd(void)
}

static const struct pci_device_id hpcd_pci_tbl[] = {
- {
/* handle any PCI Hotplug controller */
- .class = ((PCI_CLASS_SYSTEM_PCI_HOTPLUG << 8) | 0x00),
- .class_mask = ~0,
-
- /* no matter who makes it */
- .vendor = PCI_ANY_ID,
- .device = PCI_ANY_ID,
- .subvendor = PCI_ANY_ID,
- .subdevice = PCI_ANY_ID,
-
- }, { /* end: all zeroes */ }
+ { PCI_DEVICE_CLASS(((PCI_CLASS_SYSTEM_PCI_HOTPLUG << 8) | 0x00), ~0) },
+ { /* end: all zeroes */ },
};

MODULE_DEVICE_TABLE(pci, hpcd_pci_tbl);
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index b4c138a6ec02..528c4fe33171 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -303,11 +303,7 @@ struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
struct pci_dev *from)
{
struct pci_device_id id = {
- .vendor = vendor,
- .device = device,
- .subvendor = ss_vendor,
- .subdevice = ss_device,
- };
+ PCI_DEVICE_SUB(vendor, device, ss_vendor, ss_device) };

return pci_get_dev_by_id(&id, from);
}
@@ -351,13 +347,7 @@ EXPORT_SYMBOL(pci_get_device);
struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from)
{
struct pci_device_id id = {
- .vendor = PCI_ANY_ID,
- .device = PCI_ANY_ID,
- .subvendor = PCI_ANY_ID,
- .subdevice = PCI_ANY_ID,
- .class_mask = PCI_ANY_ID,
- .class = class,
- };
+ PCI_DEVICE_CLASS(PCI_ANY_ID, class) };

return pci_get_dev_by_id(&id, from);
}
--
2.25.1

2021-07-22 11:22:09

by Cai,Huoqing

[permalink] [raw]
Subject: [PATCH 2/2] PCI: vmd: Make use of PCI_DEVICE_DATA() helper function

We could make use of PCI_DEVICE_DATA() helper function

Signed-off-by: Cai Huoqing <[email protected]>
---
drivers/pci/controller/vmd.c | 38 ++++++++++++++++++------------------
include/linux/pci_ids.h | 2 ++
2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
index e3fcdfec58b3..565681ed00a1 100644
--- a/drivers/pci/controller/vmd.c
+++ b/drivers/pci/controller/vmd.c
@@ -859,25 +859,25 @@ static int vmd_resume(struct device *dev)
static SIMPLE_DEV_PM_OPS(vmd_dev_pm_ops, vmd_suspend, vmd_resume);

static const struct pci_device_id vmd_ids[] = {
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_VMD_201D),
- .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP,},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_VMD_28C0),
- .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW |
- VMD_FEAT_HAS_BUS_RESTRICTIONS |
- VMD_FEAT_CAN_BYPASS_MSI_REMAP,},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x467f),
- .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP |
- VMD_FEAT_HAS_BUS_RESTRICTIONS |
- VMD_FEAT_OFFSET_FIRST_VECTOR,},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x4c3d),
- .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP |
- VMD_FEAT_HAS_BUS_RESTRICTIONS |
- VMD_FEAT_OFFSET_FIRST_VECTOR,},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_VMD_9A0B),
- .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP |
- VMD_FEAT_HAS_BUS_RESTRICTIONS |
- VMD_FEAT_OFFSET_FIRST_VECTOR,},
- {0,}
+ { PCI_DEVICE_DATA(INTEL, VMD_201D,
+ VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP) },
+ { PCI_DEVICE_DATA(INTEL, VMD_28C0,
+ VMD_FEAT_HAS_MEMBAR_SHADOW |
+ VMD_FEAT_HAS_BUS_RESTRICTIONS |
+ VMD_FEAT_CAN_BYPASS_MSI_REMAP) },
+ { PCI_DEVICE_DATA(INTEL, VMD_467F,
+ VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP |
+ VMD_FEAT_HAS_BUS_RESTRICTIONS |
+ VMD_FEAT_OFFSET_FIRST_VECTOR) },
+ { PCI_DEVICE_DATA(INTEL, VMD_4C3D,
+ VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP |
+ VMD_FEAT_HAS_BUS_RESTRICTIONS |
+ VMD_FEAT_OFFSET_FIRST_VECTOR) },
+ { PCI_DEVICE_DATA(INTEL, VMD_9A0B,
+ VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP |
+ VMD_FEAT_HAS_BUS_RESTRICTIONS |
+ VMD_FEAT_OFFSET_FIRST_VECTOR) },
+ { },
};
MODULE_DEVICE_TABLE(pci, vmd_ids);

diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 4bac1831de80..d25552b5ae3e 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2954,6 +2954,8 @@
#define PCI_DEVICE_ID_INTEL_SBRIDGE_BR 0x3cf5 /* 13.6 */
#define PCI_DEVICE_ID_INTEL_SBRIDGE_SAD1 0x3cf6 /* 12.7 */
#define PCI_DEVICE_ID_INTEL_IOAT_SNB 0x402f
+#define PCI_DEVICE_ID_INTEL_VMD_467F 0x467f
+#define PCI_DEVICE_ID_INTEL_VMD_4C3D 0x4c3d
#define PCI_DEVICE_ID_INTEL_5100_16 0x65f0
#define PCI_DEVICE_ID_INTEL_5100_19 0x65f3
#define PCI_DEVICE_ID_INTEL_5100_21 0x65f5
--
2.25.1

2021-07-22 17:00:33

by Bjorn Helgaas

[permalink] [raw]
Subject: Re: [PATCH 0/2] PCI: Make use of PCI_DEVICE_XXX() helper function

On Thu, Jul 22, 2021 at 07:19:01PM +0800, Cai Huoqing wrote:
> Could make use of PCI_DEVICE_XXX() helper function
>
> Cai Huoqing (2):
> PCI: Make use of PCI_DEVICE_SUB/_CLASS() helper function
> PCI: vmd: Make use of PCI_DEVICE_DATA() helper function
>
> drivers/pci/controller/vmd.c | 38 +++++++++++++++----------------
> drivers/pci/hotplug/cpqphp_core.c | 13 ++---------
> drivers/pci/search.c | 14 ++----------
> include/linux/pci_ids.h | 2 ++
> 4 files changed, 25 insertions(+), 42 deletions(-)

When you fix the problem below, also:

s/Make use of/Use/

Update commit log to say what the patch does. See
https://chris.beams.io/posts/git-commit/ for hints.
Add period at end of sentences.

I don't see exactly what's wrong, but this series doesn't apply
cleanly. I'm using b4 to fetch the series. b4 is from
https://git.kernel.org/pub/scm/utils/b4/b4.git

11:47:04 ~/linux (main)$ git checkout -b wip/cai v5.14-rc1
Switched to a new branch 'wip/cai'
11:47:17 ~/linux (wip/cai)$ b4 am -om/ [email protected]
Looking up https://lore.kernel.org/r/20210722111903.432-1-caihuoqing%40baidu.com
Grabbing thread from lore.kernel.org/linux-pci
Analyzing 3 messages in the thread
---
Writing m/20210722_caihuoqing_pci_make_use_of_pci_device_xxx_helper_function.mbx
[PATCH 1/2] PCI: Make use of PCI_DEVICE_SUB/_CLASS() helper function
[PATCH 2/2] PCI: vmd: Make use of PCI_DEVICE_DATA() helper function
---
Total patches: 2
---
Cover: m/20210722_caihuoqing_pci_make_use_of_pci_device_xxx_helper_function.cover
Link: https://lore.kernel.org/r/[email protected]
Base: not found (applies clean to current tree)
git am m/20210722_caihuoqing_pci_make_use_of_pci_device_xxx_helper_function.mbx
11:47:45 ~/linux (wip/cai)$ git am m/20210722_caihuoqing_pci_make_use_of_pci_device_xxx_helper_function.mbx
Applying: PCI: Make use of PCI_DEVICE_SUB/_CLASS() helper function
error: patch failed: drivers/pci/hotplug/cpqphp_core.c:1357
error: drivers/pci/hotplug/cpqphp_core.c: patch does not apply
error: patch failed: drivers/pci/search.c:303
error: drivers/pci/search.c: patch does not apply
Patch failed at 0001 PCI: Make use of PCI_DEVICE_SUB/_CLASS() helper function
hint: Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

2021-07-23 01:33:23

by Cai,Huoqing

[permalink] [raw]
Subject: RE: [PATCH 0/2] PCI: Make use of PCI_DEVICE_XXX() helper function

Hello
I get it and will send patch PATCH again.

THX

-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: 2021??7??23?? 0:52
To: Cai,Huoqing <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 0/2] PCI: Make use of PCI_DEVICE_XXX() helper function

On Thu, Jul 22, 2021 at 07:19:01PM +0800, Cai Huoqing wrote:
> Could make use of PCI_DEVICE_XXX() helper function
>
> Cai Huoqing (2):
> PCI: Make use of PCI_DEVICE_SUB/_CLASS() helper function
> PCI: vmd: Make use of PCI_DEVICE_DATA() helper function
>
> drivers/pci/controller/vmd.c | 38 +++++++++++++++----------------
> drivers/pci/hotplug/cpqphp_core.c | 13 ++---------
> drivers/pci/search.c | 14 ++----------
> include/linux/pci_ids.h | 2 ++
> 4 files changed, 25 insertions(+), 42 deletions(-)

When you fix the problem below, also:

s/Make use of/Use/

Update commit log to say what the patch does. See https://chris.beams.io/posts/git-commit/ for hints.
Add period at end of sentences.

I don't see exactly what's wrong, but this series doesn't apply cleanly. I'm using b4 to fetch the series. b4 is from https://git.kernel.org/pub/scm/utils/b4/b4.git

11:47:04 ~/linux (main)$ git checkout -b wip/cai v5.14-rc1
Switched to a new branch 'wip/cai'
11:47:17 ~/linux (wip/cai)$ b4 am -om/ [email protected]
Looking up https://lore.kernel.org/r/20210722111903.432-1-caihuoqing%40baidu.com
Grabbing thread from lore.kernel.org/linux-pci
Analyzing 3 messages in the thread
---
Writing m/20210722_caihuoqing_pci_make_use_of_pci_device_xxx_helper_function.mbx
[PATCH 1/2] PCI: Make use of PCI_DEVICE_SUB/_CLASS() helper function
[PATCH 2/2] PCI: vmd: Make use of PCI_DEVICE_DATA() helper function
---
Total patches: 2
---
Cover: m/20210722_caihuoqing_pci_make_use_of_pci_device_xxx_helper_function.cover
Link: https://lore.kernel.org/r/[email protected]
Base: not found (applies clean to current tree)
git am m/20210722_caihuoqing_pci_make_use_of_pci_device_xxx_helper_function.mbx
11:47:45 ~/linux (wip/cai)$ git am m/20210722_caihuoqing_pci_make_use_of_pci_device_xxx_helper_function.mbx
Applying: PCI: Make use of PCI_DEVICE_SUB/_CLASS() helper function
error: patch failed: drivers/pci/hotplug/cpqphp_core.c:1357
error: drivers/pci/hotplug/cpqphp_core.c: patch does not apply
error: patch failed: drivers/pci/search.c:303
error: drivers/pci/search.c: patch does not apply
Patch failed at 0001 PCI: Make use of PCI_DEVICE_SUB/_CLASS() helper function
hint: Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".