Re: [PATCH 6/6] cxlflash: Update documentation
Acked-by: Manoj N. KumarOn 8/9/2016 6:40 PM, Matthew R. Ochs wrote: Update the block library link in the API documentation. Signed-off-by: Matthew R. Ochs --- Documentation/powerpc/cxlflash.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/powerpc/cxlflash.txt b/Documentation/powerpc/cxlflash.txt index f4c1190..6d9a2ed 100644 --- a/Documentation/powerpc/cxlflash.txt +++ b/Documentation/powerpc/cxlflash.txt @@ -121,7 +121,7 @@ Block library API below. The block library can be found on GitHub: -http://www.github.com/mikehollinger/ibmcapikv +http://github.com/open-power/capiflash CXL Flash Driver IOCTLs
Re: [PATCH 5/6] cxlflash: Remove adapter file descriptor cache
Acked-by: Manoj N. KumarOn 8/9/2016 6:40 PM, Matthew R. Ochs wrote: The adapter file descriptor was previously cached within the kernel for a given context in order to support performing a close on behalf of an application. This is no longer needed as applications are now required to perform a close on the adapter file descriptor. Inspired-by: Al Viro Signed-off-by: Matthew R. Ochs
Re: [PATCH 4/6] cxlflash: Transition to application close model
Acked-by: Manoj N. KumarOn 8/9/2016 6:39 PM, Matthew R. Ochs wrote: Caching the adapter file descriptor and performing a close on behalf of an application is a poor design. This is due to the fact that once a file descriptor in installed, it is free to be altered without the knowledge of the cxlflash driver. This can lead to inconsistencies between the application and kernel. Furthermore, the nature of the former design is more exploitable and thus should be abandoned. To support applications performing a close on the adapter file that is associated with a context, a new flag is introduced to the user API to indicate to applications that they are responsible for the close following the cleanup (detach) of a context. The documentation is also updated to reflect this change in behavior. Inspired-by: Al Viro Signed-off-by: Matthew R. Ochs
Re: [PATCH 3/6] cxlflash: Add kref to context
Acked-by: Manoj N. KumarOn 8/9/2016 6:39 PM, Matthew R. Ochs wrote: Currently, context user references are tracked via the list of LUNs that have attached to the context. While convenient, this is not intuitive without a deep study of the code and is inconsistent with the existing reference tracking patterns within the kernel. This design choice can lead to future bug injection. To improve code comprehension and better protect against future bugs, add explicit reference counting to contexts and migrate the context removal code to the kref release handler. Inspired-by: Al Viro Signed-off-by: Matthew R. Ochs
Re: [PATCH 2/6] cxlflash: Cache owning adapter within context
Acked-by: Manoj N. KumarOn 8/9/2016 6:39 PM, Matthew R. Ochs wrote: The context removal routine requires access to the owning adapter structure to reset the context within the AFU as part of the tear down sequence. In order to support kref adoption, the owning adapter must be accessible from the release handler. As the kref framework only provides the kref reference as the sole parameter, another means is needed to derive the owning adapter. As a remedy, the owning adapter reference is saved off within the context during initialization. Signed-off-by: Matthew R. Ochs --- drivers/scsi/cxlflash/superpipe.c | 1 + drivers/scsi/cxlflash/superpipe.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c index ab5c893..640c3a2 100644 --- a/drivers/scsi/cxlflash/superpipe.c +++ b/drivers/scsi/cxlflash/superpipe.c @@ -804,6 +804,7 @@ static void init_context(struct ctx_info *ctxi, struct cxlflash_cfg *cfg, ctxi->lfd = adap_fd; ctxi->pid = current->tgid; /* tgid = pid */ ctxi->ctx = ctx; + ctxi->cfg = cfg; ctxi->file = file; ctxi->initialized = true; mutex_init(>mutex); diff --git a/drivers/scsi/cxlflash/superpipe.h b/drivers/scsi/cxlflash/superpipe.h index 5f9a091..61404f2 100644 --- a/drivers/scsi/cxlflash/superpipe.h +++ b/drivers/scsi/cxlflash/superpipe.h @@ -107,6 +107,7 @@ struct ctx_info { bool err_recovery_active; struct mutex mutex; /* Context protection */ struct cxl_context *ctx; + struct cxlflash_cfg *cfg; struct list_head luns; /* LUNs attached to this context */ const struct vm_operations_struct *cxl_mmap_vmops; struct file *file;
Re: [PATCH 1/6] cxlflash: Avoid mutex when destroying context
Acked-by: Manoj N. KumarOn 8/9/2016 6:39 PM, Matthew R. Ochs wrote: Context information structures are protected by a mutex that is held when accessing/manipulating the context. When the code that manages these structures was authored, a decision was made to include taking the mutex as part of the allocation/initialization sequence and also handle the scenario where the mutex was already held when freeing the context. While not a problem outright, this design decision has been deemed as too flexible and the code should be made more rigid to avoid future bugs. In addition, further review of the code yields that the existing mutex manipulations in both of these context management paths are superfluous. This commit removes the obtaining of the context mutex in the context initialization routine and assumes the mutex is not held in the context free path. Inspired-by: Al Viro Signed-off-by: Matthew R. Ochs
Re: [PATCH 3/3] cxlflash: Shutdown notify support for CXL Flash cards
On 6/15/2016 6:49 PM, Uma Krishnan wrote: Some CXL Flash cards need notification of device shutdown in order to flush pending I/Os. A PCI notification hook for shutdown has been added where the driver notifies the card and returns. When the device is removed in the PCI remove path, notification code will wait for shutdown processing to complete. Signed-off-by: Uma KrishnanAcked-by: Manoj N. Kumar ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/3] cxlflash: Add device dependent flags
On 6/15/2016 6:49 PM, Uma Krishnan wrote: Device dependent flags are needed to support functions that are specific to a particular device. Acked-by: Manoj N. Kumar___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] cxl: Increase timeout for detection of AFU mmio hang
Tested-by: Manoj Kumar <ma...@linux.vnet.ibm.com> On 4/19/2016 11:34 AM, Frederic Barrat wrote: PSL designers recommend a larger value for the mmio hang pulse, 256 us instead of 1 us. The CAIA architecture states that it needs to be smaller than 1/2 of the RTOS timeout set in the PHB for outbound non-posted transactions, which is still (easily) the case here. Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> --- Needs to be applied on top of http://patchwork.ozlabs.org/patch/604029/ ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v6 19/20] cxlflash: Use new cxl_pci_read_adapter_vpd() API
Fred: Thanks for submitting this. Including linux-scsi. Acked-by: Manoj N. Kumar- Manoj On 3/4/2016 5:26 AM, Frederic Barrat wrote: To read the adapter VPD, drivers can't rely on pci config APIs, as it wouldn't work on powerVM. cxl introduced a new kernel API especially for this, so start using it. Co-authored-by: Christophe Lombard Signed-off-by: Frederic Barrat Signed-off-by: Christophe Lombard --- drivers/scsi/cxlflash/common.h | 1 - drivers/scsi/cxlflash/main.c | 18 ++ 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/cxlflash/common.h b/drivers/scsi/cxlflash/common.h index 5ada926..580f370 100644 --- a/drivers/scsi/cxlflash/common.h +++ b/drivers/scsi/cxlflash/common.h @@ -106,7 +106,6 @@ struct cxlflash_cfg { atomic_t scan_host_needed; struct cxl_afu *cxl_afu; - struct pci_dev *parent_dev; atomic_t recovery_threads; struct mutex ctx_recovery_mutex; diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index f6d90ce..e04aae7 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -1407,7 +1407,7 @@ static int start_context(struct cxlflash_cfg *cfg) */ static int read_vpd(struct cxlflash_cfg *cfg, u64 wwpn[]) { - struct pci_dev *dev = cfg->parent_dev; + struct pci_dev *dev = cfg->dev; int rc = 0; int ro_start, ro_size, i, j, k; ssize_t vpd_size; @@ -1416,7 +1416,7 @@ static int read_vpd(struct cxlflash_cfg *cfg, u64 wwpn[]) char *wwpn_vpd_tags[NUM_FC_PORTS] = { "V5", "V6" }; /* Get the VPD data from the device */ - vpd_size = pci_read_vpd(dev, 0, sizeof(vpd_data), vpd_data); + vpd_size = cxl_read_adapter_vpd(dev, vpd_data, sizeof(vpd_data)); if (unlikely(vpd_size <= 0)) { dev_err(>dev, "%s: Unable to read VPD (size = %ld)\n", __func__, vpd_size); @@ -2392,7 +2392,6 @@ static int cxlflash_probe(struct pci_dev *pdev, { struct Scsi_Host *host; struct cxlflash_cfg *cfg = NULL; - struct device *phys_dev; struct dev_dependent_vals *ddv; int rc = 0; @@ -2458,19 +2457,6 @@ static int cxlflash_probe(struct pci_dev *pdev, pci_set_drvdata(pdev, cfg); - /* -* Use the special service provided to look up the physical -* PCI device, since we are called on the probe of the virtual -* PCI host bus (vphb) -*/ - phys_dev = cxl_get_phys_dev(pdev); - if (!dev_is_pci(phys_dev)) { - dev_err(>dev, "%s: not a pci dev\n", __func__); - rc = -ENODEV; - goto out_remove; - } - cfg->parent_dev = to_pci_dev(phys_dev); - cfg->cxl_afu = cxl_pci_to_afu(pdev); rc = init_pci(cfg); ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v5 14/18] cxl: Support to flash a new image on the adapter from a guest
Fred: Comments below. On 2/25/2016 7:11 AM, Frederic Barrat wrote: Le 24/02/2016 21:03, Manoj Kumar a écrit : From: Christophe Lombard <clomb...@linux.vnet.ibm.com> +#define CXL_DEV_MINORS 13 /* 1 control + 4 AFUs * 3 (dedicated/master/shared) */ Where does this limit of 4 AFUs come from? Is this related to CXL_MAX_SLICES? Should this be a computed value, in case the number of AFUs/slices is increased at a future date? The architecture document (CAIA) limits the number of AFUs to 4, though I don't think anybody as tried with more than 1 so far. So yes, we could have reused CXL_MAX_SLICES. Since we were just moving the definition from another file and this is not likely to vary until a major revision of the architecture, I don't intend to address it in this patchset, but I've added it to my list of ideas for future cleanup (you had already mentioned something about hard-coded constants in the previous series). Since it was a carryover from existing code, it is fine to address later. memset(0) after kzalloc() is redundant. yep! Will fix. If this is resolved in v6, you may add Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v5 15/18] cxl: Parse device tree and create cxl device(s) at boot
Fred: Thanks for the clarification. Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/25/2016 7:19 AM, Frederic Barrat wrote: Le 24/02/2016 21:15, Manoj Kumar a écrit : On 2/23/2016 10:21 AM, Frederic Barrat wrote: +module_init(cxl_base_init); Is this a remnant from when there were two modules? Do you really need two module_init() calls (can't one be called from the other)? What is the tear-down portion of this (module_exit)? No, this is not a left-over from the previous 2-module implementation of the cxl driver. The file base.c is not part of the "normal" cxl driver. It is either part of the kernel if the cxl driver is a module or configured in the kernel. Or it is discarded if cxl is not even a module. So code in that file is either in the kernel or it's not even compiled. That was already the case on bare-metal. Code in module_init() is executed when the kernel boots and it is not going away. Fred ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v5 17/18] cxl: Adapter failure handling
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/23/2016 10:21 AM, Frederic Barrat wrote: From: Christophe Lombard <clomb...@linux.vnet.ibm.com> Check the AFU state whenever an API is called. The hypervisor may issue a reset of the adapter when it detects a fault. When it happens, it launches an error recovery which will either move the AFU to a permanent failure state, or in the disabled state. If the AFU is found to be disabled, detach all existing contexts from it before issuing a AFU reset to re-enable it. Before detaching contexts, notify any kernel driver through the EEH callbacks of the AFU pci device. Co-authored-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Acked-by: Ian Munsie <imun...@au1.ibm.com> --- drivers/misc/cxl/context.c | 2 +- drivers/misc/cxl/cxl.h | 18 ++--- drivers/misc/cxl/file.c| 10 +-- drivers/misc/cxl/guest.c | 167 - drivers/misc/cxl/main.c| 2 +- drivers/misc/cxl/native.c | 32 - drivers/misc/cxl/vphb.c| 2 +- 7 files changed, 198 insertions(+), 35 deletions(-) diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c index 180c85a..10370f2 100644 --- a/drivers/misc/cxl/context.c +++ b/drivers/misc/cxl/context.c @@ -220,7 +220,7 @@ int __detach_context(struct cxl_context *ctx) * If detach fails when hw is down, we don't care. */ WARN_ON(cxl_ops->detach_process(ctx) && - cxl_ops->link_ok(ctx->afu->adapter)); + cxl_ops->link_ok(ctx->afu->adapter, ctx->afu)); flush_work(>fault_work); /* Only needed for dedicated process */ /* release the reference to the group leader and mm handling pid */ diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index 6c2521c..e9150c3 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -373,6 +373,8 @@ struct cxl_afu_guest { phys_addr_t p2n_phys; u64 p2n_size; int max_ints; + struct mutex recovery_lock; + int previous_state; }; struct cxl_afu { @@ -611,7 +613,7 @@ struct cxl_process_element { __be32 software_state; } __packed; -static inline bool cxl_adapter_link_ok(struct cxl *cxl) +static inline bool cxl_adapter_link_ok(struct cxl *cxl, struct cxl_afu *afu) { struct pci_dev *pdev; @@ -630,13 +632,13 @@ static inline void __iomem *_cxl_p1_addr(struct cxl *cxl, cxl_p1_reg_t reg) static inline void cxl_p1_write(struct cxl *cxl, cxl_p1_reg_t reg, u64 val) { - if (likely(cxl_adapter_link_ok(cxl))) + if (likely(cxl_adapter_link_ok(cxl, NULL))) out_be64(_cxl_p1_addr(cxl, reg), val); } static inline u64 cxl_p1_read(struct cxl *cxl, cxl_p1_reg_t reg) { - if (likely(cxl_adapter_link_ok(cxl))) + if (likely(cxl_adapter_link_ok(cxl, NULL))) return in_be64(_cxl_p1_addr(cxl, reg)); else return ~0ULL; @@ -650,13 +652,13 @@ static inline void __iomem *_cxl_p1n_addr(struct cxl_afu *afu, cxl_p1n_reg_t reg static inline void cxl_p1n_write(struct cxl_afu *afu, cxl_p1n_reg_t reg, u64 val) { - if (likely(cxl_adapter_link_ok(afu->adapter))) + if (likely(cxl_adapter_link_ok(afu->adapter, afu))) out_be64(_cxl_p1n_addr(afu, reg), val); } static inline u64 cxl_p1n_read(struct cxl_afu *afu, cxl_p1n_reg_t reg) { - if (likely(cxl_adapter_link_ok(afu->adapter))) + if (likely(cxl_adapter_link_ok(afu->adapter, afu))) return in_be64(_cxl_p1n_addr(afu, reg)); else return ~0ULL; @@ -669,13 +671,13 @@ static inline void __iomem *_cxl_p2n_addr(struct cxl_afu *afu, cxl_p2n_reg_t reg static inline void cxl_p2n_write(struct cxl_afu *afu, cxl_p2n_reg_t reg, u64 val) { - if (likely(cxl_adapter_link_ok(afu->adapter))) + if (likely(cxl_adapter_link_ok(afu->adapter, afu))) out_be64(_cxl_p2n_addr(afu, reg), val); } static inline u64 cxl_p2n_read(struct cxl_afu *afu, cxl_p2n_reg_t reg) { - if (likely(cxl_adapter_link_ok(afu->adapter))) + if (likely(cxl_adapter_link_ok(afu->adapter, afu))) return in_be64(_cxl_p2n_addr(afu, reg)); else return ~0ULL; @@ -851,7 +853,7 @@ struct cxl_backend_ops { u64 wed, u64 amr); int (*detach_process)(struct cxl_context *ctx); bool (*support_attributes)(const char *attr_name); - bool (*link_ok)(struct cxl *cxl); + bool (*link_ok)(struct cxl *cxl, struct cxl_afu *afu); void (*release_afu)(struct device *dev); ssize_t (*afu_read_err_buffer)(struct cxl_afu *afu, char *buf, loff_t off, size_
Re: [PATCH v5 16/18] cxl: Support the cxl kernel API from a guest
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/23/2016 10:21 AM, Frederic Barrat wrote: Like on bare-metal, the cxl driver creates a virtual PHB and a pci device for the AFU. The configuration space of the device is mapped to the configuration record of the AFU. Reuse the code defined in afu_cr_read8|16|32() when reading the configuration space of the AFU device. Even though the (virtual) AFU device is a pci device, the adapter is not. So a driver using the cxl kernel API cannot read the VPD of the adapter through the usual PCI interface. Therefore, we add a call to the cxl kernel API: ssize_t cxl_read_adapter_vpd(struct pci_dev *dev, void *buf, size_t count); Co-authored-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> --- drivers/misc/cxl/api.c| 63 ++- drivers/misc/cxl/cxl.h| 6 +- drivers/misc/cxl/guest.c | 26 drivers/misc/cxl/native.c | 50 +++ drivers/misc/cxl/pci.c| 9 ++- drivers/misc/cxl/vphb.c | 154 +++--- include/misc/cxl.h| 5 ++ 7 files changed, 203 insertions(+), 110 deletions(-) diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index 325f957..75ec2f9 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c @@ -89,28 +89,11 @@ int cxl_release_context(struct cxl_context *ctx) } EXPORT_SYMBOL_GPL(cxl_release_context); -int cxl_allocate_afu_irqs(struct cxl_context *ctx, int num) -{ - if (num == 0) - num = ctx->afu->pp_irqs; - return afu_allocate_irqs(ctx, num); -} -EXPORT_SYMBOL_GPL(cxl_allocate_afu_irqs); - -void cxl_free_afu_irqs(struct cxl_context *ctx) -{ - afu_irq_name_free(ctx); - cxl_ops->release_irq_ranges(>irqs, ctx->afu->adapter); -} -EXPORT_SYMBOL_GPL(cxl_free_afu_irqs); - static irq_hw_number_t cxl_find_afu_irq(struct cxl_context *ctx, int num) { __u16 range; int r; - WARN_ON(num == 0); - for (r = 0; r < CXL_IRQ_RANGES; r++) { range = ctx->irqs.range[r]; if (num < range) { @@ -121,6 +104,44 @@ static irq_hw_number_t cxl_find_afu_irq(struct cxl_context *ctx, int num) return 0; } +int cxl_allocate_afu_irqs(struct cxl_context *ctx, int num) +{ + int res; + irq_hw_number_t hwirq; + + if (num == 0) + num = ctx->afu->pp_irqs; + res = afu_allocate_irqs(ctx, num); + if (!res && !cpu_has_feature(CPU_FTR_HVMODE)) { + /* In a guest, the PSL interrupt is not multiplexed. It was +* allocated above, and we need to set its handler +*/ + hwirq = cxl_find_afu_irq(ctx, 0); + if (hwirq) + cxl_map_irq(ctx->afu->adapter, hwirq, cxl_ops->psl_interrupt, ctx, "psl"); + } + return res; +} +EXPORT_SYMBOL_GPL(cxl_allocate_afu_irqs); + +void cxl_free_afu_irqs(struct cxl_context *ctx) +{ + irq_hw_number_t hwirq; + unsigned int virq; + + if (!cpu_has_feature(CPU_FTR_HVMODE)) { + hwirq = cxl_find_afu_irq(ctx, 0); + if (hwirq) { + virq = irq_find_mapping(NULL, hwirq); + if (virq) + cxl_unmap_irq(virq, ctx); + } + } + afu_irq_name_free(ctx); + cxl_ops->release_irq_ranges(>irqs, ctx->afu->adapter); +} +EXPORT_SYMBOL_GPL(cxl_free_afu_irqs); + int cxl_map_afu_irq(struct cxl_context *ctx, int num, irq_handler_t handler, void *cookie, char *name) { @@ -356,3 +377,11 @@ void cxl_perst_reloads_same_image(struct cxl_afu *afu, afu->adapter->perst_same_image = perst_reloads_same_image; } EXPORT_SYMBOL_GPL(cxl_perst_reloads_same_image); + +ssize_t cxl_read_adapter_vpd(struct pci_dev *dev, void *buf, size_t count) +{ + struct cxl_afu *afu = cxl_pci_to_afu(dev); + + return cxl_ops->read_adapter_vpd(afu->adapter, buf, count); +} +EXPORT_SYMBOL_GPL(cxl_read_adapter_vpd); diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index 0bf536c..6c2521c 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -581,6 +581,7 @@ int cxl_pci_setup_irq(struct cxl *adapter, unsigned int hwirq, unsigned int virq int cxl_update_image_control(struct cxl *adapter); int cxl_pci_reset(struct cxl *adapter); void cxl_pci_release_afu(struct device *dev); +ssize_t cxl_pci_read_adapter_vpd(struct cxl *adapter, void *buf, size_t len); /* common == phyp + powernv */ struct cxl_process_element_common { @@ -802,7 +803,6 @@ int cxl_psl_purge(struct cxl_afu *afu); void cxl_stop_trace(struct cxl *cxl); int cxl_pci_vphb_add(struct cxl_afu *afu); -void cxl_
Re: [PATCH v5 15/18] cxl: Parse device tree and create cxl device(s) at boot
Fred, Christophe: See comment below. --- Manoj Kumar On 2/23/2016 10:21 AM, Frederic Barrat wrote: +module_init(cxl_base_init); Is this a remnant from when there were two modules? Do you really need two module_init() calls (can't one be called from the other)? What is the tear-down portion of this (module_exit)? ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v5 14/18] cxl: Support to flash a new image on the adapter from a guest
Fred, Christophe: See comments below. -- Manoj Kumar On 2/23/2016 10:21 AM, Frederic Barrat wrote: From: Christophe Lombard <clomb...@linux.vnet.ibm.com> +#define CXL_DEV_MINORS 13 /* 1 control + 4 AFUs * 3 (dedicated/master/shared) */ Where does this limit of 4 AFUs come from? Is this related to CXL_MAX_SLICES? Should this be a computed value, in case the number of AFUs/slices is increased at a future date? +static int update_node(__be32 phandle, s32 scope) +{ + struct update_props_workarea *upwa; + struct device_node *dn; + int i, rc, ret; + char *prop_data; + char *buf; + int token; + u32 nprops; + u32 vd; + + token = rtas_token("ibm,update-properties"); + if (token == RTAS_UNKNOWN_SERVICE) + return -EINVAL; + + buf = kzalloc(RTAS_DATA_BUF_SIZE, GFP_KERNEL); + if (!buf) + return -ENOMEM; + memset(buf, 0, RTAS_DATA_BUF_SIZE); memset(0) after kzalloc() is redundant. +static int update_devicetree(struct cxl *adapter, s32 scope) +{ + struct update_nodes_workarea *unwa; + u32 action, node_count; + int token, rc, i; + __be32 *data, drc_index, phandle; + char *buf; + + token = rtas_token("ibm,update-nodes"); + if (token == RTAS_UNKNOWN_SERVICE) + return -EINVAL; + + buf = kzalloc(RTAS_DATA_BUF_SIZE, GFP_KERNEL); + if (!buf) + return -ENOMEM; + memset(buf, 0, RTAS_DATA_BUF_SIZE); Same as above ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v5 13/18] cxl: sysfs support for guests
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/23/2016 10:21 AM, Frederic Barrat wrote: From: Christophe Lombard <clomb...@linux.vnet.ibm.com> Filter out a few adapter parameters which don't make sense in a guest. Document the changes. Co-authored-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> --- Documentation/ABI/testing/sysfs-class-cxl | 8 +++ drivers/misc/cxl/cxl.h| 1 + drivers/misc/cxl/guest.c | 12 +++ drivers/misc/cxl/native.c | 6 ++ drivers/misc/cxl/sysfs.c | 36 +++ 5 files changed, 50 insertions(+), 13 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-class-cxl b/Documentation/ABI/testing/sysfs-class-cxl index b07e86d..4d0da47 100644 --- a/Documentation/ABI/testing/sysfs-class-cxl +++ b/Documentation/ABI/testing/sysfs-class-cxl @@ -183,7 +183,7 @@ Description:read only Identifies the revision level of the PSL. Users:https://github.com/ibm-capi/libcxl -What: /sys/class/cxl//base_image +What: /sys/class/cxl//base_image (not in a guest) Date: September 2014 Contact:linuxppc-dev@lists.ozlabs.org Description:read only @@ -193,7 +193,7 @@ Description:read only during the initial program load. Users:https://github.com/ibm-capi/libcxl -What: /sys/class/cxl//image_loaded +What: /sys/class/cxl//image_loaded (not in a guest) Date: September 2014 Contact:linuxppc-dev@lists.ozlabs.org Description:read only @@ -201,7 +201,7 @@ Description:read only onto the card. Users:https://github.com/ibm-capi/libcxl -What: /sys/class/cxl//load_image_on_perst +What: /sys/class/cxl//load_image_on_perst (not in a guest) Date: December 2014 Contact:linuxppc-dev@lists.ozlabs.org Description:read/write @@ -224,7 +224,7 @@ Description:write only to reload the FPGA depending on load_image_on_perst. Users:https://github.com/ibm-capi/libcxl -What: /sys/class/cxl//perst_reloads_same_image +What: /sys/class/cxl//perst_reloads_same_image (not in a guest) Date: July 2015 Contact: linuxppc-dev@lists.ozlabs.org Description: read/write diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index 4372a87..e54bf4f 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -844,6 +844,7 @@ struct cxl_backend_ops { int (*attach_process)(struct cxl_context *ctx, bool kernel, u64 wed, u64 amr); int (*detach_process)(struct cxl_context *ctx); + bool (*support_attributes)(const char *attr_name); bool (*link_ok)(struct cxl *cxl); void (*release_afu)(struct device *dev); ssize_t (*afu_read_err_buffer)(struct cxl_afu *afu, char *buf, diff --git a/drivers/misc/cxl/guest.c b/drivers/misc/cxl/guest.c index 03eb83d..d02ff03 100644 --- a/drivers/misc/cxl/guest.c +++ b/drivers/misc/cxl/guest.c @@ -596,6 +596,17 @@ static int guest_afu_check_and_enable(struct cxl_afu *afu) return 0; } +static bool guest_support_attributes(const char *attr_name) +{ + if ((strcmp(attr_name, "base_image") == 0) || + (strcmp(attr_name, "load_image_on_perst") == 0) || + (strcmp(attr_name, "perst_reloads_same_image") == 0) || + (strcmp(attr_name, "image_loaded") == 0)) + return false; + + return true; +} + static int activate_afu_directed(struct cxl_afu *afu) { int rc; @@ -936,6 +947,7 @@ const struct cxl_backend_ops cxl_guest_ops = { .ack_irq = guest_ack_irq, .attach_process = guest_attach_process, .detach_process = guest_detach_process, + .support_attributes = guest_support_attributes, .link_ok = guest_link_ok, .release_afu = guest_release_afu, .afu_read_err_buffer = guest_afu_read_err_buffer, diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c index c0bca59..acb9486 100644 --- a/drivers/misc/cxl/native.c +++ b/drivers/misc/cxl/native.c @@ -967,6 +967,11 @@ int cxl_check_error(struct cxl_afu *afu) return (cxl_p1n_read(afu, CXL_PSL_SCNTL_An) == ~0ULL); } +static bool native_support_attributes(const char *attr_name) +{ + return true; +} + static int native_afu_cr_read64(struct cxl_afu *afu, int cr, u64 off, u64 *out) { if (unlikely(!cxl_ops->link_ok(afu->adapter))) @@ -1026,6 +1031,7 @@ const struct cxl_backend_ops cxl_native_ops = { .ack_irq = native_ack_irq, .attach_proc
Re: [PATCH v5 12/18] cxl: Add guest-specific code
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/23/2016 10:21 AM, Frederic Barrat wrote: From: Christophe Lombard <clomb...@linux.vnet.ibm.com> The new of.c file contains code to parse the device tree to find out about cxl adapters and AFUs. guest.c implements the guest-specific callbacks for the backend API. The process element ID is not known until the context is attached, so we have to separate the context ID assigned by the cxl driver from the process element ID visible to the user applications. In bare-metal, the 2 IDs match. Co-authored-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> --- drivers/misc/cxl/Makefile | 1 + drivers/misc/cxl/api.c | 2 +- drivers/misc/cxl/context.c | 6 +- drivers/misc/cxl/cxl.h | 37 +- drivers/misc/cxl/file.c| 2 +- drivers/misc/cxl/guest.c | 950 + drivers/misc/cxl/main.c| 18 +- drivers/misc/cxl/of.c | 513 8 files changed, 1519 insertions(+), 10 deletions(-) create mode 100644 drivers/misc/cxl/guest.c create mode 100644 drivers/misc/cxl/of.c diff --git a/drivers/misc/cxl/Makefile b/drivers/misc/cxl/Makefile index be2ac5c..a3d4bef 100644 --- a/drivers/misc/cxl/Makefile +++ b/drivers/misc/cxl/Makefile @@ -4,6 +4,7 @@ ccflags-$(CONFIG_PPC_WERROR)+= -Werror cxl-y += main.o file.o irq.o fault.o native.o cxl-y += context.o sysfs.o debugfs.o pci.o trace.o cxl-y += vphb.o api.o +cxl-y += guest.o of.o hcalls.o obj-$(CONFIG_CXL) += cxl.o obj-$(CONFIG_CXL_BASE)+= base.o diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index 31eb842..325f957 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c @@ -191,7 +191,7 @@ EXPORT_SYMBOL_GPL(cxl_start_context); int cxl_process_element(struct cxl_context *ctx) { - return ctx->pe; + return ctx->external_pe; } EXPORT_SYMBOL_GPL(cxl_process_element); diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c index 200837f..180c85a 100644 --- a/drivers/misc/cxl/context.c +++ b/drivers/misc/cxl/context.c @@ -95,8 +95,12 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu *afu, bool master, return i; ctx->pe = i; - if (cpu_has_feature(CPU_FTR_HVMODE)) + if (cpu_has_feature(CPU_FTR_HVMODE)) { ctx->elem = >afu->native->spa[i]; + ctx->external_pe = ctx->pe; + } else { + ctx->external_pe = -1; /* assigned when attaching */ + } ctx->pe_inserted = false; /* diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index 3a1fabd..4372a87 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -433,6 +433,12 @@ struct cxl_irq_name { char *name; }; +struct irq_avail { + irq_hw_number_t offset; + irq_hw_number_t range; + unsigned long *bitmap; +}; + /* * This is a cxl context. If the PSL is in dedicated mode, there will be one * of these per AFU. If in AFU directed there can be lots of these. @@ -488,7 +494,19 @@ struct cxl_context { struct cxl_process_element *elem; - int pe; /* process element handle */ + /* +* pe is the process element handle, assigned by this driver when the +* context is initialized. +* +* external_pe is the PE shown outside of cxl. +* On bare-metal, pe=external_pe, because we decide what the handle is. +* In a guest, we only find out about the pe used by pHyp when the +* context is attached, and that's the value we want to report outside +* of cxl. +*/ + int pe; + int external_pe; + u32 irq_count; bool pe_inserted; bool master; @@ -782,6 +800,7 @@ void cxl_pci_vphb_reconfigure(struct cxl_afu *afu); void cxl_pci_vphb_remove(struct cxl_afu *afu); extern struct pci_driver cxl_pci_driver; +extern struct platform_driver cxl_of_driver; int afu_allocate_irqs(struct cxl_context *ctx, u32 count); int afu_open(struct inode *inode, struct file *file); @@ -792,6 +811,21 @@ unsigned int afu_poll(struct file *file, struct poll_table_struct *poll); ssize_t afu_read(struct file *file, char __user *buf, size_t count, loff_t *off); extern const struct file_operations afu_fops; +struct cxl *cxl_guest_init_adapter(struct device_node *np, struct platform_device *dev); +void cxl_guest_remove_adapter(struct cxl *adapter); +int cxl_of_read_adapter_handle(struct cxl *adapter, struct device_node *np); +int cxl_of_read_adapter_properties(struct cxl *adapter, struct device_node *np); +ssize_t cxl_guest_read_ad
Re: [PATCH v5 11/18] cxl: Separate bare-metal fields in adapter and AFU data structures
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/23/2016 10:21 AM, Frederic Barrat wrote: From: Christophe Lombard <clomb...@linux.vnet.ibm.com> Introduce sub-structures containing the bare-metal specific fields in the structures describing the adapter (struct cxl) and AFU (struct cxl_afu). Update all their references. Co-authored-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> --- drivers/misc/cxl/context.c | 2 +- drivers/misc/cxl/cxl.h | 84 +++- drivers/misc/cxl/irq.c | 2 +- drivers/misc/cxl/main.c| 1 - drivers/misc/cxl/native.c | 85 + drivers/misc/cxl/pci.c | 95 +++--- drivers/misc/cxl/sysfs.c | 2 +- drivers/misc/cxl/vphb.c| 4 +- 8 files changed, 164 insertions(+), 111 deletions(-) diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c index 46f9844..200837f 100644 --- a/drivers/misc/cxl/context.c +++ b/drivers/misc/cxl/context.c @@ -96,7 +96,7 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu *afu, bool master, ctx->pe = i; if (cpu_has_feature(CPU_FTR_HVMODE)) - ctx->elem = >afu->spa[i]; + ctx->elem = >afu->native->spa[i]; ctx->pe_inserted = false; /* diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index ac655a6..3a1fabd 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -344,18 +344,44 @@ struct cxl_sste { #define to_cxl_adapter(d) container_of(d, struct cxl, dev) #define to_cxl_afu(d) container_of(d, struct cxl_afu, dev) -struct cxl_afu { +struct cxl_afu_native { + void __iomem *p1n_mmio; + void __iomem *afu_desc_mmio; irq_hw_number_t psl_hwirq; + unsigned int psl_virq; + struct mutex spa_mutex; + /* +* Only the first part of the SPA is used for the process element +* linked list. The only other part that software needs to worry about +* is sw_command_status, which we store a separate pointer to. +* Everything else in the SPA is only used by hardware +*/ + struct cxl_process_element *spa; + __be64 *sw_command_status; + unsigned int spa_size; + int spa_order; + int spa_max_procs; + u64 pp_offset; +}; + +struct cxl_afu_guest { + u64 handle; + phys_addr_t p2n_phys; + u64 p2n_size; + int max_ints; +}; + +struct cxl_afu { + struct cxl_afu_native *native; + struct cxl_afu_guest *guest; irq_hw_number_t serr_hwirq; - char *err_irq_name; - char *psl_irq_name; unsigned int serr_virq; - void __iomem *p1n_mmio; + char *psl_irq_name; + char *err_irq_name; void __iomem *p2n_mmio; phys_addr_t psn_phys; - u64 pp_offset; u64 pp_size; - void __iomem *afu_desc_mmio; + struct cxl *adapter; struct device dev; struct cdev afu_cdev_s, afu_cdev_m, afu_cdev_d; @@ -363,26 +389,12 @@ struct cxl_afu { struct idr contexts_idr; struct dentry *debugfs; struct mutex contexts_lock; - struct mutex spa_mutex; spinlock_t afu_cntl_lock; /* AFU error buffer fields and bin attribute for sysfs */ u64 eb_len, eb_offset; struct bin_attribute attr_eb; - /* -* Only the first part of the SPA is used for the process element -* linked list. The only other part that software needs to worry about -* is sw_command_status, which we store a separate pointer to. -* Everything else in the SPA is only used by hardware -*/ - struct cxl_process_element *spa; - __be64 *sw_command_status; - unsigned int spa_size; - int spa_order; - int spa_max_procs; - unsigned int psl_virq; - /* pointer to the vphb */ struct pci_controller *phb; @@ -488,11 +500,34 @@ struct cxl_context { struct rcu_head rcu; }; -struct cxl { +struct cxl_native { + u64 afu_desc_off; + u64 afu_desc_size; void __iomem *p1_mmio; void __iomem *p2_mmio; irq_hw_number_t err_hwirq; unsigned int err_virq; + u64 ps_off; +}; + +struct cxl_guest { + struct platform_device *pdev; + int irq_nranges; + struct cdev cdev; + irq_hw_number_t irq_base_offset; + struct irq_avail *irq_avail; + spinlock_t irq_alloc_lock; + u64 handle; + char *status; + u16 vendor; + u16 device; + u16 subsystem_vendor; + u16 subsystem; +}; + +struct cxl { + struct cxl_native *native; + struct cxl_guest *guest; spinlock_t afu_list_lock; struct cxl_afu *afu[CXL_MAX_SLICE
Re: [PATCH v5 10/18] cxl: New hcalls to support cxl adapters
Fred: Thanks for correcting those spellings. Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/23/2016 10:21 AM, Frederic Barrat wrote: From: Christophe Lombard <clomb...@linux.vnet.ibm.com> The hypervisor calls provide an interface with a coherent platform facility and function. It matches version 0.16 of the 'PAPR changes' document. The following hcalls are supported: H_ATTACH_CA_PROCESSAttach a process element to a coherent platform function. H_DETACH_CA_PROCESSDetach a process element from a coherent platform function. H_CONTROL_CA_FUNCTION Allow the partition to manipulate or query certain coherent platform function behaviors. H_COLLECT_CA_INT_INFO Collect interrupt info about a coherent. platform function after an interrupt occurred H_CONTROL_CA_FAULTSControl the operation of a coherent platform function after a fault occurs. H_DOWNLOAD_CA_FACILITY Support for downloading a base adapter image to the coherent platform facility, and for validating the entire image after the download. H_CONTROL_CA_FACILITY Allow the partition to manipulate or query certain coherent platform facility behaviors. Co-authored-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> --- drivers/misc/cxl/cxl.h| 23 +- drivers/misc/cxl/hcalls.c | 639 ++ drivers/misc/cxl/hcalls.h | 203 +++ drivers/misc/cxl/main.c | 26 ++ drivers/misc/cxl/native.c | 1 + 5 files changed, 890 insertions(+), 2 deletions(-) create mode 100644 drivers/misc/cxl/hcalls.c create mode 100644 drivers/misc/cxl/hcalls.h diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index c7ed265..ac655a6 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -688,6 +688,7 @@ void cxl_prefault(struct cxl_context *ctx, u64 wed); struct cxl *get_cxl_adapter(int num); int cxl_alloc_sst(struct cxl_context *ctx); +void cxl_dump_debug_buffer(void *addr, size_t size); void init_cxl_native(void); @@ -701,16 +702,34 @@ unsigned int cxl_map_irq(struct cxl *adapter, irq_hw_number_t hwirq, void cxl_unmap_irq(unsigned int virq, void *cookie); int __detach_context(struct cxl_context *ctx); -/* This matches the layout of the H_COLLECT_CA_INT_INFO retbuf */ +/* + * This must match the layout of the H_COLLECT_CA_INT_INFO retbuf defined + * in PAPR. + * A word about endianness: a pointer to this structure is passed when + * calling the hcall. However, it is not a block of memory filled up by + * the hypervisor. The return values are found in registers, and copied + * one by one when returning from the hcall. See the end of the call to + * plpar_hcall9() in hvCall.S + * As a consequence: + * - we don't need to do any endianness conversion + * - the pid and tid are an exception. They are 32-bit values returned in + * the same 64-bit register. So we do need to worry about byte ordering. + */ struct cxl_irq_info { u64 dsisr; u64 dar; u64 dsr; +#ifndef CONFIG_CPU_LITTLE_ENDIAN u32 pid; u32 tid; +#else + u32 tid; + u32 pid; +#endif u64 afu_err; u64 errstat; - u64 padding[3]; /* to match the expected retbuf size for plpar_hcall9 */ + u64 proc_handle; + u64 padding[2]; /* to match the expected retbuf size for plpar_hcall9 */ }; void cxl_assign_psn_space(struct cxl_context *ctx); diff --git a/drivers/misc/cxl/hcalls.c b/drivers/misc/cxl/hcalls.c new file mode 100644 index 000..7e4c517 --- /dev/null +++ b/drivers/misc/cxl/hcalls.c @@ -0,0 +1,639 @@ +/* + * Copyright 2015 IBM Corp. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + + +#include +#include +#include +#include +#include +#include "hcalls.h" + +#define CXL_HCALL_TIMEOUT 6 +#define CXL_HCALL_TIMEOUT_DOWNLOAD 12 + +#define H_ATTACH_CA_PROCESS0x344 +#define H_CONTROL_CA_FUNCTION 0x348 +#define H_DETACH_CA_PROCESS0x34C +#define H_COLLECT_CA_INT_INFO 0x350 +#define H_CONTROL_CA_FAULTS0x354 +#define H_DOWNLOAD_CA_FUNCTION 0x35C +#define H_DOWNLOAD_CA_FACILITY 0x364 +#define H_CONTROL_CA_FACILITY 0x368 + +#define H_CONTROL_CA_FUNCTION_RESET 1 /* perform a reset */ +#define H_CONTROL_CA_FUNCTION_SUSPEND_PROCESS 2 /* suspend a process from being executed */ +#define H_CONTROL_CA_FUNCTION_RESUME_PROCESS 3 /* resume a process to be executed */ +#define H_CONTROL_CA_FU
Re: [PATCH v5 09/18] cxl: New possible return value from hcall
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/23/2016 10:21 AM, Frederic Barrat wrote: From: Christophe Lombard <clomb...@linux.vnet.ibm.com> The hcalls introduced for cxl use a possible new value: H_STATE (invalid state). Co-authored-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Acked-by: Ian Munsie <imun...@au1.ibm.com> --- arch/powerpc/include/asm/hvcall.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/include/asm/hvcall.h b/arch/powerpc/include/asm/hvcall.h index e3b54dd..0bc9c28 100644 --- a/arch/powerpc/include/asm/hvcall.h +++ b/arch/powerpc/include/asm/hvcall.h @@ -94,6 +94,7 @@ #define H_SG_LIST -72 #define H_OP_MODE -73 #define H_COP_HW -74 +#define H_STATE-75 #define H_UNSUPPORTED_FLAG_START -256 #define H_UNSUPPORTED_FLAG_END-511 #define H_MULTI_THREADS_ACTIVE-9005 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v5 08/18] cxl: IRQ allocation for guests
Fred: Thanks for revising the commit message. Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/23/2016 10:21 AM, Frederic Barrat wrote: The PSL interrupt cannot be multiplexed in a guest, as it is not supported by the hypervisor. So an interrupt will be allocated for it for each context. It will still be the first interrupt found in the first interrupt range, but is treated almost like any other AFU interrupt when creating/deleting the context. Only the handler is different. Rework the code so that the range 0 is treated like the other ranges. Co-authored-by: Christophe Lombard<clomb...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat<fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard<clomb...@linux.vnet.ibm.com> --- drivers/misc/cxl/irq.c | 78 +- 1 file changed, 64 insertions(+), 14 deletions(-) diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c index 5033869..3c04c14 100644 --- a/drivers/misc/cxl/irq.c +++ b/drivers/misc/cxl/irq.c @@ -19,6 +19,13 @@ #include "cxl.h" #include "trace.h" +static int afu_irq_range_start(void) +{ + if (cpu_has_feature(CPU_FTR_HVMODE)) + return 1; + return 0; +} + static irqreturn_t schedule_cxl_fault(struct cxl_context *ctx, u64 dsisr, u64 dar) { ctx->dsisr = dsisr; @@ -117,11 +124,23 @@ static irqreturn_t cxl_irq_afu(int irq, void *data) { struct cxl_context *ctx = data; irq_hw_number_t hwirq = irqd_to_hwirq(irq_get_irq_data(irq)); - int irq_off, afu_irq = 1; + int irq_off, afu_irq = 0; __u16 range; int r; - for (r = 1; r < CXL_IRQ_RANGES; r++) { + /* +* Look for the interrupt number. +* On bare-metal, we know range 0 only contains the PSL +* interrupt so we could start counting at range 1 and initialize +* afu_irq at 1. +* In a guest, range 0 also contains AFU interrupts, so it must +* be counted for. Therefore we initialize afu_irq at 0 to take into +* account the PSL interrupt. +* +* For code-readability, it just seems easier to go over all +* the ranges on bare-metal and guest. The end result is the same. +*/ + for (r = 0; r < CXL_IRQ_RANGES; r++) { irq_off = hwirq - ctx->irqs.offset[r]; range = ctx->irqs.range[r]; if (irq_off >= 0 && irq_off < range) { @@ -131,7 +150,7 @@ static irqreturn_t cxl_irq_afu(int irq, void *data) afu_irq += range; } if (unlikely(r >= CXL_IRQ_RANGES)) { - WARN(1, "Recieved AFU IRQ out of range for pe %i (virq %i hwirq %lx)\n", + WARN(1, "Received AFU IRQ out of range for pe %i (virq %i hwirq %lx)\n", ctx->pe, irq, hwirq); return IRQ_HANDLED; } @@ -141,7 +160,7 @@ static irqreturn_t cxl_irq_afu(int irq, void *data) afu_irq, ctx->pe, irq, hwirq); if (unlikely(!ctx->irq_bitmap)) { - WARN(1, "Recieved AFU IRQ for context with no IRQ bitmap\n"); + WARN(1, "Received AFU IRQ for context with no IRQ bitmap\n"); return IRQ_HANDLED; } spin_lock(>lock); @@ -227,17 +246,33 @@ int afu_allocate_irqs(struct cxl_context *ctx, u32 count) { int rc, r, i, j = 1; struct cxl_irq_name *irq_name; + int alloc_count; + + /* +* In native mode, range 0 is reserved for the multiplexed +* PSL interrupt. It has been allocated when the AFU was initialized. +* +* In a guest, the PSL interrupt is not mutliplexed, but per-context, +* and is the first interrupt from range 0. It still needs to be +* allocated, so bump the count by one. +*/ + if (cpu_has_feature(CPU_FTR_HVMODE)) + alloc_count = count; + else + alloc_count = count + 1; /* Initialize the list head to hold irq names */ INIT_LIST_HEAD(>irq_names); if ((rc = cxl_ops->alloc_irq_ranges(>irqs, ctx->afu->adapter, - count))) + alloc_count))) return rc; - /* Multiplexed PSL Interrupt */ - ctx->irqs.offset[0] = ctx->afu->psl_hwirq; - ctx->irqs.range[0] = 1; + if (cpu_has_feature(CPU_FTR_HVMODE)) { + /* Multiplexed PSL Interrupt */ + ctx->irqs.offset[0] = ctx->afu->psl_hwirq; + ctx->irqs.range[0] = 1; + } ctx->irq_count = count; ctx->irq_bitmap = kcalloc(BITS_TO_LONGS(count), @@ -249,7 +284,7 @@ int afu_allocate_irqs(struct cxl_context *ctx, u32 count)
Re: [PATCH v5 07/18] cxl: Update cxl_irq() prototype
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/23/2016 10:21 AM, Frederic Barrat wrote: The context parameter when calling cxl_irq() should be strongly typed. Co-authored-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Acked-by: Ian Munsie <imun...@au1.ibm.com> --- drivers/misc/cxl/cxl.h | 2 +- drivers/misc/cxl/irq.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index 40f6783..c7ed265 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -714,7 +714,7 @@ struct cxl_irq_info { }; void cxl_assign_psn_space(struct cxl_context *ctx); -irqreturn_t cxl_irq(int irq, void *ctx, struct cxl_irq_info *irq_info); +irqreturn_t cxl_irq(int irq, struct cxl_context *ctx, struct cxl_irq_info *irq_info); int cxl_register_one_irq(struct cxl *adapter, irq_handler_t handler, void *cookie, irq_hw_number_t *dest_hwirq, unsigned int *dest_virq, const char *name); diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c index 56ad301..5033869 100644 --- a/drivers/misc/cxl/irq.c +++ b/drivers/misc/cxl/irq.c @@ -27,9 +27,8 @@ static irqreturn_t schedule_cxl_fault(struct cxl_context *ctx, u64 dsisr, u64 da return IRQ_HANDLED; } -irqreturn_t cxl_irq(int irq, void *data, struct cxl_irq_info *irq_info) +irqreturn_t cxl_irq(int irq, struct cxl_context *ctx, struct cxl_irq_info *irq_info) { - struct cxl_context *ctx = data; u64 dsisr, dar; dsisr = irq_info->dsisr; ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v5 06/18] cxl: Isolate a few bare-metal-specific calls
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/23/2016 10:21 AM, Frederic Barrat wrote: A few functions are mostly common between bare-metal and guest and just need minor tuning. To avoid crowding the backend API, introduce a few 'if' based on the CPU being in HV mode. Co-authored-by: Christophe Lombard<clomb...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat<fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard<clomb...@linux.vnet.ibm.com> Acked-by: Ian Munsie<imun...@au1.ibm.com> --- drivers/misc/cxl/context.c | 3 ++- drivers/misc/cxl/cxl.h | 7 +-- drivers/misc/cxl/debugfs.c | 4 drivers/misc/cxl/fault.c | 19 +++ 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c index aa65262..46f9844 100644 --- a/drivers/misc/cxl/context.c +++ b/drivers/misc/cxl/context.c @@ -95,7 +95,8 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu *afu, bool master, return i; ctx->pe = i; - ctx->elem = >afu->spa[i]; + if (cpu_has_feature(CPU_FTR_HVMODE)) + ctx->elem = >afu->spa[i]; ctx->pe_inserted = false; /* diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index 02065b4..40f6783 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -560,8 +560,11 @@ static inline bool cxl_adapter_link_ok(struct cxl *cxl) { struct pci_dev *pdev; - pdev = to_pci_dev(cxl->dev.parent); - return !pci_channel_offline(pdev); + if (cpu_has_feature(CPU_FTR_HVMODE)) { + pdev = to_pci_dev(cxl->dev.parent); + return !pci_channel_offline(pdev); + } + return true; } static inline void __iomem *_cxl_p1_addr(struct cxl *cxl, cxl_p1_reg_t reg) diff --git a/drivers/misc/cxl/debugfs.c b/drivers/misc/cxl/debugfs.c index 18df6f4..5751899 100644 --- a/drivers/misc/cxl/debugfs.c +++ b/drivers/misc/cxl/debugfs.c @@ -118,6 +118,10 @@ void cxl_debugfs_afu_remove(struct cxl_afu *afu) int __init cxl_debugfs_init(void) { struct dentry *ent; + + if (!cpu_has_feature(CPU_FTR_HVMODE)) + return 0; + ent = debugfs_create_dir("cxl", NULL); if (IS_ERR(ent)) return PTR_ERR(ent); diff --git a/drivers/misc/cxl/fault.c b/drivers/misc/cxl/fault.c index ab740a1..9a8650b 100644 --- a/drivers/misc/cxl/fault.c +++ b/drivers/misc/cxl/fault.c @@ -254,14 +254,17 @@ void cxl_handle_fault(struct work_struct *fault_work) u64 dar = ctx->dar; struct mm_struct *mm = NULL; - if (cxl_p2n_read(ctx->afu, CXL_PSL_DSISR_An) != dsisr || - cxl_p2n_read(ctx->afu, CXL_PSL_DAR_An) != dar || - cxl_p2n_read(ctx->afu, CXL_PSL_PEHandle_An) != ctx->pe) { - /* Most likely explanation is harmless - a dedicated process -* has detached and these were cleared by the PSL purge, but -* warn about it just in case */ - dev_notice(>afu->dev, "cxl_handle_fault: Translation fault regs changed\n"); - return; + if (cpu_has_feature(CPU_FTR_HVMODE)) { + if (cxl_p2n_read(ctx->afu, CXL_PSL_DSISR_An) != dsisr || + cxl_p2n_read(ctx->afu, CXL_PSL_DAR_An) != dar || + cxl_p2n_read(ctx->afu, CXL_PSL_PEHandle_An) != ctx->pe) { + /* Most likely explanation is harmless - a dedicated +* process has detached and these were cleared by the +* PSL purge, but warn about it just in case +*/ + dev_notice(>afu->dev, "cxl_handle_fault: Translation fault regs changed\n"); + return; + } } /* Early return if the context is being / has been detached */ ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v5 05/18] cxl: Rename some bare-metal specific functions
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/23/2016 10:21 AM, Frederic Barrat wrote: Rename a few functions, changing the 'cxl_' prefix to either 'cxl_pci_' or 'cxl_native_', to make clear that the implementation is bare-metal specific. Those functions will have an equivalent implementation for a guest in a later patch. Co-authored-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> --- drivers/misc/cxl/cxl.h| 28 +++--- drivers/misc/cxl/native.c | 98 --- drivers/misc/cxl/pci.c| 78 +++-- 3 files changed, 104 insertions(+), 100 deletions(-) diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index 8233af3..02065b4 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -519,14 +519,14 @@ struct cxl { bool perst_same_image; }; -int cxl_alloc_one_irq(struct cxl *adapter); -void cxl_release_one_irq(struct cxl *adapter, int hwirq); -int cxl_alloc_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter, unsigned int num); -void cxl_release_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter); -int cxl_setup_irq(struct cxl *adapter, unsigned int hwirq, unsigned int virq); +int cxl_pci_alloc_one_irq(struct cxl *adapter); +void cxl_pci_release_one_irq(struct cxl *adapter, int hwirq); +int cxl_pci_alloc_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter, unsigned int num); +void cxl_pci_release_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter); +int cxl_pci_setup_irq(struct cxl *adapter, unsigned int hwirq, unsigned int virq); int cxl_update_image_control(struct cxl *adapter); -int cxl_reset(struct cxl *adapter); -void cxl_release_afu(struct device *dev); +int cxl_pci_reset(struct cxl *adapter); +void cxl_pci_release_afu(struct device *dev); /* common == phyp + powernv */ struct cxl_process_element_common { @@ -623,7 +623,7 @@ static inline u64 cxl_p2n_read(struct cxl_afu *afu, cxl_p2n_reg_t reg) return ~0ULL; } -ssize_t cxl_afu_read_err_buffer(struct cxl_afu *afu, char *buf, +ssize_t cxl_pci_afu_read_err_buffer(struct cxl_afu *afu, char *buf, loff_t off, size_t count); @@ -663,12 +663,12 @@ struct cxl *cxl_alloc_adapter(void); struct cxl_afu *cxl_alloc_afu(struct cxl *adapter, int slice); int cxl_afu_select_best_mode(struct cxl_afu *afu); -int cxl_register_psl_irq(struct cxl_afu *afu); -void cxl_release_psl_irq(struct cxl_afu *afu); -int cxl_register_psl_err_irq(struct cxl *adapter); -void cxl_release_psl_err_irq(struct cxl *adapter); -int cxl_register_serr_irq(struct cxl_afu *afu); -void cxl_release_serr_irq(struct cxl_afu *afu); +int cxl_native_register_psl_irq(struct cxl_afu *afu); +void cxl_native_release_psl_irq(struct cxl_afu *afu); +int cxl_native_register_psl_err_irq(struct cxl *adapter); +void cxl_native_release_psl_err_irq(struct cxl *adapter); +int cxl_native_register_serr_irq(struct cxl_afu *afu); +void cxl_native_release_serr_irq(struct cxl_afu *afu); int afu_register_irqs(struct cxl_context *ctx, u32 count); void afu_release_irqs(struct cxl_context *ctx, void *cookie); void afu_irq_name_free(struct cxl_context *ctx); diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c index 16d3b1a..b8a6ad5 100644 --- a/drivers/misc/cxl/native.c +++ b/drivers/misc/cxl/native.c @@ -80,7 +80,7 @@ int cxl_afu_disable(struct cxl_afu *afu) } /* This will disable as well as reset */ -static int __cxl_afu_reset(struct cxl_afu *afu) +static int native_afu_reset(struct cxl_afu *afu) { pr_devel("AFU reset request\n"); @@ -90,7 +90,7 @@ static int __cxl_afu_reset(struct cxl_afu *afu) false); } -static int cxl_afu_check_and_enable(struct cxl_afu *afu) +static int native_afu_check_and_enable(struct cxl_afu *afu) { if (!cxl_ops->link_ok(afu->adapter)) { WARN(1, "Refusing to enable afu while link down!\n"); @@ -631,7 +631,7 @@ static int deactivate_dedicated_process(struct cxl_afu *afu) return 0; } -static int cxl_afu_deactivate_mode(struct cxl_afu *afu, int mode) +static int native_afu_deactivate_mode(struct cxl_afu *afu, int mode) { if (mode == CXL_MODE_DIRECTED) return deactivate_afu_directed(afu); @@ -640,7 +640,7 @@ static int cxl_afu_deactivate_mode(struct cxl_afu *afu, int mode) return 0; } -static int cxl_afu_activate_mode(struct cxl_afu *afu, int mode) +static int native_afu_activate_mode(struct cxl_afu *afu, int mode) { if (!mode) return 0; @@ -660,7 +660,8 @@ static int cxl_afu_activate_mode(struct cxl_afu *afu, int mode) return -EINVAL; } -static int cxl_attach_process(struct cxl_context
Re: [PATCH v5 04/18] cxl: Introduce implementation-specific API
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/23/2016 10:21 AM, Frederic Barrat wrote: The backend API (in cxl.h) lists some low-level functions whose implementation is different on bare-metal and in a guest. Each environment implements its own functions, and the common code uses them through function pointers, defined in cxl_backend_ops Co-authored-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Acked-by: Ian Munsie <imun...@au1.ibm.com> --- drivers/misc/cxl/api.c | 8 +-- drivers/misc/cxl/context.c | 4 +- drivers/misc/cxl/cxl.h | 53 +++--- drivers/misc/cxl/fault.c | 6 +- drivers/misc/cxl/file.c| 15 ++--- drivers/misc/cxl/irq.c | 19 --- drivers/misc/cxl/main.c| 11 ++-- drivers/misc/cxl/native.c | 135 - drivers/misc/cxl/pci.c | 16 +++--- drivers/misc/cxl/sysfs.c | 32 +++ drivers/misc/cxl/vphb.c| 6 +- 11 files changed, 185 insertions(+), 120 deletions(-) diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index b45d857..31eb842 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c @@ -100,7 +100,7 @@ EXPORT_SYMBOL_GPL(cxl_allocate_afu_irqs); void cxl_free_afu_irqs(struct cxl_context *ctx) { afu_irq_name_free(ctx); - cxl_release_irq_ranges(>irqs, ctx->afu->adapter); + cxl_ops->release_irq_ranges(>irqs, ctx->afu->adapter); } EXPORT_SYMBOL_GPL(cxl_free_afu_irqs); @@ -176,7 +176,7 @@ int cxl_start_context(struct cxl_context *ctx, u64 wed, cxl_ctx_get(); - if ((rc = cxl_attach_process(ctx, kernel, wed , 0))) { + if ((rc = cxl_ops->attach_process(ctx, kernel, wed, 0))) { put_pid(ctx->pid); cxl_ctx_put(); goto out; @@ -342,11 +342,11 @@ int cxl_afu_reset(struct cxl_context *ctx) struct cxl_afu *afu = ctx->afu; int rc; - rc = __cxl_afu_reset(afu); + rc = cxl_ops->afu_reset(afu); if (rc) return rc; - return cxl_afu_check_and_enable(afu); + return cxl_ops->afu_check_and_enable(afu); } EXPORT_SYMBOL_GPL(cxl_afu_reset); diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c index 262b88e..aa65262 100644 --- a/drivers/misc/cxl/context.c +++ b/drivers/misc/cxl/context.c @@ -214,8 +214,8 @@ int __detach_context(struct cxl_context *ctx) /* Only warn if we detached while the link was OK. * If detach fails when hw is down, we don't care. */ - WARN_ON(cxl_detach_process(ctx) && - cxl_adapter_link_ok(ctx->afu->adapter)); + WARN_ON(cxl_ops->detach_process(ctx) && + cxl_ops->link_ok(ctx->afu->adapter)); flush_work(>fault_work); /* Only needed for dedicated process */ /* release the reference to the group leader and mm handling pid */ diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index 3b824e3..8233af3 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -623,11 +623,6 @@ static inline u64 cxl_p2n_read(struct cxl_afu *afu, cxl_p2n_reg_t reg) return ~0ULL; } -u64 cxl_afu_cr_read64(struct cxl_afu *afu, int cr, u64 off); -u32 cxl_afu_cr_read32(struct cxl_afu *afu, int cr, u64 off); -u16 cxl_afu_cr_read16(struct cxl_afu *afu, int cr, u64 off); -u8 cxl_afu_cr_read8(struct cxl_afu *afu, int cr, u64 off); - ssize_t cxl_afu_read_err_buffer(struct cxl_afu *afu, char *buf, loff_t off, size_t count); @@ -666,10 +661,6 @@ void cxl_sysfs_afu_m_remove(struct cxl_afu *afu); struct cxl *cxl_alloc_adapter(void); struct cxl_afu *cxl_alloc_afu(struct cxl *adapter, int slice); - -int cxl_afu_activate_mode(struct cxl_afu *afu, int mode); -int _cxl_afu_deactivate_mode(struct cxl_afu *afu, int mode); -int cxl_afu_deactivate_mode(struct cxl_afu *afu); int cxl_afu_select_best_mode(struct cxl_afu *afu); int cxl_register_psl_irq(struct cxl_afu *afu); @@ -681,8 +672,6 @@ void cxl_release_serr_irq(struct cxl_afu *afu); int afu_register_irqs(struct cxl_context *ctx, u32 count); void afu_release_irqs(struct cxl_context *ctx, void *cookie); void afu_irq_name_free(struct cxl_context *ctx); -irqreturn_t handle_psl_slice_error(struct cxl_context *ctx, u64 dsisr, - u64 errstat); int cxl_debugfs_init(void); void cxl_debugfs_exit(void); @@ -727,18 +716,10 @@ int cxl_register_one_irq(struct cxl *adapter, irq_handler_t handler, void *cookie, irq_hw_number_t *dest_hwirq, unsigned int *dest_virq, const char *name); -int cxl_attach_process(struct cxl_context *ctx, bool kernel, u64 wed, -
Re: [PATCH v5 03/18] cxl: Define process problem state area at attach time only
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/23/2016 10:21 AM, Frederic Barrat wrote: CXL kernel API was defining the process problem state area during context initialization, making it possible to map the problem state area before attaching the context. This won't work on a powerVM guest. So force the logical behavior, like in userspace: attach first, then map the problem state area. Remove calls to cxl_assign_psn_space during init. The function is already called on the attach paths. Co-authored-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> --- drivers/misc/cxl/api.c | 11 ++- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index ea3eeb7..b45d857 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c @@ -51,8 +51,6 @@ struct cxl_context *cxl_dev_context_init(struct pci_dev *dev) if (rc) goto err_mapping; - cxl_assign_psn_space(ctx); - return ctx; err_mapping: @@ -207,7 +205,6 @@ EXPORT_SYMBOL_GPL(cxl_stop_context); void cxl_set_master(struct cxl_context *ctx) { ctx->master = true; - cxl_assign_psn_space(ctx); } EXPORT_SYMBOL_GPL(cxl_set_master); @@ -325,15 +322,11 @@ EXPORT_SYMBOL_GPL(cxl_start_work); void __iomem *cxl_psa_map(struct cxl_context *ctx) { - struct cxl_afu *afu = ctx->afu; - int rc; - - rc = cxl_afu_check_and_enable(afu); - if (rc) + if (ctx->status != STARTED) return NULL; pr_devel("%s: psn_phys%llx size:%llx\n", -__func__, afu->psn_phys, afu->adapter->ps_size); + __func__, ctx->psn_phys, ctx->psn_size); return ioremap(ctx->psn_phys, ctx->psn_size); } EXPORT_SYMBOL_GPL(cxl_psa_map); ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v5 02/18] cxl: Move bare-metal specific code to specialized files
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/23/2016 10:21 AM, Frederic Barrat wrote: Move a few functions around to better separate code specific to bare-metal environment from code which will be commonly used between guest and bare-metal. Code specific to bare-metal is meant to be in native.c or pci.c only. It's basically anything which touches the card p1 registers, some p2 registers not needed from a guest and the PCI interface. Co-authored-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Acked-by: Ian Munsie <imun...@au1.ibm.com> --- drivers/misc/cxl/cxl.h| 24 + drivers/misc/cxl/irq.c| 205 +-- drivers/misc/cxl/main.c | 2 +- drivers/misc/cxl/native.c | 240 +- drivers/misc/cxl/pci.c| 18 5 files changed, 245 insertions(+), 244 deletions(-) diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index 3f88140..3b824e3 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -623,23 +623,8 @@ static inline u64 cxl_p2n_read(struct cxl_afu *afu, cxl_p2n_reg_t reg) return ~0ULL; } -static inline u64 cxl_afu_cr_read64(struct cxl_afu *afu, int cr, u64 off) -{ - if (likely(cxl_adapter_link_ok(afu->adapter))) - return in_le64((afu)->afu_desc_mmio + (afu)->crs_offset + - ((cr) * (afu)->crs_len) + (off)); - else - return ~0ULL; -} - -static inline u32 cxl_afu_cr_read32(struct cxl_afu *afu, int cr, u64 off) -{ - if (likely(cxl_adapter_link_ok(afu->adapter))) - return in_le32((afu)->afu_desc_mmio + (afu)->crs_offset + - ((cr) * (afu)->crs_len) + (off)); - else - return 0x; -} +u64 cxl_afu_cr_read64(struct cxl_afu *afu, int cr, u64 off); +u32 cxl_afu_cr_read32(struct cxl_afu *afu, int cr, u64 off); u16 cxl_afu_cr_read16(struct cxl_afu *afu, int cr, u64 off); u8 cxl_afu_cr_read8(struct cxl_afu *afu, int cr, u64 off); @@ -654,7 +639,6 @@ struct cxl_calls { int register_cxl_calls(struct cxl_calls *calls); void unregister_cxl_calls(struct cxl_calls *calls); -int cxl_alloc_adapter_nr(struct cxl *adapter); void cxl_remove_adapter_nr(struct cxl *adapter); int cxl_alloc_spa(struct cxl_afu *afu); @@ -697,7 +681,8 @@ void cxl_release_serr_irq(struct cxl_afu *afu); int afu_register_irqs(struct cxl_context *ctx, u32 count); void afu_release_irqs(struct cxl_context *ctx, void *cookie); void afu_irq_name_free(struct cxl_context *ctx); -irqreturn_t cxl_slice_irq_err(int irq, void *data); +irqreturn_t handle_psl_slice_error(struct cxl_context *ctx, u64 dsisr, + u64 errstat); int cxl_debugfs_init(void); void cxl_debugfs_exit(void); @@ -746,7 +731,6 @@ int cxl_attach_process(struct cxl_context *ctx, bool kernel, u64 wed, u64 amr); int cxl_detach_process(struct cxl_context *ctx); -int cxl_get_irq(struct cxl_afu *afu, struct cxl_irq_info *info); int cxl_ack_irq(struct cxl_context *ctx, u64 tfc, u64 psl_reset_mask); int cxl_check_error(struct cxl_afu *afu); diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c index e468e6c..16fd67f 100644 --- a/drivers/misc/cxl/irq.c +++ b/drivers/misc/cxl/irq.c @@ -19,72 +19,6 @@ #include "cxl.h" #include "trace.h" -/* XXX: This is implementation specific */ -static irqreturn_t handle_psl_slice_error(struct cxl_context *ctx, u64 dsisr, u64 errstat) -{ - u64 fir1, fir2, fir_slice, serr, afu_debug; - - fir1 = cxl_p1_read(ctx->afu->adapter, CXL_PSL_FIR1); - fir2 = cxl_p1_read(ctx->afu->adapter, CXL_PSL_FIR2); - fir_slice = cxl_p1n_read(ctx->afu, CXL_PSL_FIR_SLICE_An); - serr = cxl_p1n_read(ctx->afu, CXL_PSL_SERR_An); - afu_debug = cxl_p1n_read(ctx->afu, CXL_AFU_DEBUG_An); - - dev_crit(>afu->dev, "PSL ERROR STATUS: 0x%016llx\n", errstat); - dev_crit(>afu->dev, "PSL_FIR1: 0x%016llx\n", fir1); - dev_crit(>afu->dev, "PSL_FIR2: 0x%016llx\n", fir2); - dev_crit(>afu->dev, "PSL_SERR_An: 0x%016llx\n", serr); - dev_crit(>afu->dev, "PSL_FIR_SLICE_An: 0x%016llx\n", fir_slice); - dev_crit(>afu->dev, "CXL_PSL_AFU_DEBUG_An: 0x%016llx\n", afu_debug); - - dev_crit(>afu->dev, "STOPPING CXL TRACE\n"); - cxl_stop_trace(ctx->afu->adapter); - - return cxl_ack_irq(ctx, 0, errstat); -} - -irqreturn_t cxl_slice_irq_err(int irq, void *data) -{ - struct cxl_afu *afu = data; - u64 fir_slice, errstat, serr, afu_debug; - - WARN(irq, "CXL SLICE
Re: [PATCH v5 01/18] cxl: Move common code away from bare-metal-specific files
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/23/2016 10:21 AM, Frederic Barrat wrote: From: Christophe Lombard <clomb...@linux.vnet.ibm.com> Move around some functions which will be accessed from the bare-metal and guest environments. Code in native.c and pci.c is meant to be bare-metal specific. Other files contain code which may be shared with guests. Co-authored-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Acked-by: Ian Munsie <imun...@au1.ibm.com> --- drivers/misc/cxl/cxl.h| 9 +++ drivers/misc/cxl/irq.c| 14 +- drivers/misc/cxl/main.c | 67 +++ drivers/misc/cxl/native.c | 21 --- drivers/misc/cxl/pci.c| 48 + 5 files changed, 84 insertions(+), 75 deletions(-) diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index a521bc7..3f88140 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -526,6 +526,7 @@ void cxl_release_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter); int cxl_setup_irq(struct cxl *adapter, unsigned int hwirq, unsigned int virq); int cxl_update_image_control(struct cxl *adapter); int cxl_reset(struct cxl *adapter); +void cxl_release_afu(struct device *dev); /* common == phyp + powernv */ struct cxl_process_element_common { @@ -679,6 +680,9 @@ void cxl_sysfs_afu_remove(struct cxl_afu *afu); int cxl_sysfs_afu_m_add(struct cxl_afu *afu); void cxl_sysfs_afu_m_remove(struct cxl_afu *afu); +struct cxl *cxl_alloc_adapter(void); +struct cxl_afu *cxl_alloc_afu(struct cxl *adapter, int slice); + int cxl_afu_activate_mode(struct cxl_afu *afu, int mode); int _cxl_afu_deactivate_mode(struct cxl_afu *afu, int mode); int cxl_afu_deactivate_mode(struct cxl_afu *afu); @@ -733,6 +737,11 @@ struct cxl_irq_info { }; void cxl_assign_psn_space(struct cxl_context *ctx); +irqreturn_t cxl_irq(int irq, void *ctx, struct cxl_irq_info *irq_info); +int cxl_register_one_irq(struct cxl *adapter, irq_handler_t handler, + void *cookie, irq_hw_number_t *dest_hwirq, + unsigned int *dest_virq, const char *name); + int cxl_attach_process(struct cxl_context *ctx, bool kernel, u64 wed, u64 amr); int cxl_detach_process(struct cxl_context *ctx); diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c index 09a4060..e468e6c 100644 --- a/drivers/misc/cxl/irq.c +++ b/drivers/misc/cxl/irq.c @@ -93,7 +93,7 @@ static irqreturn_t schedule_cxl_fault(struct cxl_context *ctx, u64 dsisr, u64 da return IRQ_HANDLED; } -static irqreturn_t cxl_irq(int irq, void *data, struct cxl_irq_info *irq_info) +irqreturn_t cxl_irq(int irq, void *data, struct cxl_irq_info *irq_info) { struct cxl_context *ctx = data; u64 dsisr, dar; @@ -291,12 +291,12 @@ void cxl_unmap_irq(unsigned int virq, void *cookie) irq_dispose_mapping(virq); } -static int cxl_register_one_irq(struct cxl *adapter, - irq_handler_t handler, - void *cookie, - irq_hw_number_t *dest_hwirq, - unsigned int *dest_virq, - const char *name) +int cxl_register_one_irq(struct cxl *adapter, + irq_handler_t handler, + void *cookie, + irq_hw_number_t *dest_hwirq, + unsigned int *dest_virq, + const char *name) { int hwirq, virq; diff --git a/drivers/misc/cxl/main.c b/drivers/misc/cxl/main.c index 9fde75e..7ef5b43 100644 --- a/drivers/misc/cxl/main.c +++ b/drivers/misc/cxl/main.c @@ -32,6 +32,27 @@ uint cxl_verbose; module_param_named(verbose, cxl_verbose, uint, 0600); MODULE_PARM_DESC(verbose, "Enable verbose dmesg output"); +int cxl_afu_slbia(struct cxl_afu *afu) +{ + unsigned long timeout = jiffies + (HZ * CXL_TIMEOUT); + + pr_devel("cxl_afu_slbia issuing SLBIA command\n"); + cxl_p2n_write(afu, CXL_SLBIA_An, CXL_TLB_SLB_IQ_ALL); + while (cxl_p2n_read(afu, CXL_SLBIA_An) & CXL_TLB_SLB_P) { + if (time_after_eq(jiffies, timeout)) { + dev_warn(>dev, "WARNING: CXL AFU SLBIA timed out!\n"); + return -EBUSY; + } + /* If the adapter has gone down, we can assume that we +* will PERST it and that will invalidate everything. +*/ + if (!cxl_adapter_link_ok(afu->adapter)) + return -EIO; + cpu_relax(); + } + return 0; +} + static inline void _cxl_slbia(struct cxl_context *ctx, struct mm
Re: Fwd: [PATCH v4 10/18] cxl: New hcalls to support CAPI adapters
On 2/22/2016 12:14 PM, Frederic Barrat wrote: platoform->platform Irreverent to the Socratic amongst us. Hope we didn't hurt your feelings :-D Fred No, you did not! ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: Fwd: [PATCH v4 08/18] cxl: IRQ allocation for guests
On 2/22/2016 8:46 AM, Frederic Barrat wrote: Le 21/02/2016 23:30, Manoj Kumar a écrit : Subject: [PATCH v4 08/18] cxl: IRQ allocation for guests Date: Tue, 16 Feb 2016 22:39:01 +0100 From: Frederic Barrat <fbar...@linux.vnet.ibm.com> To: imun...@au1.ibm.com, michael.neul...@au1.ibm.com, m...@ellerman.id.au, linuxppc-dev@lists.ozlabs.org The PSL interrupt is not going to be multiplexed in a guest, so an interrupt will be allocated for it for each context. Not clear why this is the case. Why cannot the CXL later still multiplex this in a guest? Is this a design choice, an architectural issue, or the complexity of implementation did not warrant this? From an API perspective it would have been preferable to not cascade this change down to all consumers, and have consumers aware whether they are working in a bare-metal or a guest environment. It was a design choice made by pHyp. We cannot multiplex the PSL interrupt with the current pHyp implementation. If that is the case, perhaps the commit message should be re-worded. As currently written, it seems like it was a choice made by this patch. The PSL interrupt cannot be multiplexed in a guest, because blah... -- Manoj Kumar ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: Fwd: [PATCH v4 11/18] cxl: Separate bare-metal fields in adapter and AFU data structures
On 2/22/2016 11:57 AM, Frederic Barrat wrote: Manoj, Point taken. Those constants are all defined in the architecture document (CAIA). We should probably use more macros there. However, since those were not introduced by this patch, I'll put it in my todo list for the future, but don't intend to address it in this patchset. Fred Fred: I am fine with this approach. -- Manoj Kumar ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: Fwd: [PATCH v4 12/18] cxl: Add guest-specific code
Christophe, Fred: Is getting the code checkpatch clean not a requirement for this component? total: 458 errors, 995 warnings, 1602 lines checked NOTE: Whitespace errors detected. You may wish to use scripts/cleanpatch or scripts/cleanfile I am stopping my review at this point. Will pick it back up after you resubmit. -- Manoj Kumar Subject: [PATCH v4 12/18] cxl: Add guest-specific code Date: Tue, 16 Feb 2016 22:39:05 +0100 From: Frederic Barrat <fbar...@linux.vnet.ibm.com> To: imun...@au1.ibm.com, michael.neul...@au1.ibm.com, m...@ellerman.id.au, linuxppc-dev@lists.ozlabs.org From: Christophe Lombard <clomb...@linux.vnet.ibm.com> The new of.c file contains code to parse the device tree to find out about CAPI adapters and AFUs. guest.c implements the guest-specific callbacks for the backend API. The process element ID is not known until the context is attached, so we have to separate the context ID assigned by the cxl driver from the process element ID visible to the user applications. In bare-metal, the 2 IDs match. Co-authored-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> --- drivers/misc/cxl/Makefile | 1 + drivers/misc/cxl/api.c | 2 +- drivers/misc/cxl/context.c | 6 +- drivers/misc/cxl/cxl.h | 37 +- drivers/misc/cxl/file.c| 2 +- drivers/misc/cxl/guest.c | 950 + drivers/misc/cxl/main.c| 18 +- drivers/misc/cxl/of.c | 513 8 files changed, 1519 insertions(+), 10 deletions(-) create mode 100644 drivers/misc/cxl/guest.c create mode 100644 drivers/misc/cxl/of.c diff --git a/drivers/misc/cxl/Makefile b/drivers/misc/cxl/Makefile index be2ac5c..a3d4bef 100644 --- a/drivers/misc/cxl/Makefile +++ b/drivers/misc/cxl/Makefile @@ -4,6 +4,7 @@ ccflags-$(CONFIG_PPC_WERROR)+= -Werror cxl-y+= main.o file.o irq.o fault.o native.o cxl-y+= context.o sysfs.o debugfs.o pci.o trace.o cxl-y+= vphb.o api.o +cxl-y+= guest.o of.o hcalls.o obj-$(CONFIG_CXL)+= cxl.o obj-$(CONFIG_CXL_BASE)+= base.o diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index 31eb842..325f957 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c @@ -191,7 +191,7 @@ EXPORT_SYMBOL_GPL(cxl_start_context); int cxl_process_element(struct cxl_context *ctx) { -return ctx->pe; +return ctx->external_pe; } EXPORT_SYMBOL_GPL(cxl_process_element); diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c index 200837f..180c85a 100644 --- a/drivers/misc/cxl/context.c +++ b/drivers/misc/cxl/context.c @@ -95,8 +95,12 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu *afu, bool master, return i; ctx->pe = i; -if (cpu_has_feature(CPU_FTR_HVMODE)) +if (cpu_has_feature(CPU_FTR_HVMODE)) { ctx->elem = >afu->native->spa[i]; +ctx->external_pe = ctx->pe; +} else { +ctx->external_pe = -1; /* assigned when attaching */ +} ctx->pe_inserted = false; /* diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index 3a1fabd..4372a87 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -433,6 +433,12 @@ struct cxl_irq_name { char *name; }; +struct irq_avail { +irq_hw_number_t offset; +irq_hw_number_t range; +unsigned long *bitmap; +}; + /* * This is a cxl context. If the PSL is in dedicated mode, there will be one * of these per AFU. If in AFU directed there can be lots of these. @@ -488,7 +494,19 @@ struct cxl_context { struct cxl_process_element *elem; -int pe; /* process element handle */ +/* + * pe is the process element handle, assigned by this driver when the + * context is initialized. + * + * external_pe is the PE shown outside of cxl. + * On bare-metal, pe=external_pe, because we decide what the handle is. + * In a guest, we only find out about the pe used by pHyp when the + * context is attached, and that's the value we want to report outside + * of cxl. + */ +int pe; +int external_pe; + u32 irq_count; bool pe_inserted; bool master; @@ -782,6 +800,7 @@ void cxl_pci_vphb_reconfigure(struct cxl_afu *afu); void cxl_pci_vphb_remove(struct cxl_afu *afu); extern struct pci_driver cxl_pci_driver; +extern struct platform_driver cxl_of_driver; int afu_allocate_irqs(struct cxl_context *ctx, u32 count); int afu_open(struct inode *inode, struct file *file); @@ -792,6 +811,21 @@ unsigned int afu_poll(struct file *file, struct poll_table_struct *poll); ssize_t afu_read(struct file *file, char __user *buf, size_t count, loff_t *off); extern const struct file_operations afu_fops; +st
Re: Fwd: [PATCH v4 11/18] cxl: Separate bare-metal fields in adapter and AFU data structures
Christophe, Fred: Perhaps none of these comments below are specific to your patch, but clarification would help the next reviewer. -- Manoj Kumar Subject: [PATCH v4 11/18] cxl: Separate bare-metal fields in adapter and -WARN_ON(afu->spa_size > 0x10); /* Max size supported by the hardware */ +WARN_ON(afu->native->spa_size > 0x10); /* Max size supported by the hardware */ Would prefer to see a MACRO defined, instead of the literal 0x100 cxl_p1_write(adapter, CXL_PSL_ErrIVTE, 0x); Same as above. p1n_base = p1_base(dev) + 0x1 + (afu->slice * p1n_size); Same as above. @@ -621,7 +622,7 @@ static int cxl_read_afu_descriptor(struct cxl_afu *afu) afu->pp_size = AFUD_PPPSA_LEN(val) * 4096; Both val and pp_size are 64bit quantities. Not clear how the overflow during multiplication is going to be handled. afu->crs_len = AFUD_CR_LEN(val) * 256; What do the 4096 and 256 represent? /* Convert everything to bytes, because there is NO WAY I'd look at the * code a month later and forget what units these are in ;-) */ -adapter->ps_off = ps_off * 64 * 1024; +adapter->native->ps_off = ps_off * 64 * 1024; adapter->ps_size = ps_size * 64 * 1024; -adapter->afu_desc_off = afu_desc_off * 64 * 1024; -adapter->afu_desc_size = afu_desc_size *64 * 1024; +adapter->native->afu_desc_off = afu_desc_off * 64 * 1024; +adapter->native->afu_desc_size = afu_desc_size * 64 * 1024; Is this (64k) page size related? ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: Fwd: [PATCH v4 10/18] cxl: New hcalls to support CAPI adapters
Fred: See comments below. The most egregious checkpatch violations so far in this series, for going beyond 80 columns. total: 65 warnings, 924 lines checked On 2/21/2016 3:31 PM, Uma Krishnan wrote: From: Christophe LombardThe hypervisor calls provide an interface with a coherent plaform plaform->platform +/** + * cxl_h_download_adapter_image - Download the base image in the coherent + *platoform facility. platoform->platform + +/** + * cxl_h_validate_adapter_image - Validate the base image in the coherent + *platoform facility. platoform->platform Irreverent to the Socratic amongst us. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: Fwd: [PATCH v4 09/18] cxl: New possible return value from hcall
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar Subject: [PATCH v4 09/18] cxl: New possible return value from hcall Date: Tue, 16 Feb 2016 22:39:02 +0100 From: Frederic Barrat <fbar...@linux.vnet.ibm.com> To: imun...@au1.ibm.com, michael.neul...@au1.ibm.com, m...@ellerman.id.au, linuxppc-dev@lists.ozlabs.org From: Christophe Lombard <clomb...@linux.vnet.ibm.com> The hcalls introduced for CAPI use a possible new value: H_STATE (invalid state). Same suggestion as earlier. Try to avoid references to the term CAPI externally. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: Fwd: [PATCH v4 08/18] cxl: IRQ allocation for guests
Fred: See comment below. --- Manoj Kumar Subject: [PATCH v4 08/18] cxl: IRQ allocation for guests Date: Tue, 16 Feb 2016 22:39:01 +0100 From: Frederic Barrat <fbar...@linux.vnet.ibm.com> To: imun...@au1.ibm.com, michael.neul...@au1.ibm.com, m...@ellerman.id.au, linuxppc-dev@lists.ozlabs.org The PSL interrupt is not going to be multiplexed in a guest, so an interrupt will be allocated for it for each context. Not clear why this is the case. Why cannot the CXL later still multiplex this in a guest? Is this a design choice, an architectural issue, or the complexity of implementation did not warrant this? From an API perspective it would have been preferable to not cascade this change down to all consumers, and have consumers aware whether they are working in a bare-metal or a guest environment. It will still be the first interrupt found in the first interrupt range, but is treated almost like any other AFU interrupt when creating/deleting the context. Only the handler is different. Rework the code so that the range 0 is treated like the other ranges. Co-authored-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> --- drivers/misc/cxl/irq.c | 78 +- 1 file changed, 64 insertions(+), 14 deletions(-) diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c index 5033869..3c04c14 100644 --- a/drivers/misc/cxl/irq.c +++ b/drivers/misc/cxl/irq.c @@ -19,6 +19,13 @@ #include "cxl.h" #include "trace.h" +static int afu_irq_range_start(void) +{ +if (cpu_has_feature(CPU_FTR_HVMODE)) +return 1; +return 0; +} + static irqreturn_t schedule_cxl_fault(struct cxl_context *ctx, u64 dsisr, u64 dar) { ctx->dsisr = dsisr; @@ -117,11 +124,23 @@ static irqreturn_t cxl_irq_afu(int irq, void *data) { struct cxl_context *ctx = data; irq_hw_number_t hwirq = irqd_to_hwirq(irq_get_irq_data(irq)); -int irq_off, afu_irq = 1; +int irq_off, afu_irq = 0; __u16 range; int r; -for (r = 1; r < CXL_IRQ_RANGES; r++) { +/* + * Look for the interrupt number. + * On bare-metal, we know range 0 only contains the PSL + * interrupt so we could start counting at range 1 and initialize + * afu_irq at 1. + * In a guest, range 0 also contains AFU interrupts, so it must + * be counted for. Therefore we initialize afu_irq at 0 to take into + * account the PSL interrupt. + * + * For code-readability, it just seems easier to go over all + * the ranges on bare-metal and guest. The end result is the same. + */ +for (r = 0; r < CXL_IRQ_RANGES; r++) { irq_off = hwirq - ctx->irqs.offset[r]; range = ctx->irqs.range[r]; if (irq_off >= 0 && irq_off < range) { @@ -131,7 +150,7 @@ static irqreturn_t cxl_irq_afu(int irq, void *data) afu_irq += range; } if (unlikely(r >= CXL_IRQ_RANGES)) { -WARN(1, "Recieved AFU IRQ out of range for pe %i (virq %i hwirq %lx)\n", +WARN(1, "Received AFU IRQ out of range for pe %i (virq %i hwirq %lx)\n", ctx->pe, irq, hwirq); return IRQ_HANDLED; } @@ -141,7 +160,7 @@ static irqreturn_t cxl_irq_afu(int irq, void *data) afu_irq, ctx->pe, irq, hwirq); if (unlikely(!ctx->irq_bitmap)) { -WARN(1, "Recieved AFU IRQ for context with no IRQ bitmap\n"); +WARN(1, "Received AFU IRQ for context with no IRQ bitmap\n"); return IRQ_HANDLED; } spin_lock(>lock); @@ -227,17 +246,33 @@ int afu_allocate_irqs(struct cxl_context *ctx, u32 count) { int rc, r, i, j = 1; struct cxl_irq_name *irq_name; +int alloc_count; + +/* + * In native mode, range 0 is reserved for the multiplexed + * PSL interrupt. It has been allocated when the AFU was initialized. + * + * In a guest, the PSL interrupt is not mutliplexed, but per-context, + * and is the first interrupt from range 0. It still needs to be + * allocated, so bump the count by one. + */ +if (cpu_has_feature(CPU_FTR_HVMODE)) +alloc_count = count; +else +alloc_count = count + 1; /* Initialize the list head to hold irq names */ INIT_LIST_HEAD(>irq_names); if ((rc = cxl_ops->alloc_irq_ranges(>irqs, ctx->afu->adapter, -count))) +alloc_count))) return rc; -/* Multiplexed PSL Interrupt */ -ctx->irqs.offset[0] = ctx->afu->psl_hwirq; -ctx->irqs.range[0] = 1; +if (cpu_has_feature(CPU_FTR_HVMODE)) { +/* Multiplexed PSL Interrupt */ +ctx->irqs.offset[0] = ctx->afu->psl_hwirq; +ctx->irqs.range[0] = 1; +
Re: Fwd: [PATCH v4 07/18] cxl: Update cxl_irq() prototype
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar Subject: [PATCH v4 07/18] cxl: Update cxl_irq() prototype Date: Tue, 16 Feb 2016 22:39:00 +0100 From: Frederic Barrat <fbar...@linux.vnet.ibm.com> To: imun...@au1.ibm.com, michael.neul...@au1.ibm.com, m...@ellerman.id.au, linuxppc-dev@lists.ozlabs.org The context parameter when calling cxl_irq() should be strongly typed. Co-authored-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Acked-by: Ian Munsie <imun...@au1.ibm.com> --- drivers/misc/cxl/cxl.h | 2 +- drivers/misc/cxl/irq.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index 40f6783..c7ed265 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -714,7 +714,7 @@ struct cxl_irq_info { }; void cxl_assign_psn_space(struct cxl_context *ctx); -irqreturn_t cxl_irq(int irq, void *ctx, struct cxl_irq_info *irq_info); +irqreturn_t cxl_irq(int irq, struct cxl_context *ctx, struct cxl_irq_info *irq_info); int cxl_register_one_irq(struct cxl *adapter, irq_handler_t handler, void *cookie, irq_hw_number_t *dest_hwirq, unsigned int *dest_virq, const char *name); diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c index 56ad301..5033869 100644 --- a/drivers/misc/cxl/irq.c +++ b/drivers/misc/cxl/irq.c @@ -27,9 +27,8 @@ static irqreturn_t schedule_cxl_fault(struct cxl_context *ctx, u64 dsisr, u64 da return IRQ_HANDLED; } -irqreturn_t cxl_irq(int irq, void *data, struct cxl_irq_info *irq_info) +irqreturn_t cxl_irq(int irq, struct cxl_context *ctx, struct cxl_irq_info *irq_info) { -struct cxl_context *ctx = data; u64 dsisr, dar; dsisr = irq_info->dsisr; ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: Fwd: [PATCH v4 06/18] cxl: Isolate a few bare-metal-specific calls
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar Subject: [PATCH v4 06/18] cxl: Isolate a few bare-metal-specific calls Date: Tue, 16 Feb 2016 22:38:59 +0100 From: Frederic Barrat <fbar...@linux.vnet.ibm.com> To: imun...@au1.ibm.com, michael.neul...@au1.ibm.com, m...@ellerman.id.au, linuxppc-dev@lists.ozlabs.org A few functions are mostly common between bare-metal and guest and just need minor tuning. To avoid crowding the backend API, introduce a few 'if' based on the CPU being in HV mode. Co-authored-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Acked-by: Ian Munsie <imun...@au1.ibm.com> --- drivers/misc/cxl/context.c | 3 ++- drivers/misc/cxl/cxl.h | 7 +-- drivers/misc/cxl/debugfs.c | 4 drivers/misc/cxl/fault.c | 19 +++ 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c index aa65262..46f9844 100644 --- a/drivers/misc/cxl/context.c +++ b/drivers/misc/cxl/context.c @@ -95,7 +95,8 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu *afu, bool master, return i; ctx->pe = i; -ctx->elem = >afu->spa[i]; +if (cpu_has_feature(CPU_FTR_HVMODE)) +ctx->elem = >afu->spa[i]; ctx->pe_inserted = false; /* diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index 02065b4..40f6783 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -560,8 +560,11 @@ static inline bool cxl_adapter_link_ok(struct cxl *cxl) { struct pci_dev *pdev; -pdev = to_pci_dev(cxl->dev.parent); -return !pci_channel_offline(pdev); +if (cpu_has_feature(CPU_FTR_HVMODE)) { +pdev = to_pci_dev(cxl->dev.parent); +return !pci_channel_offline(pdev); +} +return true; } static inline void __iomem *_cxl_p1_addr(struct cxl *cxl, cxl_p1_reg_t reg) diff --git a/drivers/misc/cxl/debugfs.c b/drivers/misc/cxl/debugfs.c index 18df6f4..5751899 100644 --- a/drivers/misc/cxl/debugfs.c +++ b/drivers/misc/cxl/debugfs.c @@ -118,6 +118,10 @@ void cxl_debugfs_afu_remove(struct cxl_afu *afu) int __init cxl_debugfs_init(void) { struct dentry *ent; + +if (!cpu_has_feature(CPU_FTR_HVMODE)) +return 0; + ent = debugfs_create_dir("cxl", NULL); if (IS_ERR(ent)) return PTR_ERR(ent); diff --git a/drivers/misc/cxl/fault.c b/drivers/misc/cxl/fault.c index ab740a1..9a8650b 100644 --- a/drivers/misc/cxl/fault.c +++ b/drivers/misc/cxl/fault.c @@ -254,14 +254,17 @@ void cxl_handle_fault(struct work_struct *fault_work) u64 dar = ctx->dar; struct mm_struct *mm = NULL; -if (cxl_p2n_read(ctx->afu, CXL_PSL_DSISR_An) != dsisr || -cxl_p2n_read(ctx->afu, CXL_PSL_DAR_An) != dar || -cxl_p2n_read(ctx->afu, CXL_PSL_PEHandle_An) != ctx->pe) { -/* Most likely explanation is harmless - a dedicated process - * has detached and these were cleared by the PSL purge, but - * warn about it just in case */ -dev_notice(>afu->dev, "cxl_handle_fault: Translation fault regs changed\n"); -return; +if (cpu_has_feature(CPU_FTR_HVMODE)) { +if (cxl_p2n_read(ctx->afu, CXL_PSL_DSISR_An) != dsisr || +cxl_p2n_read(ctx->afu, CXL_PSL_DAR_An) != dar || +cxl_p2n_read(ctx->afu, CXL_PSL_PEHandle_An) != ctx->pe) { +/* Most likely explanation is harmless - a dedicated + * process has detached and these were cleared by the + * PSL purge, but warn about it just in case + */ +dev_notice(>afu->dev, "cxl_handle_fault: Translation fault regs changed\n"); +return; +} } /* Early return if the context is being / has been detached */ ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: Fwd: [PATCH v4 05/18] cxl: Rename some bare-metal specific functions
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar Subject: [PATCH v4 05/18] cxl: Rename some bare-metal specific functions Date: Tue, 16 Feb 2016 22:38:58 +0100 From: Frederic Barrat <fbar...@linux.vnet.ibm.com> To: imun...@au1.ibm.com, michael.neul...@au1.ibm.com, m...@ellerman.id.au, linuxppc-dev@lists.ozlabs.org Rename a few functions, changing the 'cxl_' prefix to either 'cxl_pci_' or 'cxl_native_', to make clear that the implementation is bare-metal specific. Those functions will have an equivalent implementation for a guest in a later patch. Co-authored-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> --- drivers/misc/cxl/cxl.h| 28 +++--- drivers/misc/cxl/native.c | 98 --- drivers/misc/cxl/pci.c| 78 +++-- 3 files changed, 104 insertions(+), 100 deletions(-) diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index 8233af3..02065b4 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -519,14 +519,14 @@ struct cxl { bool perst_same_image; }; -int cxl_alloc_one_irq(struct cxl *adapter); -void cxl_release_one_irq(struct cxl *adapter, int hwirq); -int cxl_alloc_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter, unsigned int num); -void cxl_release_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter); -int cxl_setup_irq(struct cxl *adapter, unsigned int hwirq, unsigned int virq); +int cxl_pci_alloc_one_irq(struct cxl *adapter); +void cxl_pci_release_one_irq(struct cxl *adapter, int hwirq); +int cxl_pci_alloc_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter, unsigned int num); +void cxl_pci_release_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter); +int cxl_pci_setup_irq(struct cxl *adapter, unsigned int hwirq, unsigned int virq); int cxl_update_image_control(struct cxl *adapter); -int cxl_reset(struct cxl *adapter); -void cxl_release_afu(struct device *dev); +int cxl_pci_reset(struct cxl *adapter); +void cxl_pci_release_afu(struct device *dev); /* common == phyp + powernv */ struct cxl_process_element_common { @@ -623,7 +623,7 @@ static inline u64 cxl_p2n_read(struct cxl_afu *afu, cxl_p2n_reg_t reg) return ~0ULL; } -ssize_t cxl_afu_read_err_buffer(struct cxl_afu *afu, char *buf, +ssize_t cxl_pci_afu_read_err_buffer(struct cxl_afu *afu, char *buf, loff_t off, size_t count); @@ -663,12 +663,12 @@ struct cxl *cxl_alloc_adapter(void); struct cxl_afu *cxl_alloc_afu(struct cxl *adapter, int slice); int cxl_afu_select_best_mode(struct cxl_afu *afu); -int cxl_register_psl_irq(struct cxl_afu *afu); -void cxl_release_psl_irq(struct cxl_afu *afu); -int cxl_register_psl_err_irq(struct cxl *adapter); -void cxl_release_psl_err_irq(struct cxl *adapter); -int cxl_register_serr_irq(struct cxl_afu *afu); -void cxl_release_serr_irq(struct cxl_afu *afu); +int cxl_native_register_psl_irq(struct cxl_afu *afu); +void cxl_native_release_psl_irq(struct cxl_afu *afu); +int cxl_native_register_psl_err_irq(struct cxl *adapter); +void cxl_native_release_psl_err_irq(struct cxl *adapter); +int cxl_native_register_serr_irq(struct cxl_afu *afu); +void cxl_native_release_serr_irq(struct cxl_afu *afu); int afu_register_irqs(struct cxl_context *ctx, u32 count); void afu_release_irqs(struct cxl_context *ctx, void *cookie); void afu_irq_name_free(struct cxl_context *ctx); diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c index 16d3b1a..b8a6ad5 100644 --- a/drivers/misc/cxl/native.c +++ b/drivers/misc/cxl/native.c @@ -80,7 +80,7 @@ int cxl_afu_disable(struct cxl_afu *afu) } /* This will disable as well as reset */ -static int __cxl_afu_reset(struct cxl_afu *afu) +static int native_afu_reset(struct cxl_afu *afu) { pr_devel("AFU reset request\n"); @@ -90,7 +90,7 @@ static int __cxl_afu_reset(struct cxl_afu *afu) false); } -static int cxl_afu_check_and_enable(struct cxl_afu *afu) +static int native_afu_check_and_enable(struct cxl_afu *afu) { if (!cxl_ops->link_ok(afu->adapter)) { WARN(1, "Refusing to enable afu while link down!\n"); @@ -631,7 +631,7 @@ static int deactivate_dedicated_process(struct cxl_afu *afu) return 0; } -static int cxl_afu_deactivate_mode(struct cxl_afu *afu, int mode) +static int native_afu_deactivate_mode(struct cxl_afu *afu, int mode) { if (mode == CXL_MODE_DIRECTED) return deactivate_afu_directed(afu); @@ -640,7 +640,7 @@ static int cxl_afu_deactivate_mode(struct cxl_afu *afu, int mode) return 0; } -static int cxl_afu_activate_mode(struct cxl_afu *afu, int mode) +static int native_afu_activate_mode(struct cxl_afu *afu, int mode) { if (!mode) return 0; @@ -660,7 +660,8 @@ s
Re: Fwd: [PATCH v4 04/18] cxl: Introduce implementation-specific API
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar Subject: [PATCH v4 04/18] cxl: Introduce implementation-specific API Date: Tue, 16 Feb 2016 22:38:57 +0100 From: Frederic Barrat <fbar...@linux.vnet.ibm.com> To: imun...@au1.ibm.com, michael.neul...@au1.ibm.com, m...@ellerman.id.au, linuxppc-dev@lists.ozlabs.org The backend API (in cxl.h) lists some low-level functions whose implementation is different on bare-metal and in a guest. Each environment implements its own functions, and the common code uses them through function pointers, defined in cxl_backend_ops Co-authored-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Acked-by: Ian Munsie <imun...@au1.ibm.com> --- drivers/misc/cxl/api.c | 8 +-- drivers/misc/cxl/context.c | 4 +- drivers/misc/cxl/cxl.h | 53 +++--- drivers/misc/cxl/fault.c | 6 +- drivers/misc/cxl/file.c| 15 ++--- drivers/misc/cxl/irq.c | 19 --- drivers/misc/cxl/main.c| 11 ++-- drivers/misc/cxl/native.c | 135 - drivers/misc/cxl/pci.c | 16 +++--- drivers/misc/cxl/sysfs.c | 32 +++ drivers/misc/cxl/vphb.c| 6 +- 11 files changed, 185 insertions(+), 120 deletions(-) diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index b45d857..31eb842 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c @@ -100,7 +100,7 @@ EXPORT_SYMBOL_GPL(cxl_allocate_afu_irqs); void cxl_free_afu_irqs(struct cxl_context *ctx) { afu_irq_name_free(ctx); -cxl_release_irq_ranges(>irqs, ctx->afu->adapter); +cxl_ops->release_irq_ranges(>irqs, ctx->afu->adapter); } EXPORT_SYMBOL_GPL(cxl_free_afu_irqs); @@ -176,7 +176,7 @@ int cxl_start_context(struct cxl_context *ctx, u64 wed, cxl_ctx_get(); -if ((rc = cxl_attach_process(ctx, kernel, wed , 0))) { +if ((rc = cxl_ops->attach_process(ctx, kernel, wed, 0))) { put_pid(ctx->pid); cxl_ctx_put(); goto out; @@ -342,11 +342,11 @@ int cxl_afu_reset(struct cxl_context *ctx) struct cxl_afu *afu = ctx->afu; int rc; -rc = __cxl_afu_reset(afu); +rc = cxl_ops->afu_reset(afu); if (rc) return rc; -return cxl_afu_check_and_enable(afu); +return cxl_ops->afu_check_and_enable(afu); } EXPORT_SYMBOL_GPL(cxl_afu_reset); diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c index 262b88e..aa65262 100644 --- a/drivers/misc/cxl/context.c +++ b/drivers/misc/cxl/context.c @@ -214,8 +214,8 @@ int __detach_context(struct cxl_context *ctx) /* Only warn if we detached while the link was OK. * If detach fails when hw is down, we don't care. */ -WARN_ON(cxl_detach_process(ctx) && -cxl_adapter_link_ok(ctx->afu->adapter)); +WARN_ON(cxl_ops->detach_process(ctx) && +cxl_ops->link_ok(ctx->afu->adapter)); flush_work(>fault_work); /* Only needed for dedicated process */ /* release the reference to the group leader and mm handling pid */ diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index 3b824e3..8233af3 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -623,11 +623,6 @@ static inline u64 cxl_p2n_read(struct cxl_afu *afu, cxl_p2n_reg_t reg) return ~0ULL; } -u64 cxl_afu_cr_read64(struct cxl_afu *afu, int cr, u64 off); -u32 cxl_afu_cr_read32(struct cxl_afu *afu, int cr, u64 off); -u16 cxl_afu_cr_read16(struct cxl_afu *afu, int cr, u64 off); -u8 cxl_afu_cr_read8(struct cxl_afu *afu, int cr, u64 off); - ssize_t cxl_afu_read_err_buffer(struct cxl_afu *afu, char *buf, loff_t off, size_t count); @@ -666,10 +661,6 @@ void cxl_sysfs_afu_m_remove(struct cxl_afu *afu); struct cxl *cxl_alloc_adapter(void); struct cxl_afu *cxl_alloc_afu(struct cxl *adapter, int slice); - -int cxl_afu_activate_mode(struct cxl_afu *afu, int mode); -int _cxl_afu_deactivate_mode(struct cxl_afu *afu, int mode); -int cxl_afu_deactivate_mode(struct cxl_afu *afu); int cxl_afu_select_best_mode(struct cxl_afu *afu); int cxl_register_psl_irq(struct cxl_afu *afu); @@ -681,8 +672,6 @@ void cxl_release_serr_irq(struct cxl_afu *afu); int afu_register_irqs(struct cxl_context *ctx, u32 count); void afu_release_irqs(struct cxl_context *ctx, void *cookie); void afu_irq_name_free(struct cxl_context *ctx); -irqreturn_t handle_psl_slice_error(struct cxl_context *ctx, u64 dsisr, -u64 errstat); int cxl_debugfs_init(void); void cxl_debugfs_exit(void); @@ -727,18 +716,10 @@ int cxl_register_one_irq(struct cxl *adapter, irq_handler_t handler, void *cookie, irq_hw_number_t *dest_hwirq, unsigned int *dest_virq, const char *name); -int cxl_att
Re: Fwd: [PATCH v4 03/18] cxl: Define process problem state area at attach time only
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar Subject: [PATCH v4 03/18] cxl: Define process problem state area at attach time only Date: Tue, 16 Feb 2016 22:38:56 +0100 From: Frederic Barrat <fbar...@linux.vnet.ibm.com> To: imun...@au1.ibm.com, michael.neul...@au1.ibm.com, m...@ellerman.id.au, linuxppc-dev@lists.ozlabs.org Cxl kernel API was defining the process problem state area during Suggestion: Cxl -> CXL context initialization, making it possible to map the problem state area before attaching the context. This won't work on a powerVM guest. So force the logical behavior, like in userspace: attach first, then map the problem state area. Remove calls to cxl_assign_psn_space during init. The function is already called on the attach paths. Co-authored-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> --- drivers/misc/cxl/api.c | 11 ++- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index ea3eeb7..b45d857 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c @@ -51,8 +51,6 @@ struct cxl_context *cxl_dev_context_init(struct pci_dev *dev) if (rc) goto err_mapping; -cxl_assign_psn_space(ctx); - return ctx; err_mapping: @@ -207,7 +205,6 @@ EXPORT_SYMBOL_GPL(cxl_stop_context); void cxl_set_master(struct cxl_context *ctx) { ctx->master = true; -cxl_assign_psn_space(ctx); } EXPORT_SYMBOL_GPL(cxl_set_master); @@ -325,15 +322,11 @@ EXPORT_SYMBOL_GPL(cxl_start_work); void __iomem *cxl_psa_map(struct cxl_context *ctx) { -struct cxl_afu *afu = ctx->afu; -int rc; - -rc = cxl_afu_check_and_enable(afu); -if (rc) +if (ctx->status != STARTED) return NULL; pr_devel("%s: psn_phys%llx size:%llx\n", - __func__, afu->psn_phys, afu->adapter->ps_size); +__func__, ctx->psn_phys, ctx->psn_size); return ioremap(ctx->psn_phys, ctx->psn_size); } EXPORT_SYMBOL_GPL(cxl_psa_map); ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: Fwd: [PATCH v4 02/18] cxl: Move bare-metal specific code to specialized files
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar -- Subject: [PATCH v4 02/18] cxl: Move bare-metal specific code to specialized files Date: Tue, 16 Feb 2016 22:38:55 +0100 From: Frederic Barrat <fbar...@linux.vnet.ibm.com> To: imun...@au1.ibm.com, michael.neul...@au1.ibm.com, m...@ellerman.id.au, linuxppc-dev@lists.ozlabs.org Move a few functions around to better separate code specific to bare-metal environment from code which will be commonly used between guest and bare-metal. Code specific to bare-metal is meant to be in native.c or pci.c only. It's basically anything which touches the capi p1 registers, I thought we were going to avoid using the CAPI term externally. Please update if submitting a v4 of this patch series. some p2 registers not needed from a guest and the PCI interface. Co-authored-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Acked-by: Ian Munsie <imun...@au1.ibm.com> --- drivers/misc/cxl/cxl.h| 24 + drivers/misc/cxl/irq.c| 205 +-- drivers/misc/cxl/main.c | 2 +- drivers/misc/cxl/native.c | 240 +- drivers/misc/cxl/pci.c| 18 5 files changed, 245 insertions(+), 244 deletions(-) diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index 3f88140..3b824e3 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -623,23 +623,8 @@ static inline u64 cxl_p2n_read(struct cxl_afu *afu, cxl_p2n_reg_t reg) return ~0ULL; } -static inline u64 cxl_afu_cr_read64(struct cxl_afu *afu, int cr, u64 off) -{ -if (likely(cxl_adapter_link_ok(afu->adapter))) -return in_le64((afu)->afu_desc_mmio + (afu)->crs_offset + - ((cr) * (afu)->crs_len) + (off)); -else -return ~0ULL; -} - -static inline u32 cxl_afu_cr_read32(struct cxl_afu *afu, int cr, u64 off) -{ -if (likely(cxl_adapter_link_ok(afu->adapter))) -return in_le32((afu)->afu_desc_mmio + (afu)->crs_offset + - ((cr) * (afu)->crs_len) + (off)); -else -return 0x; -} +u64 cxl_afu_cr_read64(struct cxl_afu *afu, int cr, u64 off); +u32 cxl_afu_cr_read32(struct cxl_afu *afu, int cr, u64 off); u16 cxl_afu_cr_read16(struct cxl_afu *afu, int cr, u64 off); u8 cxl_afu_cr_read8(struct cxl_afu *afu, int cr, u64 off); @@ -654,7 +639,6 @@ struct cxl_calls { int register_cxl_calls(struct cxl_calls *calls); void unregister_cxl_calls(struct cxl_calls *calls); -int cxl_alloc_adapter_nr(struct cxl *adapter); void cxl_remove_adapter_nr(struct cxl *adapter); int cxl_alloc_spa(struct cxl_afu *afu); @@ -697,7 +681,8 @@ void cxl_release_serr_irq(struct cxl_afu *afu); int afu_register_irqs(struct cxl_context *ctx, u32 count); void afu_release_irqs(struct cxl_context *ctx, void *cookie); void afu_irq_name_free(struct cxl_context *ctx); -irqreturn_t cxl_slice_irq_err(int irq, void *data); +irqreturn_t handle_psl_slice_error(struct cxl_context *ctx, u64 dsisr, +u64 errstat); int cxl_debugfs_init(void); void cxl_debugfs_exit(void); @@ -746,7 +731,6 @@ int cxl_attach_process(struct cxl_context *ctx, bool kernel, u64 wed, u64 amr); int cxl_detach_process(struct cxl_context *ctx); -int cxl_get_irq(struct cxl_afu *afu, struct cxl_irq_info *info); int cxl_ack_irq(struct cxl_context *ctx, u64 tfc, u64 psl_reset_mask); int cxl_check_error(struct cxl_afu *afu); diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c index e468e6c..16fd67f 100644 --- a/drivers/misc/cxl/irq.c +++ b/drivers/misc/cxl/irq.c @@ -19,72 +19,6 @@ #include "cxl.h" #include "trace.h" -/* XXX: This is implementation specific */ -static irqreturn_t handle_psl_slice_error(struct cxl_context *ctx, u64 dsisr, u64 errstat) -{ -u64 fir1, fir2, fir_slice, serr, afu_debug; - -fir1 = cxl_p1_read(ctx->afu->adapter, CXL_PSL_FIR1); -fir2 = cxl_p1_read(ctx->afu->adapter, CXL_PSL_FIR2); -fir_slice = cxl_p1n_read(ctx->afu, CXL_PSL_FIR_SLICE_An); -serr = cxl_p1n_read(ctx->afu, CXL_PSL_SERR_An); -afu_debug = cxl_p1n_read(ctx->afu, CXL_AFU_DEBUG_An); - -dev_crit(>afu->dev, "PSL ERROR STATUS: 0x%016llx\n", errstat); -dev_crit(>afu->dev, "PSL_FIR1: 0x%016llx\n", fir1); -dev_crit(>afu->dev, "PSL_FIR2: 0x%016llx\n", fir2); -dev_crit(>afu->dev, "PSL_SERR_An: 0x%016llx\n", serr); -dev_crit(>afu->dev, "PSL_FIR_SLICE_An: 0x%016llx\n", fir_slice); -dev_crit(>afu->dev, "CXL_PSL_AFU_DEBUG_An: 0x%016llx\n", afu_debug); - -dev_crit(>afu->dev, "STOPPING CXL TRACE\n"); -cxl_stop_trace(ctx->afu->adapter); - -retur
Re: Fwd: [PATCH v4 01/18] cxl: Move common code away from bare-metal-specific files
Would have been nice to have the code and the commit messages consistent in the terminology. Commit comments: bare-metal and guest Code: powernv and phyp Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar Forwarded Message Subject: [PATCH v4 01/18] cxl: Move common code away from bare-metal-specific files Date: Tue, 16 Feb 2016 22:38:54 +0100 From: Frederic Barrat <fbar...@linux.vnet.ibm.com> To: imun...@au1.ibm.com, michael.neul...@au1.ibm.com, m...@ellerman.id.au, linuxppc-dev@lists.ozlabs.org From: Christophe Lombard <clomb...@linux.vnet.ibm.com> Move around some functions which will be accessed from the bare-metal and guest environments. Code in native.c and pci.c is meant to be bare-metal specific. Other files contain code which may be shared with guests. Co-authored-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Frederic Barrat <fbar...@linux.vnet.ibm.com> Signed-off-by: Christophe Lombard <clomb...@linux.vnet.ibm.com> Acked-by: Ian Munsie <imun...@au1.ibm.com> --- drivers/misc/cxl/cxl.h| 9 +++ drivers/misc/cxl/irq.c| 14 +- drivers/misc/cxl/main.c | 67 +++ drivers/misc/cxl/native.c | 21 --- drivers/misc/cxl/pci.c| 48 + 5 files changed, 84 insertions(+), 75 deletions(-) diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h index a521bc7..3f88140 100644 --- a/drivers/misc/cxl/cxl.h +++ b/drivers/misc/cxl/cxl.h @@ -526,6 +526,7 @@ void cxl_release_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter); int cxl_setup_irq(struct cxl *adapter, unsigned int hwirq, unsigned int virq); int cxl_update_image_control(struct cxl *adapter); int cxl_reset(struct cxl *adapter); +void cxl_release_afu(struct device *dev); /* common == phyp + powernv */ struct cxl_process_element_common { @@ -679,6 +680,9 @@ void cxl_sysfs_afu_remove(struct cxl_afu *afu); int cxl_sysfs_afu_m_add(struct cxl_afu *afu); void cxl_sysfs_afu_m_remove(struct cxl_afu *afu); +struct cxl *cxl_alloc_adapter(void); +struct cxl_afu *cxl_alloc_afu(struct cxl *adapter, int slice); + int cxl_afu_activate_mode(struct cxl_afu *afu, int mode); int _cxl_afu_deactivate_mode(struct cxl_afu *afu, int mode); int cxl_afu_deactivate_mode(struct cxl_afu *afu); @@ -733,6 +737,11 @@ struct cxl_irq_info { }; void cxl_assign_psn_space(struct cxl_context *ctx); +irqreturn_t cxl_irq(int irq, void *ctx, struct cxl_irq_info *irq_info); +int cxl_register_one_irq(struct cxl *adapter, irq_handler_t handler, +void *cookie, irq_hw_number_t *dest_hwirq, +unsigned int *dest_virq, const char *name); + int cxl_attach_process(struct cxl_context *ctx, bool kernel, u64 wed, u64 amr); int cxl_detach_process(struct cxl_context *ctx); diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c index 09a4060..e468e6c 100644 --- a/drivers/misc/cxl/irq.c +++ b/drivers/misc/cxl/irq.c @@ -93,7 +93,7 @@ static irqreturn_t schedule_cxl_fault(struct cxl_context *ctx, u64 dsisr, u64 da return IRQ_HANDLED; } -static irqreturn_t cxl_irq(int irq, void *data, struct cxl_irq_info *irq_info) +irqreturn_t cxl_irq(int irq, void *data, struct cxl_irq_info *irq_info) { struct cxl_context *ctx = data; u64 dsisr, dar; @@ -291,12 +291,12 @@ void cxl_unmap_irq(unsigned int virq, void *cookie) irq_dispose_mapping(virq); } -static int cxl_register_one_irq(struct cxl *adapter, -irq_handler_t handler, -void *cookie, -irq_hw_number_t *dest_hwirq, -unsigned int *dest_virq, -const char *name) +int cxl_register_one_irq(struct cxl *adapter, +irq_handler_t handler, +void *cookie, +irq_hw_number_t *dest_hwirq, +unsigned int *dest_virq, +const char *name) { int hwirq, virq; diff --git a/drivers/misc/cxl/main.c b/drivers/misc/cxl/main.c index 9fde75e..7ef5b43 100644 --- a/drivers/misc/cxl/main.c +++ b/drivers/misc/cxl/main.c @@ -32,6 +32,27 @@ uint cxl_verbose; module_param_named(verbose, cxl_verbose, uint, 0600); MODULE_PARM_DESC(verbose, "Enable verbose dmesg output"); +int cxl_afu_slbia(struct cxl_afu *afu) +{ +unsigned long timeout = jiffies + (HZ * CXL_TIMEOUT); + +pr_devel("cxl_afu_slbia issuing SLBIA command\n"); +cxl_p2n_write(afu, CXL_SLBIA_An, CXL_TLB_SLB_IQ_ALL); +while (cxl_p2n_read(afu, CXL_SLBIA_An) & CXL_TLB_SLB_P) { +if (time_after_eq(jiffies, timeout)) { +dev_warn(>dev, "WARNING: CXL AFU SLBIA timed out!\n"); +return -EBUSY; +} +/* If the adapter has gone down, we can assume that we + * will PERST it and that will invalidate everything. + */ +if (!cxl_adapter_link_ok(afu-
Re: [PATCH v2 1/7] ibmvscsi: Correct values for several viosrp_crq_format enums
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/10/2016 7:32 PM, Tyrel Datwyler wrote: The enum values for VIOSRP_LINUX_FORMAT and VIOSRP_INLINE_FORMAT are off by one. They are currently defined as 0x06 and 0x07 respetively. These values are defined in PAPR correctly as 0x05 and 0x06. This inconsistency has gone unnoticed as neither enum is currently used. The possible future support of PING messages between the VIOS and client adapter relies on VIOSRP_INLINE_FORMAT crq messages. Corrected these enum values to match PAPR definitions. Signed-off-by: Tyrel Datwyler <tyr...@linux.vnet.ibm.com> Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de> --- drivers/scsi/ibmvscsi/viosrp.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ibmvscsi/viosrp.h b/drivers/scsi/ibmvscsi/viosrp.h index 1162430..d1044e9 100644 --- a/drivers/scsi/ibmvscsi/viosrp.h +++ b/drivers/scsi/ibmvscsi/viosrp.h @@ -56,8 +56,8 @@ enum viosrp_crq_formats { VIOSRP_MAD_FORMAT = 0x02, VIOSRP_OS400_FORMAT = 0x03, VIOSRP_AIX_FORMAT = 0x04, - VIOSRP_LINUX_FORMAT = 0x06, - VIOSRP_INLINE_FORMAT = 0x07 + VIOSRP_LINUX_FORMAT = 0x05, + VIOSRP_INLINE_FORMAT = 0x06 }; enum viosrp_crq_status { ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v2 2/7] ibmvscsi: Add and use enums for valid CRQ header values
Tyrel: Thanks for incorporating the suggestions. Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/10/2016 7:32 PM, Tyrel Datwyler wrote: The PAPR defines four valid header values for the first byte of a CRQ message. Namely, an unused/empty message (0x00), a valid command/response entry (0x80), a valid initialization entry (0xC0), and a valid transport event (0xFF). Further, initialization responses have two formats namely initialize (0x01) and initialize complete (0x02). Define these values as enums and use them in the code in place of their magic number equivalents. Signed-off-by: Tyrel Datwyler <tyr...@linux.vnet.ibm.com> --- drivers/scsi/ibmvscsi/ibmvscsi.c | 18 +- drivers/scsi/ibmvscsi/viosrp.h | 12 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index adfef9d..c888ea1 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -182,7 +182,7 @@ static struct viosrp_crq *crq_queue_next_crq(struct crq_queue *queue) spin_lock_irqsave(>lock, flags); crq = >msgs[queue->cur]; - if (crq->valid & 0x80) { + if (crq->valid != VIOSRP_CRQ_FREE) { if (++queue->cur == queue->size) queue->cur = 0; @@ -231,7 +231,7 @@ static void ibmvscsi_task(void *data) /* Pull all the valid messages off the CRQ */ while ((crq = crq_queue_next_crq(>queue)) != NULL) { ibmvscsi_handle_crq(crq, hostdata); - crq->valid = 0x00; + crq->valid = VIOSRP_CRQ_FREE; } vio_enable_interrupts(vdev); @@ -239,7 +239,7 @@ static void ibmvscsi_task(void *data) if (crq != NULL) { vio_disable_interrupts(vdev); ibmvscsi_handle_crq(crq, hostdata); - crq->valid = 0x00; + crq->valid = VIOSRP_CRQ_FREE; } else { done = 1; } @@ -474,7 +474,7 @@ static int initialize_event_pool(struct event_pool *pool, struct srp_event_struct *evt = >events[i]; memset(>crq, 0x00, sizeof(evt->crq)); atomic_set(>free, 1); - evt->crq.valid = 0x80; + evt->crq.valid = VIOSRP_CRQ_CMD_RSP; evt->crq.IU_length = cpu_to_be16(sizeof(*evt->xfer_iu)); evt->crq.IU_data_ptr = cpu_to_be64(pool->iu_token + sizeof(*evt->xfer_iu) * i); @@ -1767,9 +1767,9 @@ static void ibmvscsi_handle_crq(struct viosrp_crq *crq, struct srp_event_struct *evt_struct = (__force struct srp_event_struct *)crq->IU_data_ptr; switch (crq->valid) { - case 0xC0: /* initialization */ + case VIOSRP_CRQ_INIT_RSP: /* initialization */ switch (crq->format) { - case 0x01: /* Initialization message */ + case VIOSRP_CRQ_INIT: /* Initialization message */ dev_info(hostdata->dev, "partner initialized\n"); /* Send back a response */ rc = ibmvscsi_send_crq(hostdata, 0xC002LL, 0); @@ -1781,7 +1781,7 @@ static void ibmvscsi_handle_crq(struct viosrp_crq *crq, } break; - case 0x02: /* Initialization response */ + case VIOSRP_CRQ_INIT_COMPLETE: /* Initialization response */ dev_info(hostdata->dev, "partner initialization complete\n"); /* Now login */ @@ -1791,7 +1791,7 @@ static void ibmvscsi_handle_crq(struct viosrp_crq *crq, dev_err(hostdata->dev, "unknown crq message type: %d\n", crq->format); } return; - case 0xFF: /* Hypervisor telling us the connection is closed */ + case VIOSRP_CRQ_XPORT_EVENT:/* Hypervisor telling us the connection is closed */ scsi_block_requests(hostdata->host); atomic_set(>request_limit, 0); if (crq->format == 0x06) { @@ -1807,7 +1807,7 @@ static void ibmvscsi_handle_crq(struct viosrp_crq *crq, ibmvscsi_reset_host(hostdata); } return; - case 0x80: /* real payload */ + case VIOSRP_CRQ_CMD_RSP:/* real payload */ break; default: dev_err(hostdata->dev, "got an invalid message type 0x%02x\n", diff --git a/drivers/scsi/ibmvscsi/viosrp.h b/drivers/scsi/ibmvscsi/viosrp.h index d1044
Re: [PATCH v2 3/7] ibmvscsi: Replace magic values in set_adpater_info() with defines
Reviewed-by: Manoj Kumar <ma...@linux.vnet.ibm.com> --- Manoj Kumar On 2/10/2016 7:32 PM, Tyrel Datwyler wrote: Add defines for mad version and mad os_type, and replace the magic numbers in set_adapter_info() accordingly. Signed-off-by: Tyrel Datwyler <tyr...@linux.vnet.ibm.com> --- drivers/scsi/ibmvscsi/ibmvscsi.c | 8 drivers/scsi/ibmvscsi/viosrp.h | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index c888ea1..4b09a9b 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -283,8 +283,8 @@ static void set_adapter_info(struct ibmvscsi_host_data *hostdata) hostdata->madapter_info.partition_number = cpu_to_be32(partition_number); - hostdata->madapter_info.mad_version = cpu_to_be32(1); - hostdata->madapter_info.os_type = cpu_to_be32(2); + hostdata->madapter_info.mad_version = cpu_to_be32(SRP_MAD_VERSION_1); + hostdata->madapter_info.os_type = cpu_to_be32(SRP_MAD_OS_LINUX); } /** @@ -1398,7 +1398,7 @@ static void adapter_info_rsp(struct srp_event_struct *evt_struct) hostdata->host->max_sectors = be32_to_cpu(hostdata->madapter_info.port_max_txu[0]) >> 9; - if (be32_to_cpu(hostdata->madapter_info.os_type) == 3 && + if (be32_to_cpu(hostdata->madapter_info.os_type) == SRP_MAD_OS_AIX && strcmp(hostdata->madapter_info.srp_version, "1.6a") <= 0) { dev_err(hostdata->dev, "host (Ver. %s) doesn't support large transfers\n", hostdata->madapter_info.srp_version); @@ -1407,7 +1407,7 @@ static void adapter_info_rsp(struct srp_event_struct *evt_struct) hostdata->host->sg_tablesize = MAX_INDIRECT_BUFS; } - if (be32_to_cpu(hostdata->madapter_info.os_type) == 3) { + if (be32_to_cpu(hostdata->madapter_info.os_type) == SRP_MAD_OS_AIX) { enable_fast_fail(hostdata); return; } diff --git a/drivers/scsi/ibmvscsi/viosrp.h b/drivers/scsi/ibmvscsi/viosrp.h index 3d20851..d0f689b 100644 --- a/drivers/scsi/ibmvscsi/viosrp.h +++ b/drivers/scsi/ibmvscsi/viosrp.h @@ -221,7 +221,10 @@ struct mad_adapter_info_data { char srp_version[8]; char partition_name[96]; __be32 partition_number; +#define SRP_MAD_VERSION_1 1 __be32 mad_version; +#define SRP_MAD_OS_LINUX 2 +#define SRP_MAD_OS_AIX 3 __be32 os_type; __be32 port_max_txu[8]; /* per-port maximum transfer */ }; ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/6] ibmvscsi: Add and use enums for valid CRQ header values
Yeah, I can see how that is confusing. Since, all three possible valid crq message types have the first bit set I think this was originally a cute hack to grab anything that was likely valid. Then in ibmvscsi_handle_crq() we explicitly match the full header value in a switch statement logging anything that turned out actually invalid. If 'valid' will only have one of these four enums defined, would this be better written as: if (crq->valid != VIOSRP_CRQ_FREE) This definitely would make the logic easier to read and follow. Also, this would make sure any crq with an invalid header that doesn't have its first bit set will also be logged by the ibmvscsi_handle_crq() switch statement default block and not silently ignored. -Tyrel Sounds good, Tyrel. Does this mean I should expect a v2 of this patch series? - Manoj N. Kumar ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/6] ibmvscsi: Add and use enums for valid CRQ header values
On 2/3/2016 5:28 PM, Tyrel Datwyler wrote: The PAPR defines four valid header values for the first byte of a CRQ message. Namely, an unused/empty message (0x00), a valid command/response entry (0x80), a valid initialization entry (0xC0), and a transport event (0xFF). Define these values as enums and use them in the code in place of their magic number equivalents. Signed-off-by: Tyrel Datwyler--- drivers/scsi/ibmvscsi/ibmvscsi.c | 14 +++--- drivers/scsi/ibmvscsi/viosrp.h | 7 +++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index adfef9d..176260d 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -182,7 +182,7 @@ static struct viosrp_crq *crq_queue_next_crq(struct crq_queue *queue) spin_lock_irqsave(>lock, flags); crq = >msgs[queue->cur]; - if (crq->valid & 0x80) { + if (crq->valid & VIOSRP_CRQ_VALID) { After the switch to enums, bitwise operators are a bit misleading. Especially in this case since multiple values would satisfy this condition: VIOSRP_CRQ_VALID, VIOSRP_CRQ_INIT and VIOSRP_CRQ_TRANSPORT. If 'valid' will only have one of these four enums defined, would this be better written as: if (crq->valid != VIOSRP_CRQ_FREE) if (++queue->cur == queue->size) queue->cur = 0; @@ -231,7 +231,7 @@ static void ibmvscsi_task(void *data) /* Pull all the valid messages off the CRQ */ while ((crq = crq_queue_next_crq(>queue)) != NULL) { ibmvscsi_handle_crq(crq, hostdata); - crq->valid = 0x00; + crq->valid = VIOSRP_CRQ_FREE; } vio_enable_interrupts(vdev); @@ -239,7 +239,7 @@ static void ibmvscsi_task(void *data) if (crq != NULL) { vio_disable_interrupts(vdev); ibmvscsi_handle_crq(crq, hostdata); - crq->valid = 0x00; + crq->valid = VIOSRP_CRQ_FREE; } else { done = 1; } @@ -474,7 +474,7 @@ static int initialize_event_pool(struct event_pool *pool, struct srp_event_struct *evt = >events[i]; memset(>crq, 0x00, sizeof(evt->crq)); atomic_set(>free, 1); - evt->crq.valid = 0x80; + evt->crq.valid = VIOSRP_CRQ_VALID; evt->crq.IU_length = cpu_to_be16(sizeof(*evt->xfer_iu)); evt->crq.IU_data_ptr = cpu_to_be64(pool->iu_token + sizeof(*evt->xfer_iu) * i); @@ -1767,7 +1767,7 @@ static void ibmvscsi_handle_crq(struct viosrp_crq *crq, struct srp_event_struct *evt_struct = (__force struct srp_event_struct *)crq->IU_data_ptr; switch (crq->valid) { - case 0xC0: /* initialization */ + case VIOSRP_CRQ_INIT: /* initialization */ switch (crq->format) { case 0x01: /* Initialization message */ dev_info(hostdata->dev, "partner initialized\n"); @@ -1791,7 +1791,7 @@ static void ibmvscsi_handle_crq(struct viosrp_crq *crq, dev_err(hostdata->dev, "unknown crq message type: %d\n", crq->format); } return; - case 0xFF: /* Hypervisor telling us the connection is closed */ + case VIOSRP_CRQ_TRANSPORT: /* Hypervisor telling us the connection is closed */ scsi_block_requests(hostdata->host); atomic_set(>request_limit, 0); if (crq->format == 0x06) { @@ -1807,7 +1807,7 @@ static void ibmvscsi_handle_crq(struct viosrp_crq *crq, ibmvscsi_reset_host(hostdata); } return; - case 0x80: /* real payload */ + case VIOSRP_CRQ_VALID: /* real payload */ break; default: dev_err(hostdata->dev, "got an invalid message type 0x%02x\n", diff --git a/drivers/scsi/ibmvscsi/viosrp.h b/drivers/scsi/ibmvscsi/viosrp.h index d1044e9..17f2de0 100644 --- a/drivers/scsi/ibmvscsi/viosrp.h +++ b/drivers/scsi/ibmvscsi/viosrp.h @@ -51,6 +51,13 @@ union srp_iu { u8 reserved[SRP_MAX_IU_LEN]; }; +enum viosrp_crq_headers { + VIOSRP_CRQ_FREE = 0x00, + VIOSRP_CRQ_VALID = 0x80, + VIOSRP_CRQ_INIT = 0xC0, + VIOSRP_CRQ_TRANSPORT = 0xFF +}; + enum viosrp_crq_formats { VIOSRP_SRP_FORMAT = 0x01, VIOSRP_MAD_FORMAT = 0x02, ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v2 3/6] cxlflash: Removed driver date print
On 12/14/2015 3:06 PM, Uma Krishnan wrote: Having a date for the driver requires it to be updated quite often. Removing the date which is not necessary. Also made use of the existing symbol to print the driver name. Signed-off-by: Uma Krishnan--- Acked-by: Manoj N. Kumar ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 6/6] cxlflash: Enable device id for future IBM CXL adapter
On 12/13/2015 9:47 PM, Andrew Donnellan wrote: On 11/12/15 09:54, Uma Krishnan wrote: From: Manoj Kumar <ma...@linux.vnet.ibm.com> This drop enables a future card with a device id of 0x0600 to be recognized by the cxlflash driver. No card specific programming has been added. These card specific changes will be staged in later. Signed-off-by: Manoj N. Kumar <ma...@linux.vnet.ibm.com> Without the card-specific code, how does the driver behave if the new card is plugged in? Andrew: As per the design, the Accelerator Function Unit (AFU) for this new IBM CXL Flash Adapater retains the same host interface as the previous generation. For the early prototypes of the new card, the driver with this change behaves exactly as the driver prior to this behaved with the earlier generation card. i.e. No card specific changes are required. However, I left the staging comment in there, in case later versions of the card deviate from the prototype. - Manoj ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/6] cxlflash: Fix to avoid virtual LUN failover failure
On 12/10/2015 4:53 PM, Uma Krishnan wrote: From: "Matthew R. Ochs" <mro...@linux.vnet.ibm.com> To remedy this scenario, provide feedback back to the application on virtual LUN creation as to which ports the LUN may be accessed. LUN's spanning both ports are candidates for a retry in a presence of an I/O failure. Signed-off-by: Matthew R. Ochs <mro...@linux.vnet.ibm.com> Acked-by: Manoj Kumar <ma...@linux.vnet.ibm.com> ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v6 35/37] cxlflash: Fix to avoid corrupting port selection mask
Acked-by: Manoj Kumar <ma...@linux.vnet.ibm.com> On 10/21/2015 3:16 PM, Matthew R. Ochs wrote: The port selection mask of a LUN can be corrupted when the manage LUN ioctl (DK_CXLFLASH_MANAGE_LUN) is issued more than once for any device. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v6 37/37] cxlflash: Fix to avoid bypassing context cleanup
Acked-by: Manoj Kumar <ma...@linux.vnet.ibm.com> On 10/21/2015 3:16 PM, Matthew R. Ochs wrote: Contexts may be skipped over for cleanup in situations where contention for the adapter's table-list mutex is experienced in the presence of a signal during the execution of the release handler. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v6 36/37] cxlflash: Fix to avoid lock instrumentation rejection
Acked-by: Manoj Kumar <ma...@linux.vnet.ibm.com> On 10/21/2015 3:16 PM, Matthew R. Ochs wrote: When running with lock instrumentation (e.g. lockdep), some of the instrumentation can become disabled at probe time for a cxlflash adapter. This is due to a missing lock registration for the tmf_slock. The fix is to call spin_lock_init() for the tmf_slock during probe. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v5 33/34] cxlflash: Fix to avoid leaving dangling interrupt resources
Acked-by: Manoj Kumar <ma...@linux.vnet.ibm.com> ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev