All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@sous-sol.org>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: chrisw@sous-sol.org, jeremy@goop.org,
	xen-devel@lists.xensource.com, Ian.Campbell@eu.citrix.com,
	joerg.roedel@amd.com, fujita.tomonori@lab.ntt.co.jp,
	iommu@lists.linux-foundation.org, dwmw2@infradead.org,
	alex.williamson@hp.com
Subject: Re: [PATCH 03/15] [swiotlb] Add swiotlb_register_engine function.
Date: Thu, 14 Jan 2010 17:41:29 -0800	[thread overview]
Message-ID: <20100115014129.GC6021@sequoia.sous-sol.org> (raw)
In-Reply-To: <1263510064-16788-4-git-send-email-konrad.wilk@oracle.com>

* Konrad Rzeszutek Wilk (konrad.wilk@oracle.com) wrote:
> We set the internal iommu_sw pointer to the passed in swiotlb_engine
> structure. Obviously we also check if the existing iommu_sw is
> set and if so, call iommu_sw->release before the switch-over.
> 
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
>  include/linux/swiotlb.h |    2 +
>  lib/swiotlb.c           |   48 +++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 50 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
> index 781c3aa..3bc3c42 100644
> --- a/include/linux/swiotlb.h
> +++ b/include/linux/swiotlb.h
> @@ -118,6 +118,8 @@ struct swiotlb_engine {
>  	void* (*bus_to_virt)(struct device *hwdev, dma_addr_t address);
>  };
>  
> +int swiotlb_register_engine(struct swiotlb_engine *iommu);
> +
>  extern void
>  *swiotlb_alloc_coherent(struct device *hwdev, size_t size,
>  			dma_addr_t *dma_handle, gfp_t flags);
> diff --git a/lib/swiotlb.c b/lib/swiotlb.c
> index e6d9e32..e84f269 100644
> --- a/lib/swiotlb.c
> +++ b/lib/swiotlb.c
> @@ -97,6 +97,12 @@ static phys_addr_t *io_tlb_orig_addr;
>   */
>  static DEFINE_SPINLOCK(io_tlb_lock);
>  
> +/*
> + * The software IOMMU this library will utilize.
> + */
> +struct swiotlb_engine *iommu_sw;
> +EXPORT_SYMBOL(iommu_sw);

should be EXPORT_SYMBOL_GPL

