All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Shuah Khan <shuah.khan@hp.com>
Cc: Joerg Roedel <joro@8bytes.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	kubakici@wp.pl, stern@rowland.harvard.edu,
	Greg KH <gregkh@linuxfoundation.org>,
	Mark Salter <msalter@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	shuahkhan@gmail.com
Subject: Re: [PATCH] dma-debug: fix to not have dependency on get_dma_ops() interface
Date: Mon, 5 Nov 2012 08:59:29 -0500	[thread overview]
Message-ID: <20121105135929.GF11802@phenom.dumpdata.com> (raw)
In-Reply-To: <1351983607.2773.9.camel@lorien2>

On Sat, Nov 03, 2012 at 05:00:07PM -0600, Shuah Khan wrote:
> dma-debug depends on get_dma_ops() interface. Several architectures
> do not define dma_ops and get_dma_ops(). When dma debug interfaces are
> used on an architecture (e.g: c6x) that doesn't define get_dmap_ops(),
> compilation fails. Changing dma-debug to call dma_mapping_error() instead
> of defining its own that calls get_dma_ops(), such that the internal use of
> dma_mapping_error() doesn't interfere with the debug_dma_mapping_error()
> interface's mapping error checks. Moving dma_mapping_error() checks in
> check_unmap() under the dma debug entry not found is sufficient to fix the
> problem.

OK.

It looks ok to me.

> -   debug_dma_mapping_error() - need internal mapping error routine to
> -   avoid debug checks */
> -#ifndef DMA_ERROR_CODE
> -#define DMA_ERROR_CODE 0
> -#endif
> -static inline int has_mapping_error(struct device *dev, dma_addr_t dma_addr)
> -{
> -	const struct dma_map_ops *ops = get_dma_ops(dev);
> -	if (ops->mapping_error)
> -		return ops->mapping_error(dev, dma_addr);
> -
> -	return (dma_addr == DMA_ERROR_CODE);
> -}
> -
>  static void check_unmap(struct dma_debug_entry *ref)
>  {
>  	struct dma_debug_entry *entry;
>  	struct hash_bucket *bucket;
>  	unsigned long flags;
>  
> -	if (unlikely(has_mapping_error(ref->dev, ref->dev_addr))) {
> -		err_printk(ref->dev, NULL, "DMA-API: device driver tries "
> -			   "to free an invalid DMA memory address\n");
> -		return;
> -	}
> -
>  	bucket = get_hash_bucket(ref, &flags);
>  	entry = bucket_find_exact(bucket, ref);
>  
>  	if (!entry) {
> +		if (dma_mapping_error(ref->dev, ref->dev_addr)) {
> +			err_printk(ref->dev, NULL,
> +				   "DMA-API: device driver tries "
> +				   "to free an invalid DMA memory address\n");
> +			return;
> +		}
>  		err_printk(ref->dev, NULL, "DMA-API: device driver tries "
>  			   "to free DMA memory it has not allocated "
>  			   "[device address=0x%016llx] [size=%llu bytes]\n",
> @@ -1055,7 +1040,7 @@ void debug_dma_map_page(struct device *dev, struct page *page, size_t offset,
>  	if (unlikely(global_disable))
>  		return;
>  
> -	if (unlikely(has_mapping_error(dev, dma_addr)))
> +	if (dma_mapping_error(dev, dma_addr))
>  		return;
>  
>  	entry = dma_entry_alloc();
> -- 
> 1.7.9.5
> 
> 

  reply	other threads:[~2012-11-05 14:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-03 23:00 [PATCH] dma-debug: fix to not have dependency on get_dma_ops() interface Shuah Khan
2012-11-05 13:59 ` Konrad Rzeszutek Wilk [this message]
2012-11-15 17:04   ` Shuah Khan
2012-11-17 12:07 ` Joerg Roedel

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=20121105135929.GF11802@phenom.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=joro@8bytes.org \
    --cc=kubakici@wp.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=msalter@redhat.com \
    --cc=shuah.khan@hp.com \
    --cc=shuahkhan@gmail.com \
    --cc=stern@rowland.harvard.edu \
    /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.