mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Chanho Min <chanho.min@lge.com>
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: Tue, 8 Mar 2016 09:59:07 +0000	[thread overview]
Message-ID: <20160308095907.GM19428@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1457405016-23562-1-git-send-email-chanho.min@lge.com>

On Tue, Mar 08, 2016 at 11:43:36AM +0900, Chanho Min wrote:
> The use of phys_to_page is wrong in commit cb06ff102e2d ("ARM: PL011:
> Add support for Rx DMA buffer polling."), beacase DMA address is not
> physical address. Also, phys_to_page is not declared in some architecture.
> The use of virt_to_page is wrong as well because dma_alloc_coherent
> implementaion are allowed to returned remapped memory. So I use sg_table
> instead of scatterlist and change to dma_get_sgtable() implementaion.

dma_get_sgtable() is also broken.

> @@ -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 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.

-- 
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

  reply	other threads:[~2016-03-08  9:59 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 [this message]
2016-03-09  0:15   ` Chanho Min

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=20160308095907.GM19428@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=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=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®