Skip to content

Commit

Permalink
cxl: Separate bare-metal fields in adapter and AFU data structures
Browse files Browse the repository at this point in the history
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 <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Christophe Lombard <clombard@linux.vnet.ibm.com>
Reviewed-by: Manoj Kumar <manoj@linux.vnet.ibm.com>
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
  • Loading branch information
2 people authored and Michael Ellerman committed Mar 9, 2016
1 parent 444c4ba commit cbffa3a
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 111 deletions.
2 changes: 1 addition & 1 deletion drivers/misc/cxl/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = &ctx->afu->spa[i];
ctx->elem = &ctx->afu->native->spa[i];
ctx->pe_inserted = false;

/*
Expand Down
84 changes: 58 additions & 26 deletions drivers/misc/cxl/cxl.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,45 +344,57 @@ 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;
struct device *chardev_s, *chardev_m, *chardev_d;
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;

Expand Down Expand Up @@ -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_SLICES];
struct device dev;
Expand All @@ -503,9 +538,6 @@ struct cxl {
struct bin_attribute cxl_attr;
int adapter_num;
int user_irqs;
u64 afu_desc_off;
u64 afu_desc_size;
u64 ps_off;
u64 ps_size;
u16 psl_rev;
u16 base_image;
Expand Down Expand Up @@ -570,7 +602,7 @@ static inline bool cxl_adapter_link_ok(struct cxl *cxl)
static inline void __iomem *_cxl_p1_addr(struct cxl *cxl, cxl_p1_reg_t reg)
{
WARN_ON(!cpu_has_feature(CPU_FTR_HVMODE));
return cxl->p1_mmio + cxl_reg_off(reg);
return cxl->native->p1_mmio + cxl_reg_off(reg);
}

static inline void cxl_p1_write(struct cxl *cxl, cxl_p1_reg_t reg, u64 val)
Expand All @@ -590,7 +622,7 @@ static inline u64 cxl_p1_read(struct cxl *cxl, cxl_p1_reg_t reg)
static inline void __iomem *_cxl_p1n_addr(struct cxl_afu *afu, cxl_p1n_reg_t reg)
{
WARN_ON(!cpu_has_feature(CPU_FTR_HVMODE));
return afu->p1n_mmio + cxl_reg_off(reg);
return afu->native->p1n_mmio + cxl_reg_off(reg);
}

static inline void cxl_p1n_write(struct cxl_afu *afu, cxl_p1n_reg_t reg, u64 val)
Expand Down
2 changes: 1 addition & 1 deletion drivers/misc/cxl/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ int afu_allocate_irqs(struct cxl_context *ctx, u32 count)

if (cpu_has_feature(CPU_FTR_HVMODE)) {
/* Multiplexed PSL Interrupt */
ctx->irqs.offset[0] = ctx->afu->psl_hwirq;
ctx->irqs.offset[0] = ctx->afu->native->psl_hwirq;
ctx->irqs.range[0] = 1;
}

Expand Down
1 change: 0 additions & 1 deletion drivers/misc/cxl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ struct cxl_afu *cxl_alloc_afu(struct cxl *adapter, int slice)
idr_init(&afu->contexts_idr);
mutex_init(&afu->contexts_lock);
spin_lock_init(&afu->afu_cntl_lock);
mutex_init(&afu->spa_mutex);

afu->prefault_mode = CXL_PREFAULT_NONE;
afu->irqs_max = afu->adapter->user_irqs;
Expand Down
Loading

0 comments on commit cbffa3a

Please sign in to comment.