All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Barrat <fbarrat@linux.ibm.com>
To: "Alastair D'Silva" <alastair@au1.ibm.com>
Cc: "Alastair D'Silva" <alastair@d-silva.org>,
	Greg Kurz <groug@kaod.org>,
	Andrew Donnellan <andrew.donnellan@au1.ibm.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 2/7] ocxl: Allow external drivers to use OpenCAPI contexts
Date: Wed, 13 Mar 2019 19:20:44 +0100	[thread overview]
Message-ID: <35bec389-2b70-96cb-c5f5-443bf902c9cd@linux.ibm.com> (raw)
In-Reply-To: <20190313041524.14644-3-alastair@au1.ibm.com>



Le 13/03/2019 à 05:15, Alastair D'Silva a écrit :
> From: Alastair D'Silva <alastair@d-silva.org>
> 
> Most OpenCAPI operations require a valid context, so
> exposing these functions to external drivers is necessary.
> 
> Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
> Reviewed-by: Greg Kurz <groug@kaod.org>
> ---

Patch could also be moved later in the series (same reason as before), but:
Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>


>   drivers/misc/ocxl/context.c       |  9 +++++--
>   drivers/misc/ocxl/file.c          |  2 +-
>   drivers/misc/ocxl/ocxl_internal.h |  6 -----
>   include/misc/ocxl.h               | 44 +++++++++++++++++++++++++++++++
>   4 files changed, 52 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/misc/ocxl/context.c b/drivers/misc/ocxl/context.c
> index 3498a0199bde..1534b56f1db1 100644
> --- a/drivers/misc/ocxl/context.c
> +++ b/drivers/misc/ocxl/context.c
> @@ -8,6 +8,7 @@ struct ocxl_context *ocxl_context_alloc(void)
>   {
>   	return kzalloc(sizeof(struct ocxl_context), GFP_KERNEL);
>   }
> +EXPORT_SYMBOL_GPL(ocxl_context_alloc);
>   
>   int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu,
>   		struct address_space *mapping)
> @@ -43,6 +44,7 @@ int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu,
>   	ocxl_afu_get(afu);
>   	return 0;
>   }
> +EXPORT_SYMBOL_GPL(ocxl_context_init);
>   
>   /*
>    * Callback for when a translation fault triggers an error
> @@ -63,7 +65,7 @@ static void xsl_fault_error(void *data, u64 addr, u64 dsisr)
>   	wake_up_all(&ctx->events_wq);
>   }
>   
> -int ocxl_context_attach(struct ocxl_context *ctx, u64 amr)
> +int ocxl_context_attach(struct ocxl_context *ctx, u64 amr, struct mm_struct *mm)
>   {
>   	int rc;
>   
> @@ -75,7 +77,7 @@ int ocxl_context_attach(struct ocxl_context *ctx, u64 amr)
>   	}
>   
>   	rc = ocxl_link_add_pe(ctx->afu->fn->link, ctx->pasid,
> -			current->mm->context.id, ctx->tidr, amr, current->mm,
> +			mm->context.id, ctx->tidr, amr, mm,
>   			xsl_fault_error, ctx);
>   	if (rc)
>   		goto out;
> @@ -85,6 +87,7 @@ int ocxl_context_attach(struct ocxl_context *ctx, u64 amr)
>   	mutex_unlock(&ctx->status_mutex);
>   	return rc;
>   }
> +EXPORT_SYMBOL_GPL(ocxl_context_attach);
>   
>   static vm_fault_t map_afu_irq(struct vm_area_struct *vma, unsigned long address,
>   		u64 offset, struct ocxl_context *ctx)
> @@ -243,6 +246,7 @@ int ocxl_context_detach(struct ocxl_context *ctx)
>   	}
>   	return 0;
>   }
> +EXPORT_SYMBOL_GPL(ocxl_context_detach);
>   
>   void ocxl_context_detach_all(struct ocxl_afu *afu)
>   {
> @@ -280,3 +284,4 @@ void ocxl_context_free(struct ocxl_context *ctx)
>   	ocxl_afu_put(ctx->afu);
>   	kfree(ctx);
>   }
> +EXPORT_SYMBOL_GPL(ocxl_context_free);
> diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
> index 16eb8a60d5c7..865b3d176431 100644
> --- a/drivers/misc/ocxl/file.c
> +++ b/drivers/misc/ocxl/file.c
> @@ -100,7 +100,7 @@ static long afu_ioctl_attach(struct ocxl_context *ctx,
>   		return -EINVAL;
>   
>   	amr = arg.amr & mfspr(SPRN_UAMOR);
> -	rc = ocxl_context_attach(ctx, amr);
> +	rc = ocxl_context_attach(ctx, amr, current->mm);
>   	return rc;
>   }
>   
> diff --git a/drivers/misc/ocxl/ocxl_internal.h b/drivers/misc/ocxl/ocxl_internal.h
> index 06fd98c989c8..779d15ef60b5 100644
> --- a/drivers/misc/ocxl/ocxl_internal.h
> +++ b/drivers/misc/ocxl/ocxl_internal.h
> @@ -130,15 +130,9 @@ int ocxl_config_check_afu_index(struct pci_dev *dev,
>    */
>   int ocxl_link_update_pe(void *link_handle, int pasid, __u16 tid);
>   
> -struct ocxl_context *ocxl_context_alloc(void);
> -int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu,
> -			struct address_space *mapping);
> -int ocxl_context_attach(struct ocxl_context *ctx, u64 amr);
>   int ocxl_context_mmap(struct ocxl_context *ctx,
>   			struct vm_area_struct *vma);
> -int ocxl_context_detach(struct ocxl_context *ctx);
>   void ocxl_context_detach_all(struct ocxl_afu *afu);
> -void ocxl_context_free(struct ocxl_context *ctx);
>   
>   int ocxl_sysfs_add_afu(struct ocxl_afu *afu);
>   void ocxl_sysfs_remove_afu(struct ocxl_afu *afu);
> diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h
> index 3b320c39f0af..ebbfe83cd5a6 100644
> --- a/include/misc/ocxl.h
> +++ b/include/misc/ocxl.h
> @@ -51,6 +51,7 @@ struct ocxl_fn_config {
>   
>   // These are opaque outside the ocxl driver
>   struct ocxl_afu;
> +struct ocxl_context;
>   
>   enum ocxl_endian {
>   	OCXL_BIG_ENDIAN = 0,    /**< AFU data is big-endian */
> @@ -58,6 +59,49 @@ enum ocxl_endian {
>   	OCXL_HOST_ENDIAN = 2,   /**< AFU data is the same endianness as the host */
>   };
>   
> +/**
> + * Allocate space for a new OpenCAPI context
> + *
> + * Returns NULL on failure
> + */
> +struct ocxl_context *ocxl_context_alloc(void);
> +
> +/**
> + * Initialize an OpenCAPI context
> + *
> + * @ctx: The OpenCAPI context to initialize
> + * @afu: The AFU the context belongs to
> + * @mapping: The mapping to unmap when the context is closed (may be NULL)
> + */
> +int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu,
> +			struct address_space *mapping);
> +
> +/**
> + * Free an OpenCAPI context
> + *
> + * @ctx: The OpenCAPI context to free
> + */
> +void ocxl_context_free(struct ocxl_context *ctx);
> +
> +/**
> + * Grant access to an MM to an OpenCAPI context
> + * @ctx: The OpenCAPI context to attach
> + * @amr: The value of the AMR register to restrict access
> + * @mm: The mm to attach to the context
> + *
> + * Returns 0 on success, negative on failure
> + */
> +int ocxl_context_attach(struct ocxl_context *ctx, u64 amr,
> +				struct mm_struct *mm);
> +
> +/**
> + * Detach an MM from an OpenCAPI context
> + * @ctx: The OpenCAPI context to attach
> + *
> + * Returns 0 on success, negative on failure
> + */
> +int ocxl_context_detach(struct ocxl_context *ctx);
> +
>   /**
>    * Read a 32 bit value from global MMIO
>    *
> 


WARNING: multiple messages have this Message-ID (diff)
From: Frederic Barrat <fbarrat@linux.ibm.com>
To: "Alastair D'Silva" <alastair@au1.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, Greg Kurz <groug@kaod.org>,
	Andrew Donnellan <andrew.donnellan@au1.ibm.com>,
	Alastair D'Silva <alastair@d-silva.org>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 2/7] ocxl: Allow external drivers to use OpenCAPI contexts
Date: Wed, 13 Mar 2019 19:20:44 +0100	[thread overview]
Message-ID: <35bec389-2b70-96cb-c5f5-443bf902c9cd@linux.ibm.com> (raw)
In-Reply-To: <20190313041524.14644-3-alastair@au1.ibm.com>



Le 13/03/2019 à 05:15, Alastair D'Silva a écrit :
> From: Alastair D'Silva <alastair@d-silva.org>
> 
> Most OpenCAPI operations require a valid context, so
> exposing these functions to external drivers is necessary.
> 
> Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
> Reviewed-by: Greg Kurz <groug@kaod.org>
> ---

Patch could also be moved later in the series (same reason as before), but:
Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>


>   drivers/misc/ocxl/context.c       |  9 +++++--
>   drivers/misc/ocxl/file.c          |  2 +-
>   drivers/misc/ocxl/ocxl_internal.h |  6 -----
>   include/misc/ocxl.h               | 44 +++++++++++++++++++++++++++++++
>   4 files changed, 52 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/misc/ocxl/context.c b/drivers/misc/ocxl/context.c
> index 3498a0199bde..1534b56f1db1 100644
> --- a/drivers/misc/ocxl/context.c
> +++ b/drivers/misc/ocxl/context.c
> @@ -8,6 +8,7 @@ struct ocxl_context *ocxl_context_alloc(void)
>   {
>   	return kzalloc(sizeof(struct ocxl_context), GFP_KERNEL);
>   }
> +EXPORT_SYMBOL_GPL(ocxl_context_alloc);
>   
>   int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu,
>   		struct address_space *mapping)
> @@ -43,6 +44,7 @@ int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu,
>   	ocxl_afu_get(afu);
>   	return 0;
>   }
> +EXPORT_SYMBOL_GPL(ocxl_context_init);
>   
>   /*
>    * Callback for when a translation fault triggers an error
> @@ -63,7 +65,7 @@ static void xsl_fault_error(void *data, u64 addr, u64 dsisr)
>   	wake_up_all(&ctx->events_wq);
>   }
>   
> -int ocxl_context_attach(struct ocxl_context *ctx, u64 amr)
> +int ocxl_context_attach(struct ocxl_context *ctx, u64 amr, struct mm_struct *mm)
>   {
>   	int rc;
>   
> @@ -75,7 +77,7 @@ int ocxl_context_attach(struct ocxl_context *ctx, u64 amr)
>   	}
>   
>   	rc = ocxl_link_add_pe(ctx->afu->fn->link, ctx->pasid,
> -			current->mm->context.id, ctx->tidr, amr, current->mm,
> +			mm->context.id, ctx->tidr, amr, mm,
>   			xsl_fault_error, ctx);
>   	if (rc)
>   		goto out;
> @@ -85,6 +87,7 @@ int ocxl_context_attach(struct ocxl_context *ctx, u64 amr)
>   	mutex_unlock(&ctx->status_mutex);
>   	return rc;
>   }
> +EXPORT_SYMBOL_GPL(ocxl_context_attach);
>   
>   static vm_fault_t map_afu_irq(struct vm_area_struct *vma, unsigned long address,
>   		u64 offset, struct ocxl_context *ctx)
> @@ -243,6 +246,7 @@ int ocxl_context_detach(struct ocxl_context *ctx)
>   	}
>   	return 0;
>   }
> +EXPORT_SYMBOL_GPL(ocxl_context_detach);
>   
>   void ocxl_context_detach_all(struct ocxl_afu *afu)
>   {
> @@ -280,3 +284,4 @@ void ocxl_context_free(struct ocxl_context *ctx)
>   	ocxl_afu_put(ctx->afu);
>   	kfree(ctx);
>   }
> +EXPORT_SYMBOL_GPL(ocxl_context_free);
> diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
> index 16eb8a60d5c7..865b3d176431 100644
> --- a/drivers/misc/ocxl/file.c
> +++ b/drivers/misc/ocxl/file.c
> @@ -100,7 +100,7 @@ static long afu_ioctl_attach(struct ocxl_context *ctx,
>   		return -EINVAL;
>   
>   	amr = arg.amr & mfspr(SPRN_UAMOR);
> -	rc = ocxl_context_attach(ctx, amr);
> +	rc = ocxl_context_attach(ctx, amr, current->mm);
>   	return rc;
>   }
>   
> diff --git a/drivers/misc/ocxl/ocxl_internal.h b/drivers/misc/ocxl/ocxl_internal.h
> index 06fd98c989c8..779d15ef60b5 100644
> --- a/drivers/misc/ocxl/ocxl_internal.h
> +++ b/drivers/misc/ocxl/ocxl_internal.h
> @@ -130,15 +130,9 @@ int ocxl_config_check_afu_index(struct pci_dev *dev,
>    */
>   int ocxl_link_update_pe(void *link_handle, int pasid, __u16 tid);
>   
> -struct ocxl_context *ocxl_context_alloc(void);
> -int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu,
> -			struct address_space *mapping);
> -int ocxl_context_attach(struct ocxl_context *ctx, u64 amr);
>   int ocxl_context_mmap(struct ocxl_context *ctx,
>   			struct vm_area_struct *vma);
> -int ocxl_context_detach(struct ocxl_context *ctx);
>   void ocxl_context_detach_all(struct ocxl_afu *afu);
> -void ocxl_context_free(struct ocxl_context *ctx);
>   
>   int ocxl_sysfs_add_afu(struct ocxl_afu *afu);
>   void ocxl_sysfs_remove_afu(struct ocxl_afu *afu);
> diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h
> index 3b320c39f0af..ebbfe83cd5a6 100644
> --- a/include/misc/ocxl.h
> +++ b/include/misc/ocxl.h
> @@ -51,6 +51,7 @@ struct ocxl_fn_config {
>   
>   // These are opaque outside the ocxl driver
>   struct ocxl_afu;
> +struct ocxl_context;
>   
>   enum ocxl_endian {
>   	OCXL_BIG_ENDIAN = 0,    /**< AFU data is big-endian */
> @@ -58,6 +59,49 @@ enum ocxl_endian {
>   	OCXL_HOST_ENDIAN = 2,   /**< AFU data is the same endianness as the host */
>   };
>   
> +/**
> + * Allocate space for a new OpenCAPI context
> + *
> + * Returns NULL on failure
> + */
> +struct ocxl_context *ocxl_context_alloc(void);
> +
> +/**
> + * Initialize an OpenCAPI context
> + *
> + * @ctx: The OpenCAPI context to initialize
> + * @afu: The AFU the context belongs to
> + * @mapping: The mapping to unmap when the context is closed (may be NULL)
> + */
> +int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu,
> +			struct address_space *mapping);
> +
> +/**
> + * Free an OpenCAPI context
> + *
> + * @ctx: The OpenCAPI context to free
> + */
> +void ocxl_context_free(struct ocxl_context *ctx);
> +
> +/**
> + * Grant access to an MM to an OpenCAPI context
> + * @ctx: The OpenCAPI context to attach
> + * @amr: The value of the AMR register to restrict access
> + * @mm: The mm to attach to the context
> + *
> + * Returns 0 on success, negative on failure
> + */
> +int ocxl_context_attach(struct ocxl_context *ctx, u64 amr,
> +				struct mm_struct *mm);
> +
> +/**
> + * Detach an MM from an OpenCAPI context
> + * @ctx: The OpenCAPI context to attach
> + *
> + * Returns 0 on success, negative on failure
> + */
> +int ocxl_context_detach(struct ocxl_context *ctx);
> +
>   /**
>    * Read a 32 bit value from global MMIO
>    *
> 


  reply	other threads:[~2019-03-13 18:21 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13  4:15 [PATCH 0/7] Refactor OCXL driver to allow external drivers to use it Alastair D'Silva
2019-03-13  4:15 ` Alastair D'Silva
2019-03-13  4:15 ` [PATCH 1/7] ocxl: Provide global MMIO accessors for external drivers Alastair D'Silva
2019-03-13  4:15   ` Alastair D'Silva
2019-03-13 18:06   ` Frederic Barrat
2019-03-13 18:06     ` Frederic Barrat
2019-03-15  4:11   ` Andrew Donnellan
2019-03-15  4:11     ` Andrew Donnellan
2019-03-13  4:15 ` [PATCH 2/7] ocxl: Allow external drivers to use OpenCAPI contexts Alastair D'Silva
2019-03-13  4:15   ` Alastair D'Silva
2019-03-13 18:20   ` Frederic Barrat [this message]
2019-03-13 18:20     ` Frederic Barrat
2019-03-13  4:15 ` [PATCH 3/7] ocxl: Split pci.c Alastair D'Silva
2019-03-13  4:15   ` Alastair D'Silva
2019-03-14 16:48   ` Frederic Barrat
2019-03-13  4:15 ` [PATCH 4/7] ocxl: Don't pass pci_dev around Alastair D'Silva
2019-03-13  4:15   ` Alastair D'Silva
2019-03-14 17:00   ` Frederic Barrat
2019-03-14 17:00     ` Frederic Barrat
2019-03-15  3:32   ` Andrew Donnellan
2019-03-15  3:32     ` Andrew Donnellan
2019-03-13  4:15 ` [PATCH 5/7] ocxl: Create a clear delineation between ocxl backend & frontend Alastair D'Silva
2019-03-13  4:15   ` Alastair D'Silva
2019-03-14 16:27   ` Frederic Barrat
2019-03-14 16:27     ` Frederic Barrat
2019-03-13  4:15 ` [PATCH 6/7] ocxl: afu_irq only deals with IRQ IDs, not offsets Alastair D'Silva
2019-03-13  4:15   ` Alastair D'Silva
2019-03-15 13:56   ` Greg Kurz
2019-03-20  0:28     ` Alastair D'Silva
2019-03-13  4:15 ` [PATCH 7/7] ocxl: move event_fd handling to frontend Alastair D'Silva
2019-03-13  4:15   ` Alastair D'Silva
2019-03-20  5:08 ` [PATCH v2 0/7] Refactor OCXL driver to allow external drivers to use it Alastair D'Silva
2019-03-20  5:08   ` Alastair D'Silva
2019-03-20  5:08   ` [PATCH v2 1/7] ocxl: Split pci.c Alastair D'Silva
2019-03-20  5:08     ` Alastair D'Silva
2019-03-20  5:08   ` [PATCH v2 2/7] ocxl: Don't pass pci_dev around Alastair D'Silva
2019-03-20  5:08     ` Alastair D'Silva
2019-03-20  5:08   ` [PATCH v2 3/7] ocxl: Create a clear delineation between ocxl backend & frontend Alastair D'Silva
2019-03-20  5:08     ` Alastair D'Silva
2019-03-22 17:38     ` Frederic Barrat
2019-03-22 17:38       ` Frederic Barrat
2019-03-20  5:08   ` [PATCH v2 4/7] ocxl: Allow external drivers to use OpenCAPI contexts Alastair D'Silva
2019-03-20  5:08     ` Alastair D'Silva
2019-03-20  5:08   ` [PATCH v2 5/7] ocxl: afu_irq only deals with IRQ IDs, not offsets Alastair D'Silva
2019-03-20  5:08     ` Alastair D'Silva
2019-03-20  5:08   ` [PATCH v2 6/7] ocxl: move event_fd handling to frontend Alastair D'Silva
2019-03-20  5:08     ` Alastair D'Silva
2019-03-20  5:08   ` [PATCH v2 7/7] ocxl: Provide global MMIO accessors for external drivers Alastair D'Silva
2019-03-20  5:08     ` Alastair D'Silva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=35bec389-2b70-96cb-c5f5-443bf902c9cd@linux.ibm.com \
    --to=fbarrat@linux.ibm.com \
    --cc=alastair@au1.ibm.com \
    --cc=alastair@d-silva.org \
    --cc=andrew.donnellan@au1.ibm.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=groug@kaod.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.