mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	cxl: Move cxl_afu_get / cxl_afu_put to base
The Mellanox CX4 uses a model where the AFU is one physical function of the device, and is used by other peer physical functions of the same device. This will require those other devices to grab a reference on the AFU when they are initialised to make sure that it does not go away during their lifetime. Move the AFU refcount functions to base.c so they can be called from the PHB code. Signed-off-by: Ian Munsie <imunsie@au1.ibm.com> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:
		
							parent
							
								
									48b3adf334
								
							
						
					
					
						commit
						62ccf2d2ef
					
				
					 3 changed files with 17 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -54,6 +54,19 @@ static inline void cxl_calls_put(struct cxl_calls *calls) { }
 | 
			
		|||
 | 
			
		||||
#endif /* CONFIG_CXL_MODULE */
 | 
			
		||||
 | 
			
		||||
/* AFU refcount management */
 | 
			
		||||
struct cxl_afu *cxl_afu_get(struct cxl_afu *afu)
 | 
			
		||||
{
 | 
			
		||||
	return (get_device(&afu->dev) == NULL) ? NULL : afu;
 | 
			
		||||
}
 | 
			
		||||
EXPORT_SYMBOL_GPL(cxl_afu_get);
 | 
			
		||||
 | 
			
		||||
void cxl_afu_put(struct cxl_afu *afu)
 | 
			
		||||
{
 | 
			
		||||
	put_device(&afu->dev);
 | 
			
		||||
}
 | 
			
		||||
EXPORT_SYMBOL_GPL(cxl_afu_put);
 | 
			
		||||
 | 
			
		||||
void cxl_slbia(struct mm_struct *mm)
 | 
			
		||||
{
 | 
			
		||||
	struct cxl_calls *calls;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -440,18 +440,6 @@ struct cxl_afu {
 | 
			
		|||
	bool enabled;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* AFU refcount management */
 | 
			
		||||
static inline struct cxl_afu *cxl_afu_get(struct cxl_afu *afu)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	return (get_device(&afu->dev) == NULL) ? NULL : afu;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline void  cxl_afu_put(struct cxl_afu *afu)
 | 
			
		||||
{
 | 
			
		||||
	put_device(&afu->dev);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct cxl_irq_name {
 | 
			
		||||
	struct list_head list;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,11 +36,15 @@ static inline void cxl_ctx_put(void)
 | 
			
		|||
       atomic_dec(&cxl_use_count);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct cxl_afu *cxl_afu_get(struct cxl_afu *afu);
 | 
			
		||||
void cxl_afu_put(struct cxl_afu *afu);
 | 
			
		||||
void cxl_slbia(struct mm_struct *mm);
 | 
			
		||||
 | 
			
		||||
#else /* CONFIG_CXL_BASE */
 | 
			
		||||
 | 
			
		||||
static inline bool cxl_ctx_in_use(void) { return false; }
 | 
			
		||||
static inline struct cxl_afu *cxl_afu_get(struct cxl_afu *afu) { return NULL; }
 | 
			
		||||
static inline void cxl_afu_put(struct cxl_afu *afu) {}
 | 
			
		||||
static inline void cxl_slbia(struct mm_struct *mm) {}
 | 
			
		||||
 | 
			
		||||
#endif /* CONFIG_CXL_BASE */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue