From: Hans Verkuil <hverkuil@xs4all.nl>
To: Mauro Carvalho Chehab <m.chehab@samsung.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
Mauro Carvalho Chehab <mchehab@infradead.org>,
Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [PATCH 3/3] [media] tw68: don't assume that pagesize is always 4096
Date: Thu, 04 Sep 2014 18:21:30 +0200 [thread overview]
Message-ID: <5408918A.2090607@xs4all.nl> (raw)
In-Reply-To: <5bbc05f52d23b17cc0faa81a2e5d4f2a344aaaa9.1409841955.git.m.chehab@samsung.com>
On 09/04/2014 04:46 PM, Mauro Carvalho Chehab wrote:
> This code implicitly assumes that pagesize is 4096, but this is
> not true on all archs, as the PAGE_SHIFT can be different than
> 12 on all those architectures: alpha, arc, arm64, cris, frv,
> hexagon,ia64, m68k, metag, microblaze, mips, openrisc, parisc,
> powerpc, sh, sparc and tile.
>
> The real constrant here seems to be to limit the buffer size to
> 4MB.
>
> So, fix the code to reflect that, in a way that it will keep
> working with differnt values for PAGE_SIZE.
While your fix is OK, I have a better patch that makes the code a lot more
readable. I'll post that soon.
Regards,
Hans
>
> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
>
> diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c
> index 4dd38578cf1b..66658accdca9 100644
> --- a/drivers/media/pci/tw68/tw68-video.c
> +++ b/drivers/media/pci/tw68/tw68-video.c
> @@ -366,7 +366,7 @@ static int tw68_buffer_pages(int size)
> {
> size = PAGE_ALIGN(size);
> size += PAGE_SIZE; /* for non-page-aligned buffers */
> - size /= 4096;
> + size /= PAGE_SIZE;
> return size;
> }
>
> @@ -376,7 +376,7 @@ static int tw68_buffer_count(unsigned int size, unsigned int count)
> {
> unsigned int maxcount;
>
> - maxcount = 1024 / tw68_buffer_pages(size);
> + maxcount = (4096 * 1024 / PAGE_SIZE) / tw68_buffer_pages(size);
> if (count > maxcount)
> count = maxcount;
> return count;
>
next prev parent reply other threads:[~2014-09-04 16:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-04 14:46 [PATCH 1/3] [media] tw68: make tw68_pci_tbl static and constify Mauro Carvalho Chehab
2014-09-04 14:46 ` [PATCH 2/3] [media] tw68: Remove a sparse warning Mauro Carvalho Chehab
2014-09-04 14:54 ` Hans Verkuil
2014-09-04 15:05 ` Mauro Carvalho Chehab
2014-09-04 16:20 ` Hans Verkuil
2014-09-04 14:46 ` [PATCH 3/3] [media] tw68: don't assume that pagesize is always 4096 Mauro Carvalho Chehab
2014-09-04 14:53 ` Hans Verkuil
2014-09-04 16:21 ` Hans Verkuil [this message]
2014-09-04 14:50 ` [PATCH 1/3] [media] tw68: make tw68_pci_tbl static and constify Hans Verkuil
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=5408918A.2090607@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=hans.verkuil@cisco.com \
--cc=linux-media@vger.kernel.org \
--cc=m.chehab@samsung.com \
--cc=mchehab@infradead.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.