mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chanho Min <chanho.min@lge.com>
To: "'Russell King - ARM Linux'" <linux@arm.linux.org.uk>
Cc: "'Greg Kroah-Hartman'" <gregkh@linuxfoundation.org>,
	"'Jiri Slaby'" <jslaby@suse.com>, <linux-serial@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	"'Jongsung Kim'" <neidhard.kim@lge.com>,
	"'Gunho Lee'" <gunho.lee@lge.com>
Subject: RE: [PATCH] tty: amba-pl011: use sg_table instead of scatterlist
Date: Wed, 9 Mar 2016 09:15:36 +0900	[thread overview]
Message-ID: <05b701d17998$cdd9adc0$698d0940$@lge.com> (raw)
In-Reply-To: <20160308095907.GM19428@n2100.arm.linux.org.uk>

> > @@ -344,17 +344,23 @@ static int pl011_sgbuf_init(struct dma_chan *chan,
> struct pl011_sgbuf *sg,
> >  	enum dma_data_direction dir)
> >  {
> >  	dma_addr_t dma_addr;
> > +	int ret;
> >
> >  	sg->buf = dma_alloc_coherent(chan->device->dev,
> >  		PL011_DMA_BUFFER_SIZE, &dma_addr, GFP_KERNEL);
> >  	if (!sg->buf)
> >  		return -ENOMEM;
> 
> sg->buf can be a mapped address, which virt_to_page() will return
> sg->invalid
> results:
> 
> int dma_common_get_sgtable(struct device *dev, struct sg_table *sgt,
>                  void *cpu_addr, dma_addr_t handle, size_t size) {
>         struct page *page = virt_to_page(cpu_addr);
>         int ret;
> 
>         ret = sg_alloc_table(sgt, 1, GFP_KERNEL);
>         if (unlikely(ret))
>                 return ret;
> 
>         sg_set_page(sgt->sgl, page, PAGE_ALIGN(size), 0);
>         return 0;
> }
> EXPORT_SYMBOL(dma_common_get_sgtable);
> 
> I've no idea who is shoveling crap like this into the kernel, but it's
> _really_ far from good that such broken abstractions are being merged as
> generic code.

dma_get_sgtable goes to ops->get_sgtable first, which dma_to_pfn
will return valid address.
IMHO, Only If ops->alloc returns direct mapping address,
dma_common_get_sgtable can be used.

int arm_dma_get_sgtable(struct device *dev, struct sg_table *sgt,
                 void *cpu_addr, dma_addr_t handle, size_t size,
                 struct dma_attrs *attrs)
{
        struct page *page = pfn_to_page(dma_to_pfn(dev, handle));
        int ret;

      reply	other threads:[~2016-03-09  0:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-08  2:43 Chanho Min
2016-03-08  9:59 ` Russell King - ARM Linux
2016-03-09  0:15   ` Chanho Min [this message]

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='05b701d17998$cdd9adc0$698d0940$@lge.com' \
    --to=chanho.min@lge.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gunho.lee@lge.com \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=neidhard.kim@lge.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®