>  static int late_alloc;
>  
>  static int __init
> @@ -126,6 +132,48 @@ static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev,
>  	return phys_to_dma(hwdev, virt_to_phys(address));
>  }
>  
> +/*
> + * Register a software IO TLB engine.
> + *
> + * The registration allows the software IO TLB functions in the
> + * swiotlb library to function properly.
> + *
> + * All the values in the iotlb structure must be set.
> + *
> + * If the registration fails, it is assumed that the caller will free
> + * all of the resources allocated in the swiotlb_engine structure.
> + */
> +int swiotlb_register_engine(struct swiotlb_engine *iommu)
> +{
> +	if (!iommu || !iommu->name || !iommu->release) {
> +		printk(KERN_ERR "DMA: Trying to register a SWIOTLB engine" \
> +				" improperly!");
> +		return -EINVAL;
> +	}
> +
> +	if (iommu_sw && iommu_sw->name) {

According to above, you can't have !iommu_sw->name.

> +		int retval = -EINVAL;
> +
> +		/* 'release' must check for out-standing DMAs and flush them
> +		 *  out or fail. */
> +		if (iommu_sw->release)
> +			retval = iommu_sw->release(iommu_sw);

Same here, you can't have !iommu_sw->release, just call unconditionally.

> +
> +		if (retval) {
> +			printk(KERN_ERR "DMA: %s cannot be released!\n",
> +				iommu_sw->name);
> +			return retval;
> +		}
> +		printk(KERN_INFO "DMA: Replacing [%s] with [%s]\n",
> +			iommu_sw->name, iommu->name);
> +	}
> +
> +	iommu_sw = iommu;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(swiotlb_register_engine);
> +
>  void swiotlb_print_info(void)
>  {
>  	unsigned long bytes = io_tlb_nslabs << IO_TLB_SHIFT;

  parent reply	other threads:[~2010-01-15  1:41 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-14 23:00 [RFC SWIOTLB-0.2] Konrad Rzeszutek Wilk
2010-01-14 23:00 ` [PATCH 01/15] [swiotlb] fix: Update 'setup_io_tlb_npages' to accept both arguments in either order Konrad Rzeszutek Wilk
2010-01-14 23:00   ` [PATCH 02/15] [swiotlb] Add swiotlb_engine structure for tracking multiple software IO TLBs Konrad Rzeszutek Wilk
2010-01-14 23:00     ` [PATCH 03/15] [swiotlb] Add swiotlb_register_engine function Konrad Rzeszutek Wilk
2010-01-14 23:00       ` [PATCH 04/15] [swiotlb] Search and replace s/io_tlb/iommu_sw->/ Konrad Rzeszutek Wilk
2010-01-14 23:00         ` [PATCH 05/15] [swiotlb] Respect the io_tlb_nslabs argument value Konrad Rzeszutek Wilk
2010-01-14 23:00           ` [PATCH 06/15] [swiotlb] In 'swiotlb_init' take advantage of the default swiotlb_engine support Konrad Rzeszutek Wilk
2010-01-14 23:00             ` [PATCH 07/15] [swiotlb] In 'swiotlb_free' check iommu_sw pointer Konrad Rzeszutek Wilk
2010-01-14 23:00               ` [PATCH 08/15] [swiotlb] Add 'is_swiotlb_buffer' to the swiotlb_ops function decleration Konrad Rzeszutek Wilk
2010-01-14 23:00                 ` [PATCH 09/15] [swiotlb] Add 'dma_capable' to the swiotlb_ops structure Konrad Rzeszutek Wilk
2010-01-14 23:00                   ` [PATCH 10/15] [swiotlb] Replace the [phys, bus]->virt and virt->[bus, phys] functions with iommu_sw calls Konrad Rzeszutek Wilk
2010-01-14 23:01                     ` [PATCH 11/15] [swiotlb] Replace late_alloc with iommu_sw->priv usage Konrad Rzeszutek Wilk
2010-01-14 23:01                       ` [PATCH 12/15] [swiotlb] Remove un-used static declerations obsoleted by iommu_sw Konrad Rzeszutek Wilk
2010-01-14 23:01                         ` [PATCH 13/15] [swiotlb] Make io_tlb_nslabs visible outside lib/swiotlb.c and rename it Konrad Rzeszutek Wilk
2010-01-14 23:01                           ` [PATCH 14/15] [swiotlb] Move initialization (swiotlb_init) and its friends in swiotlb-default.c Konrad Rzeszutek Wilk
2010-01-14 23:01                             ` [PATCH 15/15] [swiotlb] Take advantage of iommu_sw->name and add %s to printk's Konrad Rzeszutek Wilk
2010-01-15  2:14                             ` [PATCH 14/15] [swiotlb] Move initialization (swiotlb_init) and its friends in swiotlb-default.c Chris Wright
2010-01-19 17:45                               ` Konrad Rzeszutek Wilk
2010-01-19 18:55                                 ` Chris Wright
2010-01-15  2:02               ` [PATCH 07/15] [swiotlb] In 'swiotlb_free' check iommu_sw pointer Chris Wright
2010-01-19 17:45                 ` Konrad Rzeszutek Wilk
2010-01-19 18:23                   ` Chris Wright
2010-01-15  1:57             ` [PATCH 06/15] [swiotlb] In 'swiotlb_init' take advantage of the default swiotlb_engine support Chris Wright
2010-01-19 17:45               ` Konrad Rzeszutek Wilk
2010-01-15  1:47           ` [PATCH 05/15] [swiotlb] Respect the io_tlb_nslabs argument value Chris Wright
2010-01-15  1:43         ` [PATCH 04/15] [swiotlb] Search and replace s/io_tlb/iommu_sw->/ Chris Wright
2010-01-19 17:45           ` Konrad Rzeszutek Wilk
2010-01-15  1:41       ` Chris Wright [this message]
2010-01-19 17:25         ` [PATCH 03/15] [swiotlb] Add swiotlb_register_engine function Konrad Rzeszutek Wilk
2010-01-15  1:33     ` [PATCH 02/15] [swiotlb] Add swiotlb_engine structure for tracking multiple software IO TLBs Chris Wright
2010-01-19 17:46       ` Konrad Rzeszutek Wilk
2010-01-19 18:43         ` Chris Wright
2010-01-22  1:51     ` FUJITA Tomonori
2010-01-26 16:20       ` Konrad Rzeszutek Wilk
2010-02-03  2:04         ` FUJITA Tomonori
2010-02-03 17:08           ` [RFC SWIOTLB-0.4] Konrad Rzeszutek Wilk
2010-02-03 17:08             ` [PATCH 01/11] [swiotlb] fix: Update 'setup_io_tlb_npages' to accept both arguments in either order Konrad Rzeszutek Wilk
2010-02-03 17:08               ` [PATCH 02/11] [swiotlb] Make 'setup_io_tlb_npages' accept new 'swiotlb=' syntax Konrad Rzeszutek Wilk
2010-02-03 17:08                 ` [PATCH 03/11] [swiotlb] Normalize the swiotlb_init_* function's naming syntax Konrad Rzeszutek Wilk
2010-02-03 17:08                   ` [PATCH 04/11] [swiotlb] Make printk's use same prefix and include dev_err when possible Konrad Rzeszutek Wilk
2010-02-03 17:08                     ` [PATCH 05/11] [swiotlb] Make internal bookkeeping functions have 'do_' prefix Konrad Rzeszutek Wilk
2010-02-03 17:08                       ` [PATCH 06/11] [swiotlb] do_map_single: abstract out swiotlb_virt_to_bus calls out Konrad Rzeszutek Wilk
2010-02-03 17:08                         ` [PATCH 07/11] [swiotlb] Fix checkpatch warnings Konrad Rzeszutek Wilk
2010-02-03 17:08                           ` [PATCH 08/11] [swiotlb] Re-order the function declerations Konrad Rzeszutek Wilk
2010-02-03 17:08                             ` [PATCH 09/11] [swiotlb] Make swiotlb bookkeeping functions visible in the header file Konrad Rzeszutek Wilk
2010-02-03 17:08                               ` [PATCH 10/11] [swiotlb] Rename swiotlb.c to swiotlb-core.c Konrad Rzeszutek Wilk
2010-02-03 17:08                                 ` [PATCH 11/11] [swiotlb] move dma_ops functions to swiotlb.c Konrad Rzeszutek Wilk
2010-02-04  0:17             ` [RFC SWIOTLB-0.4] FUJITA Tomonori
2010-02-04  3:07               ` Konrad Rzeszutek Wilk
2010-02-16 23:37                 ` Konrad Rzeszutek Wilk
2010-01-15  1:22   ` [PATCH 01/15] [swiotlb] fix: Update 'setup_io_tlb_npages' to accept both arguments in either order Chris Wright
2010-01-19 17:47     ` Konrad Rzeszutek Wilk
2010-01-19 19:00       ` Chris Wright
2010-01-19 19:39         ` Konrad Rzeszutek Wilk
2010-01-15  2:25 ` [RFC SWIOTLB-0.2] Chris Wright
2010-01-19 18:20   ` Konrad Rzeszutek Wilk

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=20100115014129.GC6021@sequoia.sous-sol.org \
    --to=chrisw@sous-sol.org \
    --cc=Ian.Campbell@eu.citrix.com \
    --cc=alex.williamson@hp.com \
    --cc=dwmw2@infradead.org \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jeremy@goop.org \
    --cc=joerg.roedel@amd.com \
    --cc=konrad.wilk@oracle.com \
    --cc=xen-devel@lists.xensource.com \
    /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.