remove dead powernv code
Hi all,
the powerpc powernv port has a fairly large chunk of code that never had any upstream user. We generally strive to not keep dead code around, and this was affirmed at least years Maintainer summit.
PATCH 1/3 powerpc/powernv: remove the unused pnv_pci_set_p2p function
This function has never been used since it has been added to the tree. We also now have proper PCIe P2P APIs in the core kernel, and any new P2P support should be using those.
--- arch/powerpc/include/asm/opal.h | 2 - arch/powerpc/include/asm/pnv-pci.h | 2 - arch/powerpc/platforms/powernv/opal-call.c | 1 - arch/powerpc/platforms/powernv/pci.c | 74 ---------------------- arch/powerpc/platforms/powernv/pci.h | 5 -- 5 files changed, 84 deletions(-)
arch/powerpc/include/asm/opal.h +0 -2
@@ -279,8 +279,6 @@ int64_t opal_xive_allocate_irq(uint32_t chip_id);int64_t opal_xive_free_irq (uint32_t girq);int64_t opal_xive_sync (uint32_t type,uint32_t id);int64_t opal_xive_dump (uint32_t type,uint32_t id); -int64_t opal_pci_set_p2p (uint64_t phb_init,uint64_t phb_target, -uint64_t desc,uint16_t pe_number);int64_t opal_imc_counters_init (uint32_t type,uint64_t address,uint64_t cpu_pir);
arch/powerpc/include/asm/pnv-pci.h +0 -2
@@ -26,8 +26,6 @@ extern int pnv_pci_get_presence_state(uint64_t id, uint8_t *state);extern int pnv_pci_get_power_state (uint64_t id,uint8_t *state);extern int pnv_pci_set_power_state (uint64_t id,uint8_t state,struct opal_msg *msg); -extern int pnv_pci_set_p2p (struct pci_dev *initiator,struct pci_dev *target, -u64 desc);extern int pnv_pci_enable_tunnel (struct pci_dev *dev,uint64_t *asnind);extern int pnv_pci_disable_tunnel (struct pci_dev *dev);
arch/powerpc/platforms/powernv/opal-call.c +0 -1
@@ -267,7 +267,6 @@ OPAL_CALL(opal_npu_map_lpar, OPAL_NPU_MAP_LPAR);OPAL_CALL (opal_imc_counters_init,OPAL_IMC_COUNTERS_INIT );OPAL_CALL (opal_imc_counters_start,OPAL_IMC_COUNTERS_START );OPAL_CALL (opal_imc_counters_stop,OPAL_IMC_COUNTERS_STOP ); -OPAL_CALL (opal_pci_set_p2p,OPAL_PCI_SET_P2P );OPAL_CALL (opal_get_powercap,OPAL_GET_POWERCAP );OPAL_CALL (opal_set_powercap,OPAL_SET_POWERCAP );OPAL_CALL (opal_get_power_shift_ratio,OPAL_GET_POWER_SHIFT_RATIO );
arch/powerpc/platforms/powernv/pci.c +0 -74
86 lines not on this page · raw message
arch/powerpc/platforms/powernv/pci.h +0 -5
@@ -78,9 +78,6 @@ struct pnv_ioda_pe {struct pnv_ioda_pe *master;struct list_head slaves; -/* PCI peer-to-peer*/ -int p2p_initiator_count; -/* Link in list of PE#s */ struct list_head list; };
@@ -171,8 +168,6 @@ struct pnv_phb {/* PHB and hub diagnostics */ unsigned int diag_data_size;u8 *diag_data; - -int p2p_target_count; };extern struct pci_ops pnv_pci_ops;
Signature · 1 line
2.20.1
Re: [PATCH 1/3] powerpc/powernv: remove the unused pnv_pci_set_p2p function
Hi,
The PCI p2p and tunnel code is used by the Mellanox CX5 driver, at least their latest, out of tree version, which is used for CORAL. My understanding is that they'll upstream it at some point, though I don't know what their schedule is like.
Fred
Le 26/04/2019 à 14:49, Christoph Hellwig a écrit :
Quoted 167 lines
This function has never been used since it has been added to the tree. We also now have proper PCIe P2P APIs in the core kernel, and any new P2P support should be using those.
Signed-off-by Christoph Hellwig <[email protected]>--- arch/powerpc/include/asm/opal.h | 2 - arch/powerpc/include/asm/pnv-pci.h | 2 - arch/powerpc/platforms/powernv/opal-call.c | 1 - arch/powerpc/platforms/powernv/pci.c | 74 ---------------------- arch/powerpc/platforms/powernv/pci.h | 5 -- 5 files changed, 84 deletions(-)arch/powerpc/include/asm/opal.h +0
-2@@ -279,8 +279,6 @@ int64_t opal_xive_allocate_irq(uint32_t chip_id);int64_t opal_xive_free_irq (uint32_t girq);int64_t opal_xive_sync (uint32_t type,uint32_t id);int64_t opal_xive_dump (uint32_t type,uint32_t id); -int64_t opal_pci_set_p2p (uint64_t phb_init,uint64_t phb_target, -uint64_t desc,uint16_t pe_number);int64_t opal_imc_counters_init (uint32_t type,uint64_t address,uint64_t cpu_pir);arch/powerpc/include/asm/pnv-pci.h +0
-2@@ -26,8 +26,6 @@ extern int pnv_pci_get_presence_state(uint64_t id, uint8_t *state);extern int pnv_pci_get_power_state (uint64_t id,uint8_t *state);extern int pnv_pci_set_power_state (uint64_t id,uint8_t state,struct opal_msg *msg); -extern int pnv_pci_set_p2p (struct pci_dev *initiator,struct pci_dev *target, -u64 desc);extern int pnv_pci_enable_tunnel (struct pci_dev *dev,uint64_t *asnind);extern int pnv_pci_disable_tunnel (struct pci_dev *dev);arch/powerpc/platforms/powernv/opal-call.c +0
-1@@ -267,7 +267,6 @@ OPAL_CALL(opal_npu_map_lpar, OPAL_NPU_MAP_LPAR);OPAL_CALL (opal_imc_counters_init,OPAL_IMC_COUNTERS_INIT );OPAL_CALL (opal_imc_counters_start,OPAL_IMC_COUNTERS_START );OPAL_CALL (opal_imc_counters_stop,OPAL_IMC_COUNTERS_STOP ); -OPAL_CALL (opal_pci_set_p2p,OPAL_PCI_SET_P2P );OPAL_CALL (opal_get_powercap,OPAL_GET_POWERCAP );OPAL_CALL (opal_set_powercap,OPAL_SET_POWERCAP );OPAL_CALL (opal_get_power_shift_ratio,OPAL_GET_POWER_SHIFT_RATIO );arch/powerpc/platforms/powernv/pci.c +0
-74@@ -38,7 +38,6 @@#include "powernv.h" #include "pci.h" -static DEFINE_MUTEX (p2p_mutex);static DEFINE_MUTEX (tunnel_mutex);int pnv_pci_get_slot_id (struct device_node *np,uint64_t *id)@@ -861,79 +860,6 @@ void pnv_pci_dma_bus_setup(struct pci_bus *bus) } } -int pnv_pci_set_p2p (struct pci_dev *initiator,struct pci_dev *target,u64 desc) -{ -struct pci_controller *hose; -struct pnv_phb *phb_init, *phb_target; -struct pnv_ioda_pe *pe_init; -int rc; - -if (!opal_check_token (OPAL_PCI_SET_P2P )) -return -ENXIO ; - - hose =pci_bus_to_host (initiator->bus); - phb_init = hose->private_data; - - hose =pci_bus_to_host (target->bus); - phb_target = hose->private_data; - - pe_init =pnv_ioda_get_pe (initiator); -if (!pe_init) -return -ENODEV ; - -/* -* Configuring the initiator's PHB requires to adjust its -* TVE#1 setting. Since the same device can be an initiator -* several times for different target devices, we need to keep -* a reference count to know when we can restore the default -* bypass setting on its TVE#1 when disabling. Opal is not -* tracking PE states, so we add a reference count on the PE -* in linux. -* -* For the target, the configuration is per PHB, so we keep a -* target reference count on the PHB. -*/ -mutex_lock (&p2p_mutex); - -if (desc &OPAL_PCI_P2P_ENABLE ) { -/* always go to opal to validate the configuration */ - rc =opal_pci_set_p2p (phb_init->opal_id, phb_target->opal_id, - desc, pe_init->pe_number); - -if (rc !=OPAL_SUCCESS ) { - rc = -EIO ; - goto out; - } - - pe_init->p2p_initiator_count++; - phb_target->p2p_target_count++; - }else { -if (!pe_init->p2p_initiator_count || - !phb_target->p2p_target_count) { - rc = -EINVAL ; - goto out; - } - -if (--pe_init->p2p_initiator_count ==0 ) -pnv_pci_ioda2_set_bypass (pe_init, true); - -if (--phb_target->p2p_target_count ==0 ) { - rc =opal_pci_set_p2p (phb_init->opal_id, - phb_target->opal_id, desc, - pe_init->pe_number); -if (rc !=OPAL_SUCCESS ) { - rc = -EIO ; - goto out; - } - } - } - rc =0 ; -out: -mutex_unlock (&p2p_mutex); -return rc; -} -EXPORT_SYMBOL_GPL (pnv_pci_set_p2p); -struct device_node *pnv_pci_get_phb_node (struct pci_dev *dev) {struct pci_controller *hose =pci_bus_to_host (dev->bus);arch/powerpc/platforms/powernv/pci.h +0
-5@@ -78,9 +78,6 @@ struct pnv_ioda_pe {struct pnv_ioda_pe *master;struct list_head slaves; -/* PCI peer-to-peer*/ -int p2p_initiator_count; -/* Link in list of PE#s */ struct list_head list; };@@ -171,8 +168,6 @@ struct pnv_phb {/* PHB and hub diagnostics */ unsigned int diag_data_size;u8 *diag_data; - -int p2p_target_count; };extern struct pci_ops pnv_pci_ops;
Re: [PATCH 1/3] powerpc/powernv: remove the unused pnv_pci_set_p2p function
Quoted 6 lines · Frederic Barrat
Hi,
The PCI p2p and tunnel code is used by the Mellanox CX5 driver, at least their latest, out of tree version, which is used for CORAL. My understanding is that they'll upstream it at some point, though I don't know what their schedule is like.
As said before, we only keep exports in tree for in-tree users. If the CX5 driver grows special P2P support it will have to use the proper existing kernel infrastructure for that anyway.
Re: [PATCH 1/3] powerpc/powernv: remove the unused pnv_pci_set_p2p function
In reply to Frederic BarratQuoted 6 lines · Frederic Barrat
Hi,
The PCI p2p and tunnel code is used by the Mellanox CX5 driver, at least their latest, out of tree version, which is used for CORAL. My understanding is that they'll upstream it at some point, though I don't know what their schedule is like.
FYI, Max who wrote (at least larger parts of) that code is on Cc agreed that all P2P code should go through the kernel P2P infrastructure and might be able to spend some cycles on it.
Which still doesn't change anything about that fact that we [1] generally don't add infrastructure for anything that is not in the tree.
[1] well, powernv seems to have handles this a little oddly, and now is on my special watchlist.
RE: [PATCH 1/3] powerpc/powernv: remove the unused pnv_pci_set_p2p function
Hi Greg/Christoph,
Can we leave it meanwhile till we'll find a general solution (for the upcoming kernel) ?
I guess we can somehow generalize the P2P initialization process for PPC and leave it empty for now for other archs.
Or maybe we can find some other solution (sysfs/configfs/module param), but it will take time since we'll need to work closely with the IBM pci guys that wrote this code.
-Max.
-----Original Message-----
From: Christoph Hellwig <[email protected]>
Sent: Thursday, May 23, 2019 10:53 AM
To: Frederic Barrat <[email protected]>
Cc: Christoph Hellwig <[email protected]>; Benjamin Herrenschmidt <[email protected]>; Paul Mackerras <[email protected]>; Michael Ellerman <[email protected]>; [email protected]; Max Gurtovoy <[email protected]>
Subject: Re: [PATCH 1/3] powerpc/powernv: remove the unused pnv_pci_set_p2p function
Quoted 6 lines · Frederic Barrat
Hi,
The PCI p2p and tunnel code is used by the Mellanox CX5 driver, at least their latest, out of tree version, which is used for CORAL. My understanding is that they'll upstream it at some point, though I don't know what their schedule is like.
FYI, Max who wrote (at least larger parts of) that code is on Cc agreed that all P2P code should go through the kernel P2P infrastructure and might be able to spend some cycles on it.
Which still doesn't change anything about that fact that we [1] generally don't add infrastructure for anything that is not in the tree.
[1] well, powernv seems to have handles this a little oddly, and now is on my special watchlist.
Re: [PATCH 1/3] powerpc/powernv: remove the unused pnv_pci_set_p2p function
Quoted 4 lines · Max Gurtovoy
Hi Greg/Christoph,
Can we leave it meanwhile till we'll find a general solution (for the upcoming kernel) ?
I guess we can somehow generalize the P2P initialization process for PPC and leave it empty for now for other archs.
Or maybe we can find some other solution (sysfs/configfs/module param), but it will take time since we'll need to work closely with the IBM pci guys that wrote this code.
We do not keep code without in-tree users around, especially not if we have a better API with in-tree users.
AFAICS the only thing you'll need is to wire up the enable/disable calls.
Re: [PATCH 1/3] powerpc/powernv: remove the unused pnv_pci_set_p2p function
Quoted 10 lines · Christoph Hellwig
Quoted 4 lines · Max Gurtovoy
Hi Greg/Christoph,
Can we leave it meanwhile till we'll find a general solution (for the upcoming kernel) ?
I guess we can somehow generalize the P2P initialization process for PPC and leave it empty for now for other archs.
Or maybe we can find some other solution (sysfs/configfs/module param), but it will take time since we'll need to work closely with the IBM pci guys that wrote this code.We do not keep code without in-tree users around, especially not if we have a better API with in-tree users.
AFAICS the only thing you'll need is to wire up the enable/disable calls.
I guess you're right, but we still need to know the time frame we have here since this should be tested carefully on the P9 hardware.
Are we ok with working on a solution during kernel-5.3 cycle ?
Re: [PATCH 1/3] powerpc/powernv: remove the unused pnv_pci_set_p2p function
Quoted 1 line · Max Gurtovoy
Are we ok with working on a solution during kernel-5.3 cycle ?
You can start working on it any time, no need to ask for permission.
Re: [PATCH 1/3] powerpc/powernv: remove the unused pnv_pci_set_p2p function
Quoted 3 lines · Christoph Hellwig
Quoted 1 line · Max Gurtovoy
Are we ok with working on a solution during kernel-5.3 cycle ?
You can start working on it any time, no need to ask for permission.
I just want to make sure we don't remove it from the kernel before we send a general API solution.
This way we'll make sure that all the kernel versions has this functionality...
Re: [PATCH 1/3] powerpc/powernv: remove the unused pnv_pci_set_p2p function
Quoted 8 lines · Max Gurtovoy
Quoted 3 lines · Christoph Hellwig
Quoted 1 line · Max Gurtovoy
Are we ok with working on a solution during kernel-5.3 cycle ?
You can start working on it any time, no need to ask for permission.
I just want to make sure we don't remove it from the kernel before we send a general API solution.
The code is gone in this merge window.
Quoted 2 lines
This way we'll make sure that all the kernel versions has this functionality...
Again, we do not provide functionality for out of tree modules. We've had the p2p API for about a year now, its not like you didn't have plenty of time.
Re: [PATCH 1/3] powerpc/powernv: remove the unused pnv_pci_set_p2p function
Quoted 8 lines · Christoph Hellwig
Quoted 6 lines · Max Gurtovoy
Quoted 3 lines · Christoph Hellwig
Quoted 1 line · Max Gurtovoy
Are we ok with working on a solution during kernel-5.3 cycle ?
You can start working on it any time, no need to ask for permission.
I just want to make sure we don't remove it from the kernel before we send a general API solution.
The code is gone in this merge window.
Ok, so we must fix it to kernel-5.3 to make sure we're covered.
Understood.
Quoted 6 lines
Quoted 3 lines
This way we'll make sure that all the kernel versions has this functionality...
Again, we do not provide functionality for out of tree modules. We've had the p2p API for about a year now, its not like you didn't have plenty of time.
I didn't know about the intention to remove this code...
Also this code was merged before the p2p API for p2pmem.
Re: [PATCH 1/3] powerpc/powernv: remove the unused pnv_pci_set_p2p function
Quoted 1 line · Max Gurtovoy
Also this code was merged before the p2p API for p2pmem.
Yes, without a single user or intention to submit a user, and without covering the most useful use case (PCIe switches). While at the same time the people involved completely ignored the PCIe P2P discussions that have been going on the PCI list for a long time.
This is a text book example of why code needs to be upstream first with a broad discussion instead of slipping some crap in for out of tree drivers.
Re: [PATCH 1/3] powerpc/powernv: remove the unused pnv_pci_set_p2p function
In reply to Max GurtovoyQuoted 16 lines · Max Gurtovoy
Quoted 8 lines · Christoph Hellwig
Quoted 6 lines · Max Gurtovoy
Quoted 3 lines · Christoph Hellwig
Quoted 1 line · Max Gurtovoy
Are we ok with working on a solution during kernel-5.3 cycle ?
You can start working on it any time, no need to ask for permission.
I just want to make sure we don't remove it from the kernel before we send a general API solution.
The code is gone in this merge window.
Ok, so we must fix it to kernel-5.3 to make sure we're covered.
Understood.
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
This way we'll make sure that all the kernel versions has this functionality...
Again, we do not provide functionality for out of tree modules. We've had the p2p API for about a year now, its not like you didn't have plenty of time.
I didn't know about the intention to remove this code...
The original email you responded to in this thread was received by you back in May. It is now July, 5.3 will not be out for 8-9 weeks. There has been plenty of time here...
greg k-h
PATCH 2/3 powerpc/powernv: remove pnv_pci_{enable,disable}_tunnel
In reply to Christoph HellwigThese have been unused ever since they've been added to the kernel.
--- arch/powerpc/include/asm/pnv-pci.h | 2 - arch/powerpc/platforms/powernv/pci-ioda.c | 4 +- arch/powerpc/platforms/powernv/pci.c | 48 ----------------------- arch/powerpc/platforms/powernv/pci.h | 1 - 4 files changed, 3 insertions(+), 52 deletions(-)
arch/powerpc/include/asm/pnv-pci.h +0 -2
@@ -27,8 +27,6 @@ extern int pnv_pci_get_power_state(uint64_t id, uint8_t *state);extern int pnv_pci_set_power_state (uint64_t id,uint8_t state,struct opal_msg *msg); -extern int pnv_pci_enable_tunnel (struct pci_dev *dev,uint64_t *asnind); -extern int pnv_pci_disable_tunnel (struct pci_dev *dev);extern int pnv_pci_set_tunnel_bar (struct pci_dev *dev,uint64_t addr,int enable); extern int pnv_pci_get_as_notify_info(struct task_struct *task, u32 *lpid,
arch/powerpc/platforms/powernv/pci-ioda.c +3 -1
@@ -54,6 +54,8 @@static const char *const pnv_phb_names[] = {"IODA1" ,"IODA2" ,"NPU_NVLINK" ,"NPU_OCAPI" }; +static void pnv_pci_ioda2_set_bypass (struct pnv_ioda_pe *pe,bool enable); +void pe_level_printk (const struct pnv_ioda_pe *pe,const char *level,const char *fmt, ...) {
@@ -2359,7 +2361,7 @@ static long pnv_pci_ioda2_set_window(struct iommu_table_group *table_group,return 0 ; } -void pnv_pci_ioda2_set_bypass (struct pnv_ioda_pe *pe,bool enable) +static void pnv_pci_ioda2_set_bypass (struct pnv_ioda_pe *pe,bool enable) {uint16_t window_id = (pe->pe_number <<1 ) +1 ;int64_t rc;
arch/powerpc/platforms/powernv/pci.c +0 -48
54 lines not on this page · raw message
arch/powerpc/platforms/powernv/pci.h +0 -1
@@ -194,7 +194,6 @@ extern int pnv_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type);extern void pnv_teardown_msi_irqs (struct pci_dev *pdev);extern struct pnv_ioda_pe *pnv_ioda_get_pe (struct pci_dev *dev);extern void pnv_set_msi_irq_chip (struct pnv_phb *phb,unsigned int virq); -extern void pnv_pci_ioda2_set_bypass (struct pnv_ioda_pe *pe,bool enable);extern unsigned long pnv_pci_ioda2_get_table_size (__u32 page_shift,__u64 window_size,__u32 levels);extern int pnv_eeh_post_init (void );
Signature · 1 line
2.20.1
PATCH 3/3 powerpc/powernv: remove dead NPU DMA code
In reply to Christoph HellwigNone of these routines were ever used since they were added to the kernel.
--- arch/powerpc/include/asm/book3s/64/mmu.h | 3 - arch/powerpc/include/asm/powernv.h | 22 - arch/powerpc/mm/mmu_context_book3s64.c | 2 - arch/powerpc/platforms/powernv/npu-dma.c | 556 ----------------------- 4 files changed, 583 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu.h +0 -3
@@ -120,9 +120,6 @@ typedef struct {/* Number of users of the external (Nest) MMU */ atomic_t copros; -/* NPU NMMU context */ -struct npu_context *npu_context; -#ifdef CONFIG_PPC_MM_SLICES /* SLB page size encodings*/ unsigned char low_slices_psize[BITS_PER_LONG /BITS_PER_BYTE ];
arch/powerpc/include/asm/powernv.h +0 -22
@@ -11,35 +11,13 @@#define _ASM_POWERNV_H#ifdef CONFIG_PPC_POWERNV -#define NPU2_WRITE 1extern void powernv_set_nmmu_ptcr (unsigned long ptcr); -extern struct npu_context *pnv_npu2_init_context (struct pci_dev *gpdev, -unsigned long flags, -void (*cb)(struct npu_context *,void *), -void *priv); -extern void pnv_npu2_destroy_context (struct npu_context *context, -struct pci_dev *gpdev); -extern int pnv_npu2_handle_fault (struct npu_context *context,uintptr_t *ea, -unsigned long *flags,unsigned long *status, -int count);void pnv_program_cpu_hotplug_lpcr (unsigned int cpu,u64 lpcr_val);void pnv_tm_init (void );#else static inline void powernv_set_nmmu_ptcr (unsigned long ptcr) { } -static inline struct npu_context *pnv_npu2_init_context (struct pci_dev *gpdev, -unsigned long flags, -struct npu_context *(*cb)(struct npu_context *,void *), -void *priv) {return ERR_PTR (-ENODEV ); } -static inline void pnv_npu2_destroy_context (struct npu_context *context, -struct pci_dev *gpdev) { } - -static inline int pnv_npu2_handle_fault (struct npu_context *context, -uintptr_t *ea,unsigned long *flags, -unsigned long *status,int count) { -return -ENODEV ; -}static inline void pnv_tm_init (void ) { }#endif
arch/powerpc/mm/mmu_context_book3s64.c +0 -2
@@ -117,8 +117,6 @@ static int radix__init_new_context(struct mm_struct *mm)*/ asmvolatile ("ptesync;isync" : : :"memory" ); - mm->context.npu_context =NULL ; -return index; }
arch/powerpc/platforms/powernv/npu-dma.c +0 -556
594 lines not on this page · raw message
Signature · 1 line
2.20.1