All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [git commit] linux: bump default kernel to version 3.1
From: Peter Korsgaard @ 2011-10-24 15:49 UTC (permalink / raw)
  To: buildroot

commit: http://git.buildroot.net/buildroot/commit/?id=80d7b68167a5c8893e906ace6b5f0b0166336406
branch: http://git.buildroot.net/buildroot/commit/?id=refs/heads/master

Bump default kernel vesion to 3.1 to match headers.
Also implement downloads for 3.x series kernels.

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 linux/Config.in |   10 +++++-----
 linux/linux.mk  |    8 +++++---
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/linux/Config.in b/linux/Config.in
index 5655286..774aaf8 100644
--- a/linux/Config.in
+++ b/linux/Config.in
@@ -19,10 +19,10 @@ if BR2_LINUX_KERNEL
 #
 choice
 	prompt "Kernel version"
-	default BR2_LINUX_KERNEL_2_6_39
+	default BR2_LINUX_KERNEL_3_1
 
-config BR2_LINUX_KERNEL_2_6_39
-	bool "2.6.39.4"
+config BR2_LINUX_KERNEL_3_1
+	bool "3.1"
 
 config BR2_LINUX_KERNEL_SAME_AS_HEADERS
 	bool "Same as toolchain kernel headers"
@@ -58,7 +58,7 @@ endchoice
 config BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE
 	string "Kernel version"
 	depends on BR2_LINUX_KERNEL_CUSTOM_VERSION
-	default "2.6.39.4"
+	default "3.1"
 
 config BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION
 	string "URL of custom kernel tarball"
@@ -74,7 +74,7 @@ config BR2_LINUX_KERNEL_CUSTOM_GIT_VERSION
 
 config BR2_LINUX_KERNEL_VERSION
 	string
-	default "2.6.39.4" if BR2_LINUX_KERNEL_2_6_39
+	default "3.1" if BR2_LINUX_KERNEL_3_1
 	default BR2_DEFAULT_KERNEL_HEADERS if BR2_LINUX_KERNEL_SAME_AS_HEADERS
 	default BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE if BR2_LINUX_KERNEL_CUSTOM_VERSION
 	default "custom" if BR2_LINUX_KERNEL_CUSTOM_TARBALL
diff --git a/linux/linux.mk b/linux/linux.mk
index 99f4649..6b6fd5c 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -18,9 +18,11 @@ LINUX_SOURCE = linux-$(LINUX_VERSION).tar.bz2
 # In X.Y.Z, get X and Y. We replace dots and dashes by spaces in order
 # to use the $(word) function. We support versions such as 3.1,
 # 2.6.32, 2.6.32-rc1, 3.0-rc6, etc.
-LINUX_VERSION_MAJOR = $(word 1,$(subst ., ,$(subst -, ,$(LINUX_VERSION))))
-LINUX_VERSION_MINOR = $(word 2,$(subst ., ,$(subst -, ,$(LINUX_VERSION))))
-LINUX_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v$(LINUX_VERSION_MAJOR).$(LINUX_VERSION_MINOR)/
+ifeq ($(findstring x2.6.,x$(LINUX_VERSION)),x2.6.)
+LINUX_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v2.6/
+else
+LINUX_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v3.x/
+endif
 # release candidates are in testing/ subdir
 ifneq ($(findstring -rc,$(LINUX_VERSION)),)
 LINUX_SITE := $(LINUX_SITE)testing/

^ permalink raw reply related

* Re: Ofono use
From: Jean Parpaillon @ 2011-10-24 15:48 UTC (permalink / raw)
  To: ofono
In-Reply-To: <4EA47705.4050404@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1530 bytes --]

Hi,
Thak you all for your answer.

Le dimanche 23 octobre 2011 à 15:20 -0500, Denis Kenzior a écrit :
> Hi Jean,
> 
> On 10/24/2011 04:44 AM, Jean Parpaillon wrote:
> > Hi all,
> > I am currently trying to use ofono and I can not get how to register the
> > modem in a reliable way.
> > When I detect a modem, I set org.ofono.Modem.Powered to True.
> > When SimManager interface is ready, I enter the pin.
> > Then, I set the modem org.ofono.Modem.Online to True.
> 
> So far so good...
> 
> > By the way, I wait for NetworkRegistration interface to be available.
> > When it is available, I wait for NetworkRegistration.Name to be non
> > empty to call NetworkRegistration.Register.
> > 
> 
> oFono will automatically register unless the Mode property is set to
> 'manual'.  So calling NetworkRegistration.Register is wholly pointless
> if you obtain a NetworkRegistration.Name.  That means you're already
> registered ;)
> 

Noted :)

> > The point is setting Online property usually end with a timeout. It is
> > the right workflow ? Must I look for other property ? 
> 
> What modem are you using?  In general Online should never result in a
> timeout...
> 

I am using a Huawei 1752 USB dongle.
After some time, modem is online, but I sometimes got a timeout. Really
precise, isn't it ? ;)

The really point now is I wanted to make voice calls but it appears that
this modem come with voice call feature disabled by default. Arggg.

> Regards,
> -Denis

Thanks again,
Jean


^ permalink raw reply

* [Buildroot] [git commit] kernel-headers: bump to version 3.0.7 and add version 3.1
From: Peter Korsgaard @ 2011-10-24 15:48 UTC (permalink / raw)
  To: buildroot

commit: http://git.buildroot.net/buildroot/commit/?id=19e022a92f268d924f0c718ec89eb4bde29065ae
branch: http://git.buildroot.net/buildroot/commit/?id=refs/heads/master

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 toolchain/kernel-headers/Config.in                 |    8 ++++++--
 toolchain/kernel-headers/kernel-headers.mk         |    2 +-
 ...all-fix-__packed-in-exported-kernel-head.patch} |    0
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/toolchain/kernel-headers/Config.in b/toolchain/kernel-headers/Config.in
index b827ec5..8be9186 100644
--- a/toolchain/kernel-headers/Config.in
+++ b/toolchain/kernel-headers/Config.in
@@ -6,7 +6,7 @@ comment "Kernel Header Options"
 
 choice
 	prompt "Kernel Headers"
-	default BR2_KERNEL_HEADERS_3_0
+	default BR2_KERNEL_HEADERS_3_1
 	help
 	  Select the version of kernel header files you wish to use.
 	  You must select the correct set of header files to match
@@ -33,6 +33,9 @@ choice
 	config BR2_KERNEL_HEADERS_3_0
 		bool "Linux 3.0.x kernel headers"
 
+	config BR2_KERNEL_HEADERS_3_1
+		bool "Linux 3.1.x kernel headers"
+
 	config BR2_KERNEL_HEADERS_VERSION
 		bool "Linux 2.6 (manually specified version)"
 
@@ -54,6 +57,7 @@ config BR2_DEFAULT_KERNEL_HEADERS
 	default "2.6.37.6"	if BR2_KERNEL_HEADERS_2_6_37
 	default "2.6.38.8"	if BR2_KERNEL_HEADERS_2_6_38
 	default "2.6.39.4"	if BR2_KERNEL_HEADERS_2_6_39
-	default "3.0.4"		if BR2_KERNEL_HEADERS_3_0
+	default "3.0.7"		if BR2_KERNEL_HEADERS_3_0
+	default "3.1"		if BR2_KERNEL_HEADERS_3_1
 	default "2.6"		if BR2_KERNEL_HEADERS_SNAP
 	default $BR2_DEFAULT_KERNEL_VERSION if BR2_KERNEL_HEADERS_VERSION
diff --git a/toolchain/kernel-headers/kernel-headers.mk b/toolchain/kernel-headers/kernel-headers.mk
index 044fcf9..72c6007 100644
--- a/toolchain/kernel-headers/kernel-headers.mk
+++ b/toolchain/kernel-headers/kernel-headers.mk
@@ -29,7 +29,7 @@ LINUX_HEADERS_VERSION:=$(VERSION).$(PATCHLEVEL)$(SUBLEVEL)$(EXTRAVERSION)
 ifeq ($(findstring x2.6.,x$(DEFAULT_KERNEL_HEADERS)),x2.6.)
 LINUX_HEADERS_SITE:=$(BR2_KERNEL_MIRROR)/linux/kernel/v2.6/
 else
-LINUX_HEADERS_SITE:=$(BR2_KERNEL_MIRROR)/linux/kernel/v3.0/
+LINUX_HEADERS_SITE:=$(BR2_KERNEL_MIRROR)/linux/kernel/v3.x/
 endif
 LINUX_HEADERS_SOURCE:=linux-$(LINUX_HEADERS_VERSION).tar.bz2
 LINUX_HEADERS_CAT:=$(BZCAT)
diff --git a/toolchain/kernel-headers/linux-3.0.4-headers_install-fix-__packed-in-exported-kernel-head.patch b/toolchain/kernel-headers/linux-3.0.7-headers_install-fix-__packed-in-exported-kernel-head.patch
similarity index 100%
rename from toolchain/kernel-headers/linux-3.0.4-headers_install-fix-__packed-in-exported-kernel-head.patch
rename to toolchain/kernel-headers/linux-3.0.7-headers_install-fix-__packed-in-exported-kernel-head.patch

^ permalink raw reply related

* Re: [PATCH 05/10] user namespace: clamp down users of cap_raised
From: Andrew G. Morgan @ 2011-10-24 15:47 UTC (permalink / raw)
  To: Serge E. Hallyn
  Cc: David Howells, linux-kernel, ebiederm, akpm, oleg, richard,
	mikevs, segoon, gregkh, eparis, Serge E. Hallyn
In-Reply-To: <20111024144334.GA26603@hallyn.com>

Serge,

It seems as if this whole thing is really idiomatic. How about?

#define IN_ROOT_USER_NS_CAPABLE(cap)  \
   ((current_user_ns() == &init_user_ns) && cap_raised(current_cap(), cap))

Cheers

Andrew

On Mon, Oct 24, 2011 at 7:43 AM, Serge E. Hallyn <serge@hallyn.com> wrote:
> A few modules are using cap_raised(current_cap(), cap) to authorize
> actions.  This means that tasks which are privileged in non-initial
> user namespaces will be deemed privileged.  The privilege should only
> be granted if the task is in the initial user namespace.
>
> Switching the calls to capable() would change the behavior - it would
> cause the LSM capable hooks to be called, and set PF_SUPERPRIV if
> the capability was used.  So instead, put in an explicit check and
> refuse privilege if the caller is not in init_user_ns.
>
> Changelog:
> Oct 23: Use a nice macro to make the code shorter and easier to read,
>        per advice from Andrew Morgan and David Howells.
>
> Signed-off-by: Serge E. Hallyn <serge.hallyn@canonical.com>
> Cc: Eric W. Biederman <ebiederm@xmission.com>
> Cc: Andrew Morgan <morgan@kernel.org>
> Cc: Vasiliy Kulikov <segoon@openwall.com>
> Cc: David Howells <dhowells@redhat.com>
> ---
>  drivers/block/drbd/drbd_nl.c           |    2 +-
>  drivers/md/dm-log-userspace-transfer.c |    2 +-
>  drivers/staging/pohmelfs/config.c      |    2 +-
>  drivers/video/uvesafb.c                |    2 +-
>  include/linux/cred.h                   |    2 ++
>  5 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
> index 0feab26..f799b15 100644
> --- a/drivers/block/drbd/drbd_nl.c
> +++ b/drivers/block/drbd/drbd_nl.c
> @@ -2297,7 +2297,7 @@ static void drbd_connector_callback(struct cn_msg *req, struct netlink_skb_parms
>                return;
>        }
>
> -       if (!cap_raised(current_cap(), CAP_SYS_ADMIN)) {
> +       if (!IN_ROOT_USER_NS() || !cap_raised(current_cap(), CAP_SYS_ADMIN)) {
>                retcode = ERR_PERM;
>                goto fail;
>        }
> diff --git a/drivers/md/dm-log-userspace-transfer.c b/drivers/md/dm-log-userspace-transfer.c
> index 1f23e04..126a79b 100644
> --- a/drivers/md/dm-log-userspace-transfer.c
> +++ b/drivers/md/dm-log-userspace-transfer.c
> @@ -134,7 +134,7 @@ static void cn_ulog_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp)
>  {
>        struct dm_ulog_request *tfr = (struct dm_ulog_request *)(msg + 1);
>
> -       if (!cap_raised(current_cap(), CAP_SYS_ADMIN))
> +       if (!IN_ROOT_USER_NS() || !cap_raised(current_cap(), CAP_SYS_ADMIN))
>                return;
>
>        spin_lock(&receiving_list_lock);
> diff --git a/drivers/staging/pohmelfs/config.c b/drivers/staging/pohmelfs/config.c
> index b6c42cb..327c047 100644
> --- a/drivers/staging/pohmelfs/config.c
> +++ b/drivers/staging/pohmelfs/config.c
> @@ -525,7 +525,7 @@ static void pohmelfs_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *n
>  {
>        int err;
>
> -       if (!cap_raised(current_cap(), CAP_SYS_ADMIN))
> +       if (!IN_ROOT_USER_NS() || !cap_raised(current_cap(), CAP_SYS_ADMIN))
>                return;
>
>        switch (msg->flags) {
> diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
> index 7f8472c..94e0e9d 100644
> --- a/drivers/video/uvesafb.c
> +++ b/drivers/video/uvesafb.c
> @@ -73,7 +73,7 @@ static void uvesafb_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *ns
>        struct uvesafb_task *utask;
>        struct uvesafb_ktask *task;
>
> -       if (!cap_raised(current_cap(), CAP_SYS_ADMIN))
> +       if (!IN_ROOT_USER_NS() || !cap_raised(current_cap(), CAP_SYS_ADMIN))
>                return;
>
>        if (msg->seq >= UVESAFB_TASKS_MAX)
> diff --git a/include/linux/cred.h b/include/linux/cred.h
> index 4030896..2f75da7 100644
> --- a/include/linux/cred.h
> +++ b/include/linux/cred.h
> @@ -359,9 +359,11 @@ static inline void put_cred(const struct cred *_cred)
>
>  #ifdef CONFIG_USER_NS
>  #define current_user_ns() (current_cred_xxx(user_ns))
> +#define IN_ROOT_USER_NS() (current_user_ns() == &init_user_ns)
>  #else
>  extern struct user_namespace init_user_ns;
>  #define current_user_ns() (&init_user_ns)
> +#define IN_ROOT_USER_NS() (1)
>  #endif
>
>
> --
> 1.7.5.4
>
>

^ permalink raw reply

* Re: [Qemu-devel] [PATCH 1/5] monitor: screen_dump async
From: Luiz Capitulino @ 2011-10-24 15:45 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: mdroth, mlureau, Alon Levy, armbru, qemu-devel
In-Reply-To: <4EA5808A.7050409@redhat.com>

On Mon, 24 Oct 2011 17:13:14 +0200
Gerd Hoffmann <kraxel@redhat.com> wrote:

> On 10/24/11 14:02, Alon Levy wrote:
> > Make screen_dump monitor command an async command to allow next for qxl
> > to implement it as a initiating call to red_worker and completion on
> > callback, to fix a deadlock when issueing a screendump command via
> > libvirt while connected with a libvirt controlled spice-gtk client.
> 
> Approach looks reasonable to me.  Patch breaks the build though, you've
> missed a bunch of screen_dump functions in non-x86 targets.

There are two problems actually.

The first one is that changing an existing command from synchronous
to asynchronous is an incompatible change because asynchronous commands
semantics is different. For an example of possible problems please
check: https://bugzilla.redhat.com/show_bug.cgi?id=623903.

The second problem is that the existing asynchronous interface in the
monitor is incomplete and has never been used for real. Our plan is to
use QAPI's async support, but that has not landed in master yet and iirc
there wasn't consensus about it. I also think it's a bit late for its
inclusion in 1.0 (and certainly not a candidate for stable).

If all you need here is to delay sending the response, then maybe the
current interface could work (although I honestly don't trust it and
regret not having dropped it). Otherwise our only choice would be to
work on getting the QAPI async support merged.

^ permalink raw reply

* Re: [PATCH 1/2] writeback: Improve busyloop prevention
From: Jan Kara @ 2011-10-24 15:45 UTC (permalink / raw)
  To: Wu Fengguang
  Cc: Jan Kara, linux-fsdevel@vger.kernel.org, Christoph Hellwig,
	Dave Chinner
In-Reply-To: <20111022042019.GA10287@localhost>

On Sat 22-10-11 12:20:19, Wu Fengguang wrote:
> On Fri, Oct 21, 2011 at 06:26:16AM +0800, Jan Kara wrote:
> > On Thu 20-10-11 21:39:38, Wu Fengguang wrote:
> > > On Thu, Oct 20, 2011 at 08:33:00PM +0800, Wu Fengguang wrote:
> > > > On Thu, Oct 20, 2011 at 08:09:09PM +0800, Wu Fengguang wrote:
> > > > > Jan,
> > > > > 
> > > > > I tried the below combined patch over the ioless one, and find some
> > > > > minor regressions. I studied the thresh=1G/ext3-1dd case in particular
> > > > > and find that nr_writeback and the iostat avgrq-sz drops from time to time.
> > > > > 
> > > > > I'll try to bisect the changeset.
> > > 
> > > This is interesting, the culprit is found to be patch 1, which is
> > > simply
> > >                 if (work->for_kupdate) {
> > >                         oldest_jif = jiffies -
> > >                                 msecs_to_jiffies(dirty_expire_interval * 10);
> > > -                       work->older_than_this = &oldest_jif;
> > > -               }
> > > +               } else if (work->for_background)
> > > +                       oldest_jif = jiffies;
> >   Yeah. I had a look into the trace and you can notice that during the
> > whole dd run, we were running a single background writeback work (you can
> > verify that by work->nr_pages decreasing steadily).
> 
> Yes, it is.
> 
> > Without refreshing
> > oldest_jif, we'd write block device inode for /dev/sda (you can identify
> > that by bdi=8:0, ino=0) only once. When refreshing oldest_jif, we write it
> > every 5 seconds (kjournald dirties the device inode after committing a
> > transaction by dirtying metadata buffers which were just committed and can
> > now be checkpointed either by kjournald or flusher thread).
> 
> OK, now I understand the regular drops of nr_writeback and avgrq-sz:
> on every 5s, it takes _some time_ to write inode 0, during which the
> flusher is blocked and the IO queue runs low.
> 
> > So although the performance is slightly reduced, I'd say that the
> > behavior is a desired one.
> 
> OK. However it's sad to see the flusher get blocked from time to time...
  Well, it doesn't get blocked. It just has to write out inode which cannot
be written out so efficiently. But that's nothing we can really solve...

> > Also if you observed the performance on a really long run, the difference
> > should get smaller because eventually, kjournald has to flush the metadata
> > blocks when the journal fills up and we need to free some journal space and
> > at that point flushing is even more expensive because we have to do a
> > blocking write during which all transaction operations, thus effectively
> > the whole filesystem, are blocked.
> 
> OK. The dd test time was 300s, I'll increase it to 900s (cannot do
> more because it's a 90GB disk partition).
  Yes, that might be an interesting try...

								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply

* Re: [RFC 3/4] lib: devres: add convenience function to remap a resource
From: Tejun Heo @ 2011-10-24 15:44 UTC (permalink / raw)
  To: Grant Likely; +Cc: Wolfram Sang, linux-kernel, linux-arm-kernel, Greg KH
In-Reply-To: <20111024115612.GL8708@ponder.secretlab.ca>

Hello, Grant.

On Mon, Oct 24, 2011 at 01:56:12PM +0200, Grant Likely wrote:
> > +/**
> > + * devm_resource_to_mapped_ptr - Check, request region, and ioremap resource
> 
> Kernel doc format should have '()' for functions is:

Simple Grepping gives me an order of magnitude more on the ones w/o
'()'.  Maybe it's better to change the rule at this point?

Thanks.

-- 
tejun

^ permalink raw reply

* [RFC 3/4] lib: devres: add convenience function to remap a resource
From: Tejun Heo @ 2011-10-24 15:44 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20111024115612.GL8708@ponder.secretlab.ca>

Hello, Grant.

On Mon, Oct 24, 2011 at 01:56:12PM +0200, Grant Likely wrote:
> > +/**
> > + * devm_resource_to_mapped_ptr - Check, request region, and ioremap resource
> 
> Kernel doc format should have '()' for functions is:

Simple Grepping gives me an order of magnitude more on the ones w/o
'()'.  Maybe it's better to change the rule at this point?

Thanks.

-- 
tejun

^ permalink raw reply

* Re: Eclipse Plugin: ADT Version too old
From: Jack Mitchell @ 2011-10-24 15:44 UTC (permalink / raw)
  To: Zhang, Jessica; +Cc: yocto@yoctoproject.org
In-Reply-To: <C6510F6D410BB64A8C15398EDC6B847C16E996E5@ORSMSX101.amr.corp.intel.com>

On 24/10/2011 16:42, Zhang, Jessica wrote:
> Hi Jack,
>
> So you mean you did "bitbake meta-ide-support" to use the build tree?
>
> I just tried with my Edison build tree mode on my laptop and it works fine. So can you check under your build/tmp directory, there should be an environment-setup-*-poky-linux file, where * is your target arch.  At the end file do you have several OECORE_* settings ? If not, you need to rerun "bitbake meta-ide-support" and ensure there're OECORE_* settings at the end.
>
> Thanks,
> Jessica
>
> -----Original Message-----
> From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Jack Mitchell
> Sent: Monday, October 24, 2011 2:24 AM
> To: yocto@yoctoproject.org
> Subject: Re: [yocto] Eclipse Plugin: ADT Version too old
>
> On 24/10/2011 10:18, Lu, Lianhao wrote:
>> Jack Mitchell wrote on 2011-10-24:
>>> I am trying to use the new eclipse plugin, which I have had working
>>> fine for the past couple of weeks until I switched from the master branch to edison.
>>>
>>> I performed a fresh build using the stable edison branch, installed
>>> the new 1.1 eclipse plugin and now whenever I try to setup the Yocto
>>> eclipse environment I receive the following error:
>>>
>>> Yocto Preferences Configuration Error!
>>> OECORE related items are not found in envrionement setup files.
>>> The ADT version you're using is too old.
>>> Please upgrade to our latest ADT Version!
>>>
>>> This pops up in a message box, not the eclipse console. I have
>>> followed the ADT Setup guide to the letter and it's not playing ball -
>>> could someone confirm this as working or point me towards a reason why I may be getting this error?
>>>
>> Hi Jack,
>>
>> How did you install your ADT? You can check the ADT version by "cat" the file /opt/poky/${version}/version-xxxx, where xxxx is your target sys architecture.
>>
>> -Lianhao
>> _______________________________________________
>> yocto mailing list
>> yocto@yoctoproject.org
>> https://lists.yoctoproject.org/listinfo/yocto
> Hi Lianhao,
>
> I am using the yocto build tree so I don't have an installed ADT in /opt
> but one that has been generated within my build directory, this is
> correct yes?
>
> Jack.
> _______________________________________________
> yocto mailing list
> yocto@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto

Hi Jessica,

I posted my environment settings earlier, which are located here: 
http://pastebin.com/4vnWPAD2

Yes, I did use bitbake meta-ide-support to build my root.


^ permalink raw reply

* Re: [RFC 3/4] lib: devres: add convenience function to remap a resource
From: Tejun Heo @ 2011-10-24 15:43 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-kernel, linux-arm-kernel, Greg KH, Grant Likely
In-Reply-To: <1319445729-14841-4-git-send-email-w.sang@pengutronix.de>

Hello,

On Mon, Oct 24, 2011 at 10:42:08AM +0200, Wolfram Sang wrote:
> * the new function is not named 'devm_ioremap_resource' because it does more than
>   just ioremap, namely request_mem_region. I didn't want to create implicit
>   knowledge here.

Maybe devm_request_and_ioremap_resource()?  Maybe it's a bit long but
A_to_B names are usually used for trivial conversions.

> +int __must_check devm_resource_to_mapped_ptr(struct device *dev,
> +			struct resource *res, void __iomem **dest)

If we're already printing out dev_err(), I think we can live with
%NULL return on error.

> +{
> +	resource_size_t size;
> +	const char *name;
> +
> +	BUG_ON(!dev || !dest);
> +
> +	*dest = NULL;
> +
> +	if (!res || resource_type(res) != IORESOURCE_MEM) {
> +		dev_err(dev, "invalid resource\n");
> +		return -ENOENT;
> +	}
> +
> +	size = resource_size(res);
> +	name = res->name ?: dev_name(dev);
> +
> +	if (!devm_request_mem_region(dev, res->start, size, name)) {
> +		dev_err(dev, "can't request region for resource %pR\n", res);
> +		return -EBUSY;
> +	}
> +
> +	if (res->flags & IORESOURCE_CACHEABLE)
> +		*dest = devm_ioremap(dev, res->start, size);
> +	else
> +		*dest = devm_ioremap_nocache(dev, res->start, size);
> +
> +	if (!*dest) {
> +		dev_err(dev, "ioremap failed for resource %pR\n", res);
> +		return -ENOMEM;
> +	}

So, for library functions, it's nice if the function doesn't hold any
extra resource on error return.  devres has grouping to support this.
You just need to wrap allocations inside a group and remove it on
success and release on error.  ie.

	if (!devres_open_group(dev, NULL, GFP_KERNEL))
		return NULL;
	if (alloc_resource(0) < 0)
		goto fail;
	if (alloc_resource(1) < 0)
		goto fail;
	devres_remove_group(dev, NULL);
	return 0;
fail:
	devres_release_group(dev, NULL);
	return 0;

Thanks.

-- 
tejun

^ permalink raw reply

* [RFC 3/4] lib: devres: add convenience function to remap a resource
From: Tejun Heo @ 2011-10-24 15:43 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1319445729-14841-4-git-send-email-w.sang@pengutronix.de>

Hello,

On Mon, Oct 24, 2011 at 10:42:08AM +0200, Wolfram Sang wrote:
> * the new function is not named 'devm_ioremap_resource' because it does more than
>   just ioremap, namely request_mem_region. I didn't want to create implicit
>   knowledge here.

Maybe devm_request_and_ioremap_resource()?  Maybe it's a bit long but
A_to_B names are usually used for trivial conversions.

> +int __must_check devm_resource_to_mapped_ptr(struct device *dev,
> +			struct resource *res, void __iomem **dest)

If we're already printing out dev_err(), I think we can live with
%NULL return on error.

> +{
> +	resource_size_t size;
> +	const char *name;
> +
> +	BUG_ON(!dev || !dest);
> +
> +	*dest = NULL;
> +
> +	if (!res || resource_type(res) != IORESOURCE_MEM) {
> +		dev_err(dev, "invalid resource\n");
> +		return -ENOENT;
> +	}
> +
> +	size = resource_size(res);
> +	name = res->name ?: dev_name(dev);
> +
> +	if (!devm_request_mem_region(dev, res->start, size, name)) {
> +		dev_err(dev, "can't request region for resource %pR\n", res);
> +		return -EBUSY;
> +	}
> +
> +	if (res->flags & IORESOURCE_CACHEABLE)
> +		*dest = devm_ioremap(dev, res->start, size);
> +	else
> +		*dest = devm_ioremap_nocache(dev, res->start, size);
> +
> +	if (!*dest) {
> +		dev_err(dev, "ioremap failed for resource %pR\n", res);
> +		return -ENOMEM;
> +	}

So, for library functions, it's nice if the function doesn't hold any
extra resource on error return.  devres has grouping to support this.
You just need to wrap allocations inside a group and remove it on
success and release on error.  ie.

	if (!devres_open_group(dev, NULL, GFP_KERNEL))
		return NULL;
	if (alloc_resource(0) < 0)
		goto fail;
	if (alloc_resource(1) < 0)
		goto fail;
	devres_remove_group(dev, NULL);
	return 0;
fail:
	devres_release_group(dev, NULL);
	return 0;

Thanks.

-- 
tejun

^ permalink raw reply

* Re: Eclipse Plugin: ADT Version too old
From: Zhang, Jessica @ 2011-10-24 15:42 UTC (permalink / raw)
  To: Jack Mitchell, yocto@yoctoproject.org
In-Reply-To: <4EA52E9F.9070001@communistcode.co.uk>

Hi Jack,

So you mean you did "bitbake meta-ide-support" to use the build tree?

I just tried with my Edison build tree mode on my laptop and it works fine. So can you check under your build/tmp directory, there should be an environment-setup-*-poky-linux file, where * is your target arch.  At the end file do you have several OECORE_* settings ? If not, you need to rerun "bitbake meta-ide-support" and ensure there're OECORE_* settings at the end.

Thanks,
Jessica

-----Original Message-----
From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Jack Mitchell
Sent: Monday, October 24, 2011 2:24 AM
To: yocto@yoctoproject.org
Subject: Re: [yocto] Eclipse Plugin: ADT Version too old

On 24/10/2011 10:18, Lu, Lianhao wrote:
> Jack Mitchell wrote on 2011-10-24:
>> I am trying to use the new eclipse plugin, which I have had working
>> fine for the past couple of weeks until I switched from the master branch to edison.
>>
>> I performed a fresh build using the stable edison branch, installed
>> the new 1.1 eclipse plugin and now whenever I try to setup the Yocto
>> eclipse environment I receive the following error:
>>
>> Yocto Preferences Configuration Error!
>> OECORE related items are not found in envrionement setup files.
>> The ADT version you're using is too old.
>> Please upgrade to our latest ADT Version!
>>
>> This pops up in a message box, not the eclipse console. I have
>> followed the ADT Setup guide to the letter and it's not playing ball -
>> could someone confirm this as working or point me towards a reason why I may be getting this error?
>>
> Hi Jack,
>
> How did you install your ADT? You can check the ADT version by "cat" the file /opt/poky/${version}/version-xxxx, where xxxx is your target sys architecture.
>
> -Lianhao
> _______________________________________________
> yocto mailing list
> yocto@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto

Hi Lianhao,

I am using the yocto build tree so I don't have an installed ADT in /opt
but one that has been generated within my build directory, this is
correct yes?

Jack.
_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


^ permalink raw reply

* Re: Eclipse Plugin: ADT Version too old
From: Jack Mitchell @ 2011-10-24 15:41 UTC (permalink / raw)
  To: yocto
In-Reply-To: <4EA58560.5060905@linux.intel.com>

On 24/10/2011 16:33, Joshua Lock wrote:
>
> On 24/10/11 02:12, Jack Mitchell wrote:
>> On 24/10/2011 10:03, Jack Mitchell wrote:
>>> I am trying to use the new eclipse plugin, which I have had working
>>> fine for the past couple of weeks until I switched from the master
>>> branch to edison.
>>>
>>> I performed a fresh build using the stable edison branch, installed
>>> the new 1.1 eclipse plugin and now whenever I try to setup the Yocto
>>> eclipse environment I receive the following error:
>>>
>>> Yocto Preferences Configuration Error!
>>> OECORE related items are not found in envrionement setup files.
>>> The ADT version you're using is too old.
>>> Please upgrade to our latest ADT Version!
>>>
>>> This pops up in a message box, not the eclipse console. I have
>>> followed the ADT Setup guide to the letter and it's not playing ball -
>>> could someone confirm this as working or point me towards a reason why
>>> I may be getting this error?
>>>
>>> Cheers,
>>> Jack.
>>>
>>>
>>> _______________________________________________
>>> yocto mailing list
>>> yocto@yoctoproject.org
>>> https://lists.yoctoproject.org/listinfo/yocto
>> This is a pastebin of my current environment setup file:
>>
>> http://pastebin.com/4vnWPAD2
>>
> I'm not ADT expert but I expect the problem is this line:
>
> export OECORE_DISTRO_VERSION="1.1+snapshot-20111021"
>
> By switching to the edison branch you'll now have a DISTRO_VERSION of
> "1.1", without the snapshot and date - hence version mismatch.
>
> I'm not sure if you need to change the plugin or just build a new
> meta-ide-support, though.
>
> Cheers,
> Joshua

Ah, that makes sense Joshua. However, this is a fresh build directory 
created after I had checked out the edison tag, so due to me checking 
out a git 'tag' I have the snapshot tag version listed instead of the 
1.1 clean download version?

So all the things I built were built while on an edision checkout which 
means I shouldn't have old git versions lingering about.

Cheers,
Jack.


^ permalink raw reply

* [PATCH 2/2] uvcvideo: Use videobuf2-vmalloc
From: Laurent Pinchart @ 2011-10-24 15:42 UTC (permalink / raw)
  To: linux-media
In-Reply-To: <1319470924-15703-1-git-send-email-laurent.pinchart@ideasonboard.com>

Replace the current video buffers queue implementation with
videobuf2-vmalloc.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/video/uvc/Kconfig     |    1 +
 drivers/media/video/uvc/uvc_queue.c |  556 +++++++++--------------------------
 drivers/media/video/uvc/uvc_v4l2.c  |   19 +-
 drivers/media/video/uvc/uvc_video.c |    9 +-
 drivers/media/video/uvc/uvcvideo.h  |   33 +--
 5 files changed, 161 insertions(+), 457 deletions(-)

diff --git a/drivers/media/video/uvc/Kconfig b/drivers/media/video/uvc/Kconfig
index 2956a76..6c197da 100644
--- a/drivers/media/video/uvc/Kconfig
+++ b/drivers/media/video/uvc/Kconfig
@@ -1,5 +1,6 @@
 config USB_VIDEO_CLASS
 	tristate "USB Video Class (UVC)"
+	select VIDEOBUF2_VMALLOC
 	---help---
 	  Support for the USB Video Class (UVC).  Currently only video
 	  input devices, such as webcams, are supported.
diff --git a/drivers/media/video/uvc/uvc_queue.c b/drivers/media/video/uvc/uvc_queue.c
index 0fbb04b..a5122a1 100644
--- a/drivers/media/video/uvc/uvc_queue.c
+++ b/drivers/media/video/uvc/uvc_queue.c
@@ -11,6 +11,7 @@
  *
  */
 
+#include <linux/atomic.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/list.h>
@@ -19,7 +20,7 @@
 #include <linux/videodev2.h>
 #include <linux/vmalloc.h>
 #include <linux/wait.h>
-#include <linux/atomic.h>
+#include <media/videobuf2-vmalloc.h>
 
 #include "uvcvideo.h"
 
@@ -29,470 +30,199 @@
  * Video queues is initialized by uvc_queue_init(). The function performs
  * basic initialization of the uvc_video_queue struct and never fails.
  *
- * Video buffer allocation and freeing are performed by uvc_alloc_buffers and
- * uvc_free_buffers respectively. The former acquires the video queue lock,
- * while the later must be called with the lock held (so that allocation can
- * free previously allocated buffers). Trying to free buffers that are mapped
- * to user space will return -EBUSY.
- *
- * Video buffers are managed using two queues. However, unlike most USB video
- * drivers that use an in queue and an out queue, we use a main queue to hold
- * all queued buffers (both 'empty' and 'done' buffers), and an irq queue to
- * hold empty buffers. This design (copied from video-buf) minimizes locking
- * in interrupt, as only one queue is shared between interrupt and user
- * contexts.
- *
- * Use cases
- * ---------
- *
- * Unless stated otherwise, all operations that modify the irq buffers queue
- * are protected by the irq spinlock.
- *
- * 1. The user queues the buffers, starts streaming and dequeues a buffer.
- *
- *    The buffers are added to the main and irq queues. Both operations are
- *    protected by the queue lock, and the later is protected by the irq
- *    spinlock as well.
- *
- *    The completion handler fetches a buffer from the irq queue and fills it
- *    with video data. If no buffer is available (irq queue empty), the handler
- *    returns immediately.
- *
- *    When the buffer is full, the completion handler removes it from the irq
- *    queue, marks it as done (UVC_BUF_STATE_DONE) and wakes its wait queue.
- *    At that point, any process waiting on the buffer will be woken up. If a
- *    process tries to dequeue a buffer after it has been marked done, the
- *    dequeing will succeed immediately.
- *
- * 2. Buffers are queued, user is waiting on a buffer and the device gets
- *    disconnected.
- *
- *    When the device is disconnected, the kernel calls the completion handler
- *    with an appropriate status code. The handler marks all buffers in the
- *    irq queue as being erroneous (UVC_BUF_STATE_ERROR) and wakes them up so
- *    that any process waiting on a buffer gets woken up.
- *
- *    Waking up up the first buffer on the irq list is not enough, as the
- *    process waiting on the buffer might restart the dequeue operation
- *    immediately.
- *
+ * Video buffers are managed by videobuf2. The driver uses a mutex to protect
+ * the videobuf2 queue operations by serializing calls to videobuf2 and a
+ * spinlock to protect the IRQ queue that holds the buffers to be processed by
+ * the driver.
  */
 
-void uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
-		    int drop_corrupted)
-{
-	mutex_init(&queue->mutex);
-	spin_lock_init(&queue->irqlock);
-	INIT_LIST_HEAD(&queue->mainqueue);
-	INIT_LIST_HEAD(&queue->irqqueue);
-	queue->flags = drop_corrupted ? UVC_QUEUE_DROP_CORRUPTED : 0;
-	queue->type = type;
-}
-
-/*
- * Free the video buffers.
- *
- * This function must be called with the queue lock held.
+/* -----------------------------------------------------------------------------
+ * videobuf2 queue operations
  */
-static int __uvc_free_buffers(struct uvc_video_queue *queue)
+
+static int uvc_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,
+			   unsigned int *nplanes, unsigned int sizes[],
+			   void *alloc_ctxs[])
 {
-	unsigned int i;
+	struct uvc_video_queue *queue = vb2_get_drv_priv(vq);
+	struct uvc_streaming *stream =
+			container_of(queue, struct uvc_streaming, queue);
 
-	for (i = 0; i < queue->count; ++i) {
-		if (queue->buffer[i].vma_use_count != 0)
-			return -EBUSY;
-	}
+	if (*nbuffers > UVC_MAX_VIDEO_BUFFERS)
+		*nbuffers = UVC_MAX_VIDEO_BUFFERS;
 
-	if (queue->count) {
-		uvc_queue_cancel(queue, 0);
-		INIT_LIST_HEAD(&queue->mainqueue);
-		vfree(queue->mem);
-		queue->count = 0;
-	}
+	*nplanes = 1;
+
+	sizes[0] = stream->ctrl.dwMaxVideoFrameSize;
 
 	return 0;
 }
 
-int uvc_free_buffers(struct uvc_video_queue *queue)
+static int uvc_buffer_prepare(struct vb2_buffer *vb)
 {
-	int ret;
-
-	mutex_lock(&queue->mutex);
-	ret = __uvc_free_buffers(queue);
-	mutex_unlock(&queue->mutex);
-
-	return ret;
-}
+	struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue);
+	struct uvc_buffer *buf = container_of(vb, struct uvc_buffer, buf);
 
-/*
- * Allocate the video buffers.
- *
- * Pages are reserved to make sure they will not be swapped, as they will be
- * filled in the URB completion handler.
- *
- * Buffers will be individually mapped, so they must all be page aligned.
- */
-int uvc_alloc_buffers(struct uvc_video_queue *queue, unsigned int nbuffers,
-		unsigned int buflength)
-{
-	unsigned int bufsize = PAGE_ALIGN(buflength);
-	unsigned int i;
-	void *mem = NULL;
-	int ret;
+	if (vb->v4l2_buf.type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
+	    vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) {
+		uvc_trace(UVC_TRACE_CAPTURE, "[E] Bytes used out of bounds.\n");
+		return -EINVAL;
+	}
 
-	if (nbuffers > UVC_MAX_VIDEO_BUFFERS)
-		nbuffers = UVC_MAX_VIDEO_BUFFERS;
+	if (unlikely(queue->flags & UVC_QUEUE_DISCONNECTED))
+		return -ENODEV;
 
-	mutex_lock(&queue->mutex);
+	buf->state = UVC_BUF_STATE_QUEUED;
+	buf->error = 0;
+	buf->mem = vb2_plane_vaddr(vb, 0);
+	buf->length = vb2_plane_size(vb, 0);
+	if (vb->v4l2_buf.type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		buf->bytesused = 0;
+	else
+		buf->bytesused = vb2_get_plane_payload(vb, 0);
 
-	if ((ret = __uvc_free_buffers(queue)) < 0)
-		goto done;
+	return 0;
+}
 
-	/* Bail out if no buffers should be allocated. */
-	if (nbuffers == 0)
-		goto done;
+static void uvc_buffer_queue(struct vb2_buffer *vb)
+{
+	struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue);
+	struct uvc_buffer *buf = container_of(vb, struct uvc_buffer, buf);
+	unsigned long flags;
 
-	/* Decrement the number of buffers until allocation succeeds. */
-	for (; nbuffers > 0; --nbuffers) {
-		mem = vmalloc_32(nbuffers * bufsize);
-		if (mem != NULL)
-			break;
+	spin_lock_irqsave(&queue->irqlock, flags);
+	if (likely(!(queue->flags & UVC_QUEUE_DISCONNECTED))) {
+		list_add_tail(&buf->queue, &queue->irqqueue);
+	} else {
+		/* If the device is disconnected return the buffer to userspace
+		 * directly. The next QBUF call will fail with -ENODEV.
+		 */
+		buf->state = UVC_BUF_STATE_ERROR;
+		vb2_buffer_done(&buf->buf, VB2_BUF_STATE_ERROR);
 	}
 
-	if (mem == NULL) {
-		ret = -ENOMEM;
-		goto done;
-	}
+	spin_unlock_irqrestore(&queue->irqlock, flags);
+}
 
-	for (i = 0; i < nbuffers; ++i) {
-		memset(&queue->buffer[i], 0, sizeof queue->buffer[i]);
-		queue->buffer[i].buf.index = i;
-		queue->buffer[i].buf.m.offset = i * bufsize;
-		queue->buffer[i].buf.length = buflength;
-		queue->buffer[i].buf.type = queue->type;
-		queue->buffer[i].buf.field = V4L2_FIELD_NONE;
-		queue->buffer[i].buf.memory = V4L2_MEMORY_MMAP;
-		queue->buffer[i].buf.flags = 0;
-
-		queue->buffer[i].mem = queue->mem + i * bufsize;
-		queue->buffer[i].length = buflength;
-		init_waitqueue_head(&queue->buffer[i].wait);
-	}
+static struct vb2_ops uvc_queue_qops = {
+	.queue_setup = uvc_queue_setup,
+	.buf_prepare = uvc_buffer_prepare,
+	.buf_queue = uvc_buffer_queue,
+};
 
-	queue->mem = mem;
-	queue->count = nbuffers;
-	queue->buf_size = bufsize;
-	ret = nbuffers;
+void uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
+		    int drop_corrupted)
+{
+	queue->queue.type = type;
+	queue->queue.io_modes = VB2_MMAP;
+	queue->queue.drv_priv = queue;
+	queue->queue.buf_struct_size = sizeof(struct uvc_buffer);
+	queue->queue.ops = &uvc_queue_qops;
+	queue->queue.mem_ops = &vb2_vmalloc_memops;
+	vb2_queue_init(&queue->queue);
 
-done:
-	mutex_unlock(&queue->mutex);
-	return ret;
+	mutex_init(&queue->mutex);
+	spin_lock_init(&queue->irqlock);
+	INIT_LIST_HEAD(&queue->irqqueue);
+	queue->flags = drop_corrupted ? UVC_QUEUE_DROP_CORRUPTED : 0;
 }
 
-/*
- * Check if buffers have been allocated.
+/* -----------------------------------------------------------------------------
+ * V4L2 queue operations
  */
-int uvc_queue_allocated(struct uvc_video_queue *queue)
+
+int uvc_alloc_buffers(struct uvc_video_queue *queue,
+		struct v4l2_requestbuffers *rb, unsigned int buflength)
 {
-	int allocated;
+	int ret;
 
 	mutex_lock(&queue->mutex);
-	allocated = queue->count != 0;
+	ret = vb2_reqbufs(&queue->queue, rb);
 	mutex_unlock(&queue->mutex);
 
-	return allocated;
+	return ret ? ret : rb->count;
 }
 
-static void __uvc_query_buffer(struct uvc_buffer *buf,
-		struct v4l2_buffer *v4l2_buf)
+void uvc_free_buffers(struct uvc_video_queue *queue)
 {
-	memcpy(v4l2_buf, &buf->buf, sizeof *v4l2_buf);
-
-	if (buf->vma_use_count)
-		v4l2_buf->flags |= V4L2_BUF_FLAG_MAPPED;
-
-	switch (buf->state) {
-	case UVC_BUF_STATE_ERROR:
-	case UVC_BUF_STATE_DONE:
-		v4l2_buf->flags |= V4L2_BUF_FLAG_DONE;
-		break;
-	case UVC_BUF_STATE_QUEUED:
-	case UVC_BUF_STATE_ACTIVE:
-	case UVC_BUF_STATE_READY:
-		v4l2_buf->flags |= V4L2_BUF_FLAG_QUEUED;
-		break;
-	case UVC_BUF_STATE_IDLE:
-	default:
-		break;
-	}
+	mutex_lock(&queue->mutex);
+	vb2_queue_release(&queue->queue);
+	mutex_unlock(&queue->mutex);
 }
 
-int uvc_query_buffer(struct uvc_video_queue *queue,
-		struct v4l2_buffer *v4l2_buf)
+int uvc_query_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf)
 {
-	int ret = 0;
+	int ret;
 
 	mutex_lock(&queue->mutex);
-	if (v4l2_buf->index >= queue->count) {
-		ret = -EINVAL;
-		goto done;
-	}
-
-	__uvc_query_buffer(&queue->buffer[v4l2_buf->index], v4l2_buf);
-
-done:
+	ret = vb2_querybuf(&queue->queue, buf);
 	mutex_unlock(&queue->mutex);
+
 	return ret;
 }
 
-/*
- * Queue a video buffer. Attempting to queue a buffer that has already been
- * queued will return -EINVAL.
- */
-int uvc_queue_buffer(struct uvc_video_queue *queue,
-	struct v4l2_buffer *v4l2_buf)
+int uvc_queue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf)
 {
-	struct uvc_buffer *buf;
-	unsigned long flags;
-	int ret = 0;
-
-	uvc_trace(UVC_TRACE_CAPTURE, "Queuing buffer %u.\n", v4l2_buf->index);
-
-	if (v4l2_buf->type != queue->type ||
-	    v4l2_buf->memory != V4L2_MEMORY_MMAP) {
-		uvc_trace(UVC_TRACE_CAPTURE, "[E] Invalid buffer type (%u) "
-			"and/or memory (%u).\n", v4l2_buf->type,
-			v4l2_buf->memory);
-		return -EINVAL;
-	}
+	int ret;
 
 	mutex_lock(&queue->mutex);
-	if (v4l2_buf->index >= queue->count) {
-		uvc_trace(UVC_TRACE_CAPTURE, "[E] Out of range index.\n");
-		ret = -EINVAL;
-		goto done;
-	}
-
-	buf = &queue->buffer[v4l2_buf->index];
-	if (buf->state != UVC_BUF_STATE_IDLE) {
-		uvc_trace(UVC_TRACE_CAPTURE, "[E] Invalid buffer state "
-			"(%u).\n", buf->state);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	if (v4l2_buf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
-	    v4l2_buf->bytesused > buf->buf.length) {
-		uvc_trace(UVC_TRACE_CAPTURE, "[E] Bytes used out of bounds.\n");
-		ret = -EINVAL;
-		goto done;
-	}
-
-	spin_lock_irqsave(&queue->irqlock, flags);
-	if (queue->flags & UVC_QUEUE_DISCONNECTED) {
-		spin_unlock_irqrestore(&queue->irqlock, flags);
-		ret = -ENODEV;
-		goto done;
-	}
-	buf->state = UVC_BUF_STATE_QUEUED;
-	if (v4l2_buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
-		buf->bytesused = 0;
-	else
-		buf->bytesused = v4l2_buf->bytesused;
-
-	list_add_tail(&buf->stream, &queue->mainqueue);
-	list_add_tail(&buf->queue, &queue->irqqueue);
-	spin_unlock_irqrestore(&queue->irqlock, flags);
-
-done:
+	ret = vb2_qbuf(&queue->queue, buf);
 	mutex_unlock(&queue->mutex);
-	return ret;
-}
 
-static int uvc_queue_waiton(struct uvc_buffer *buf, int nonblocking)
-{
-	if (nonblocking) {
-		return (buf->state != UVC_BUF_STATE_QUEUED &&
-			buf->state != UVC_BUF_STATE_ACTIVE &&
-			buf->state != UVC_BUF_STATE_READY)
-			? 0 : -EAGAIN;
-	}
-
-	return wait_event_interruptible(buf->wait,
-		buf->state != UVC_BUF_STATE_QUEUED &&
-		buf->state != UVC_BUF_STATE_ACTIVE &&
-		buf->state != UVC_BUF_STATE_READY);
+	return ret;
 }
 
-/*
- * Dequeue a video buffer. If nonblocking is false, block until a buffer is
- * available.
- */
-int uvc_dequeue_buffer(struct uvc_video_queue *queue,
-		struct v4l2_buffer *v4l2_buf, int nonblocking)
+int uvc_dequeue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf,
+		       int nonblocking)
 {
-	struct uvc_buffer *buf;
-	int ret = 0;
-
-	if (v4l2_buf->type != queue->type ||
-	    v4l2_buf->memory != V4L2_MEMORY_MMAP) {
-		uvc_trace(UVC_TRACE_CAPTURE, "[E] Invalid buffer type (%u) "
-			"and/or memory (%u).\n", v4l2_buf->type,
-			v4l2_buf->memory);
-		return -EINVAL;
-	}
+	int ret;
 
 	mutex_lock(&queue->mutex);
-	if (list_empty(&queue->mainqueue)) {
-		uvc_trace(UVC_TRACE_CAPTURE, "[E] Empty buffer queue.\n");
-		ret = -EINVAL;
-		goto done;
-	}
-
-	buf = list_first_entry(&queue->mainqueue, struct uvc_buffer, stream);
-	if ((ret = uvc_queue_waiton(buf, nonblocking)) < 0)
-		goto done;
-
-	uvc_trace(UVC_TRACE_CAPTURE, "Dequeuing buffer %u (%u, %u bytes).\n",
-		buf->buf.index, buf->state, buf->buf.bytesused);
-
-	switch (buf->state) {
-	case UVC_BUF_STATE_ERROR:
-		uvc_trace(UVC_TRACE_CAPTURE, "[W] Corrupted data "
-			"(transmission error).\n");
-		ret = -EIO;
-	case UVC_BUF_STATE_DONE:
-		buf->state = UVC_BUF_STATE_IDLE;
-		break;
-
-	case UVC_BUF_STATE_IDLE:
-	case UVC_BUF_STATE_QUEUED:
-	case UVC_BUF_STATE_ACTIVE:
-	case UVC_BUF_STATE_READY:
-	default:
-		uvc_trace(UVC_TRACE_CAPTURE, "[E] Invalid buffer state %u "
-			"(driver bug?).\n", buf->state);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	list_del(&buf->stream);
-	__uvc_query_buffer(buf, v4l2_buf);
-
-done:
+	ret = vb2_dqbuf(&queue->queue, buf, nonblocking);
 	mutex_unlock(&queue->mutex);
-	return ret;
-}
 
-/*
- * VMA operations.
- */
-static void uvc_vm_open(struct vm_area_struct *vma)
-{
-	struct uvc_buffer *buffer = vma->vm_private_data;
-	buffer->vma_use_count++;
-}
-
-static void uvc_vm_close(struct vm_area_struct *vma)
-{
-	struct uvc_buffer *buffer = vma->vm_private_data;
-	buffer->vma_use_count--;
+	return ret;
 }
 
-static const struct vm_operations_struct uvc_vm_ops = {
-	.open		= uvc_vm_open,
-	.close		= uvc_vm_close,
-};
-
-/*
- * Memory-map a video buffer.
- *
- * This function implements video buffers memory mapping and is intended to be
- * used by the device mmap handler.
- */
 int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma)
 {
-	struct uvc_buffer *uninitialized_var(buffer);
-	struct page *page;
-	unsigned long addr, start, size;
-	unsigned int i;
-	int ret = 0;
-
-	start = vma->vm_start;
-	size = vma->vm_end - vma->vm_start;
+	int ret;
 
 	mutex_lock(&queue->mutex);
+	ret = vb2_mmap(&queue->queue, vma);
+	mutex_unlock(&queue->mutex);
 
-	for (i = 0; i < queue->count; ++i) {
-		buffer = &queue->buffer[i];
-		if ((buffer->buf.m.offset >> PAGE_SHIFT) == vma->vm_pgoff)
-			break;
-	}
-
-	if (i == queue->count || PAGE_ALIGN(size) != queue->buf_size) {
-		ret = -EINVAL;
-		goto done;
-	}
-
-	/*
-	 * VM_IO marks the area as being an mmaped region for I/O to a
-	 * device. It also prevents the region from being core dumped.
-	 */
-	vma->vm_flags |= VM_IO;
-
-	addr = (unsigned long)buffer->mem;
-#ifdef CONFIG_MMU
-	while (size > 0) {
-		page = vmalloc_to_page((void *)addr);
-		if ((ret = vm_insert_page(vma, start, page)) < 0)
-			goto done;
-
-		start += PAGE_SIZE;
-		addr += PAGE_SIZE;
-		size -= PAGE_SIZE;
-	}
-#endif
+	return ret;
+}
 
-	vma->vm_ops = &uvc_vm_ops;
-	vma->vm_private_data = buffer;
-	uvc_vm_open(vma);
+unsigned int uvc_queue_poll(struct uvc_video_queue *queue, struct file *file,
+			    poll_table *wait)
+{
+	unsigned int ret;
 
-done:
+	mutex_lock(&queue->mutex);
+	ret = vb2_poll(&queue->queue, file, wait);
 	mutex_unlock(&queue->mutex);
+
 	return ret;
 }
 
-/*
- * Poll the video queue.
+/* -----------------------------------------------------------------------------
  *
- * This function implements video queue polling and is intended to be used by
- * the device poll handler.
  */
-unsigned int uvc_queue_poll(struct uvc_video_queue *queue, struct file *file,
-		poll_table *wait)
+
+/*
+ * Check if buffers have been allocated.
+ */
+int uvc_queue_allocated(struct uvc_video_queue *queue)
 {
-	struct uvc_buffer *buf;
-	unsigned int mask = 0;
+	int allocated;
 
 	mutex_lock(&queue->mutex);
-	if (list_empty(&queue->mainqueue)) {
-		mask |= POLLERR;
-		goto done;
-	}
-	buf = list_first_entry(&queue->mainqueue, struct uvc_buffer, stream);
-
-	poll_wait(file, &buf->wait, wait);
-	if (buf->state == UVC_BUF_STATE_DONE ||
-	    buf->state == UVC_BUF_STATE_ERROR) {
-		if (queue->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
-			mask |= POLLIN | POLLRDNORM;
-		else
-			mask |= POLLOUT | POLLWRNORM;
-	}
-
-done:
+	allocated = vb2_is_busy(&queue->queue);
 	mutex_unlock(&queue->mutex);
-	return mask;
+
+	return allocated;
 }
 
 #ifndef CONFIG_MMU
@@ -543,27 +273,24 @@ done:
  */
 int uvc_queue_enable(struct uvc_video_queue *queue, int enable)
 {
-	unsigned int i;
-	int ret = 0;
+	unsigned long flags;
+	int ret;
 
 	mutex_lock(&queue->mutex);
 	if (enable) {
-		if (uvc_queue_streaming(queue)) {
-			ret = -EBUSY;
+		ret = vb2_streamon(&queue->queue, queue->queue.type);
+		if (ret < 0)
 			goto done;
-		}
-		queue->flags |= UVC_QUEUE_STREAMING;
+
 		queue->buf_used = 0;
 	} else {
-		uvc_queue_cancel(queue, 0);
-		INIT_LIST_HEAD(&queue->mainqueue);
-
-		for (i = 0; i < queue->count; ++i) {
-			queue->buffer[i].error = 0;
-			queue->buffer[i].state = UVC_BUF_STATE_IDLE;
-		}
+		ret = vb2_streamoff(&queue->queue, queue->queue.type);
+		if (ret < 0)
+			goto done;
 
-		queue->flags &= ~UVC_QUEUE_STREAMING;
+		spin_lock_irqsave(&queue->irqlock, flags);
+		INIT_LIST_HEAD(&queue->irqqueue);
+		spin_unlock_irqrestore(&queue->irqlock, flags);
 	}
 
 done:
@@ -594,12 +321,12 @@ void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect)
 				       queue);
 		list_del(&buf->queue);
 		buf->state = UVC_BUF_STATE_ERROR;
-		wake_up(&buf->wait);
+		vb2_buffer_done(&buf->buf, VB2_BUF_STATE_ERROR);
 	}
 	/* This must be protected by the irqlock spinlock to avoid race
-	 * conditions between uvc_queue_buffer and the disconnection event that
+	 * conditions between uvc_buffer_queue and the disconnection event that
 	 * could result in an interruptible wait in uvc_dequeue_buffer. Do not
-	 * blindly replace this logic by checking for the UVC_DEV_DISCONNECTED
+	 * blindly replace this logic by checking for the UVC_QUEUE_DISCONNECTED
 	 * state outside the queue code.
 	 */
 	if (disconnect)
@@ -616,15 +343,12 @@ struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
 	if ((queue->flags & UVC_QUEUE_DROP_CORRUPTED) && buf->error) {
 		buf->error = 0;
 		buf->state = UVC_BUF_STATE_QUEUED;
-		buf->buf.bytesused = 0;
+		vb2_set_plane_payload(&buf->buf, 0, 0);
 		return buf;
 	}
 
 	spin_lock_irqsave(&queue->irqlock, flags);
 	list_del(&buf->queue);
-	buf->error = 0;
-	buf->state = UVC_BUF_STATE_DONE;
-	buf->buf.bytesused = buf->bytesused;
 	if (!list_empty(&queue->irqqueue))
 		nextbuf = list_first_entry(&queue->irqqueue, struct uvc_buffer,
 					   queue);
@@ -632,7 +356,9 @@ struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
 		nextbuf = NULL;
 	spin_unlock_irqrestore(&queue->irqlock, flags);
 
-	wake_up(&buf->wait);
+	buf->state = buf->error ? VB2_BUF_STATE_ERROR : UVC_BUF_STATE_DONE;
+	vb2_set_plane_payload(&buf->buf, 0, buf->bytesused);
+	vb2_buffer_done(&buf->buf, VB2_BUF_STATE_DONE);
+
 	return nextbuf;
 }
-
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
index dadf11f..9d57fbb 100644
--- a/drivers/media/video/uvc/uvc_v4l2.c
+++ b/drivers/media/video/uvc/uvc_v4l2.c
@@ -513,10 +513,7 @@ static int uvc_v4l2_release(struct file *file)
 	/* Only free resources if this is a privileged handle. */
 	if (uvc_has_privileges(handle)) {
 		uvc_video_enable(stream, 0);
-
-		if (uvc_free_buffers(&stream->queue) < 0)
-			uvc_printk(KERN_ERR, "uvc_v4l2_release: Unable to "
-					"free buffers.\n");
+		uvc_free_buffers(&stream->queue);
 	}
 
 	/* Release the file handle. */
@@ -914,18 +911,11 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
 
 	/* Buffers & streaming */
 	case VIDIOC_REQBUFS:
-	{
-		struct v4l2_requestbuffers *rb = arg;
-
-		if (rb->type != stream->type ||
-		    rb->memory != V4L2_MEMORY_MMAP)
-			return -EINVAL;
-
 		if ((ret = uvc_acquire_privileges(handle)) < 0)
 			return ret;
 
 		mutex_lock(&stream->mutex);
-		ret = uvc_alloc_buffers(&stream->queue, rb->count,
+		ret = uvc_alloc_buffers(&stream->queue, arg,
 					stream->ctrl.dwMaxVideoFrameSize);
 		mutex_unlock(&stream->mutex);
 		if (ret < 0)
@@ -934,18 +924,13 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
 		if (ret == 0)
 			uvc_dismiss_privileges(handle);
 
-		rb->count = ret;
 		ret = 0;
 		break;
-	}
 
 	case VIDIOC_QUERYBUF:
 	{
 		struct v4l2_buffer *buf = arg;
 
-		if (buf->type != stream->type)
-			return -EINVAL;
-
 		if (!uvc_has_privileges(handle))
 			return -EBUSY;
 
diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c
index 00fe749..2995f26 100644
--- a/drivers/media/video/uvc/uvc_video.c
+++ b/drivers/media/video/uvc/uvc_video.c
@@ -467,9 +467,10 @@ static int uvc_video_decode_start(struct uvc_streaming *stream,
 		else
 			ktime_get_real_ts(&ts);
 
-		buf->buf.sequence = stream->sequence;
-		buf->buf.timestamp.tv_sec = ts.tv_sec;
-		buf->buf.timestamp.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
+		buf->buf.v4l2_buf.sequence = stream->sequence;
+		buf->buf.v4l2_buf.timestamp.tv_sec = ts.tv_sec;
+		buf->buf.v4l2_buf.timestamp.tv_usec =
+			ts.tv_nsec / NSEC_PER_USEC;
 
 		/* TODO: Handle PTS and SCR. */
 		buf->state = UVC_BUF_STATE_ACTIVE;
@@ -728,7 +729,7 @@ static void uvc_video_encode_bulk(struct urb *urb, struct uvc_streaming *stream,
 		if (buf->bytesused == stream->queue.buf_used) {
 			stream->queue.buf_used = 0;
 			buf->state = UVC_BUF_STATE_READY;
-			buf->buf.sequence = ++stream->sequence;
+			buf->buf.v4l2_buf.sequence = ++stream->sequence;
 			uvc_queue_next_buffer(&stream->queue, buf);
 			stream->last_fid ^= UVC_STREAM_FID;
 		}
diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h
index 55f9171..842682d 100644
--- a/drivers/media/video/uvc/uvcvideo.h
+++ b/drivers/media/video/uvc/uvcvideo.h
@@ -13,6 +13,7 @@
 #include <linux/videodev2.h>
 #include <media/media-device.h>
 #include <media/v4l2-device.h>
+#include <media/videobuf2-core.h>
 
 /* --------------------------------------------------------------------------
  * UVC constants
@@ -319,13 +320,9 @@ enum uvc_buffer_state {
 };
 
 struct uvc_buffer {
-	unsigned long vma_use_count;
-	struct list_head stream;
-
-	/* Touched by interrupt handler. */
-	struct v4l2_buffer buf;
+	struct vb2_buffer buf;
 	struct list_head queue;
-	wait_queue_head_t wait;
+
 	enum uvc_buffer_state state;
 	unsigned int error;
 
@@ -334,24 +331,17 @@ struct uvc_buffer {
 	unsigned int bytesused;
 };
 
-#define UVC_QUEUE_STREAMING		(1 << 0)
-#define UVC_QUEUE_DISCONNECTED		(1 << 1)
-#define UVC_QUEUE_DROP_CORRUPTED	(1 << 2)
+#define UVC_QUEUE_DISCONNECTED		(1 << 0)
+#define UVC_QUEUE_DROP_CORRUPTED	(1 << 1)
 
 struct uvc_video_queue {
-	enum v4l2_buf_type type;
+	struct vb2_queue queue;
+	struct mutex mutex;			/* Protects queue */
 
-	void *mem;
 	unsigned int flags;
-
-	unsigned int count;
-	unsigned int buf_size;
 	unsigned int buf_used;
-	struct uvc_buffer buffer[UVC_MAX_VIDEO_BUFFERS];
-	struct mutex mutex;	/* protects buffers and mainqueue */
-	spinlock_t irqlock;	/* protects irqqueue */
 
-	struct list_head mainqueue;
+	spinlock_t irqlock;			/* Protects irqqueue */
 	struct list_head irqqueue;
 };
 
@@ -391,6 +381,7 @@ struct uvc_streaming {
 	 */
 	struct mutex mutex;
 
+	/* Buffers queue. */
 	unsigned int frozen : 1;
 	struct uvc_video_queue queue;
 	void (*decode) (struct urb *urb, struct uvc_streaming *video,
@@ -520,8 +511,8 @@ extern struct uvc_entity *uvc_entity_by_id(struct uvc_device *dev, int id);
 extern void uvc_queue_init(struct uvc_video_queue *queue,
 		enum v4l2_buf_type type, int drop_corrupted);
 extern int uvc_alloc_buffers(struct uvc_video_queue *queue,
-		unsigned int nbuffers, unsigned int buflength);
-extern int uvc_free_buffers(struct uvc_video_queue *queue);
+		struct v4l2_requestbuffers *rb, unsigned int buflength);
+extern void uvc_free_buffers(struct uvc_video_queue *queue);
 extern int uvc_query_buffer(struct uvc_video_queue *queue,
 		struct v4l2_buffer *v4l2_buf);
 extern int uvc_queue_buffer(struct uvc_video_queue *queue,
@@ -543,7 +534,7 @@ extern unsigned long uvc_queue_get_unmapped_area(struct uvc_video_queue *queue,
 extern int uvc_queue_allocated(struct uvc_video_queue *queue);
 static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
 {
-	return queue->flags & UVC_QUEUE_STREAMING;
+	return vb2_is_streaming(&queue->queue);
 }
 
 /* V4L2 interface */
-- 
1.7.3.4


^ permalink raw reply related

* [PATCH 1/2] uvcvideo: Move fields from uvc_buffer::buf to uvc_buffer
From: Laurent Pinchart @ 2011-10-24 15:42 UTC (permalink / raw)
  To: linux-media
In-Reply-To: <1319470924-15703-1-git-send-email-laurent.pinchart@ideasonboard.com>

Add mem, length and bytesused fields to the uvc_buffer structure and use
them instead of accessing the uvc_buffer::buf m.offset, length and
bytesused fields directly. This prepares the driver to the conversion to
videobuf2.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/video/uvc/uvc_isight.c |   10 +++++-----
 drivers/media/video/uvc/uvc_queue.c  |   12 ++++++++----
 drivers/media/video/uvc/uvc_video.c  |   21 ++++++++++-----------
 drivers/media/video/uvc/uvcvideo.h   |    4 ++++
 4 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/drivers/media/video/uvc/uvc_isight.c b/drivers/media/video/uvc/uvc_isight.c
index 74bbe8f..8510e72 100644
--- a/drivers/media/video/uvc/uvc_isight.c
+++ b/drivers/media/video/uvc/uvc_isight.c
@@ -74,7 +74,7 @@ static int isight_decode(struct uvc_video_queue *queue, struct uvc_buffer *buf,
 	 * Empty buffers (bytesused == 0) don't trigger end of frame detection
 	 * as it doesn't make sense to return an empty buffer.
 	 */
-	if (is_header && buf->buf.bytesused != 0) {
+	if (is_header && buf->bytesused != 0) {
 		buf->state = UVC_BUF_STATE_DONE;
 		return -EAGAIN;
 	}
@@ -83,13 +83,13 @@ static int isight_decode(struct uvc_video_queue *queue, struct uvc_buffer *buf,
 	 * contain no data.
 	 */
 	if (!is_header) {
-		maxlen = buf->buf.length - buf->buf.bytesused;
-		mem = queue->mem + buf->buf.m.offset + buf->buf.bytesused;
+		maxlen = buf->length - buf->bytesused;
+		mem = buf->mem + buf->bytesused;
 		nbytes = min(len, maxlen);
 		memcpy(mem, data, nbytes);
-		buf->buf.bytesused += nbytes;
+		buf->bytesused += nbytes;
 
-		if (len > maxlen || buf->buf.bytesused == buf->buf.length) {
+		if (len > maxlen || buf->bytesused == buf->length) {
 			uvc_trace(UVC_TRACE_FRAME, "Frame complete "
 				  "(overflow).\n");
 			buf->state = UVC_BUF_STATE_DONE;
diff --git a/drivers/media/video/uvc/uvc_queue.c b/drivers/media/video/uvc/uvc_queue.c
index 677691c..0fbb04b 100644
--- a/drivers/media/video/uvc/uvc_queue.c
+++ b/drivers/media/video/uvc/uvc_queue.c
@@ -173,6 +173,9 @@ int uvc_alloc_buffers(struct uvc_video_queue *queue, unsigned int nbuffers,
 		queue->buffer[i].buf.field = V4L2_FIELD_NONE;
 		queue->buffer[i].buf.memory = V4L2_MEMORY_MMAP;
 		queue->buffer[i].buf.flags = 0;
+
+		queue->buffer[i].mem = queue->mem + i * bufsize;
+		queue->buffer[i].length = buflength;
 		init_waitqueue_head(&queue->buffer[i].wait);
 	}
 
@@ -293,9 +296,9 @@ int uvc_queue_buffer(struct uvc_video_queue *queue,
 	}
 	buf->state = UVC_BUF_STATE_QUEUED;
 	if (v4l2_buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
-		buf->buf.bytesused = 0;
+		buf->bytesused = 0;
 	else
-		buf->buf.bytesused = v4l2_buf->bytesused;
+		buf->bytesused = v4l2_buf->bytesused;
 
 	list_add_tail(&buf->stream, &queue->mainqueue);
 	list_add_tail(&buf->queue, &queue->irqqueue);
@@ -437,7 +440,7 @@ int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma)
 	 */
 	vma->vm_flags |= VM_IO;
 
-	addr = (unsigned long)queue->mem + buffer->buf.m.offset;
+	addr = (unsigned long)buffer->mem;
 #ifdef CONFIG_MMU
 	while (size > 0) {
 		page = vmalloc_to_page((void *)addr);
@@ -515,7 +518,7 @@ unsigned long uvc_queue_get_unmapped_area(struct uvc_video_queue *queue,
 		ret = -EINVAL;
 		goto done;
 	}
-	ret = (unsigned long)queue->mem + buffer->buf.m.offset;
+	ret = (unsigned long)buf->mem;
 done:
 	mutex_unlock(&queue->mutex);
 	return ret;
@@ -621,6 +624,7 @@ struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
 	list_del(&buf->queue);
 	buf->error = 0;
 	buf->state = UVC_BUF_STATE_DONE;
+	buf->buf.bytesused = buf->bytesused;
 	if (!list_empty(&queue->irqqueue))
 		nextbuf = list_first_entry(&queue->irqqueue, struct uvc_buffer,
 					   queue);
diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c
index b015e8e..00fe749 100644
--- a/drivers/media/video/uvc/uvc_video.c
+++ b/drivers/media/video/uvc/uvc_video.c
@@ -490,7 +490,7 @@ static int uvc_video_decode_start(struct uvc_streaming *stream,
 	 * avoids detecting end of frame conditions at FID toggling if the
 	 * previous payload had the EOF bit set.
 	 */
-	if (fid != stream->last_fid && buf->buf.bytesused != 0) {
+	if (fid != stream->last_fid && buf->bytesused != 0) {
 		uvc_trace(UVC_TRACE_FRAME, "Frame complete (FID bit "
 				"toggled).\n");
 		buf->state = UVC_BUF_STATE_READY;
@@ -505,7 +505,6 @@ static int uvc_video_decode_start(struct uvc_streaming *stream,
 static void uvc_video_decode_data(struct uvc_streaming *stream,
 		struct uvc_buffer *buf, const __u8 *data, int len)
 {
-	struct uvc_video_queue *queue = &stream->queue;
 	unsigned int maxlen, nbytes;
 	void *mem;
 
@@ -513,11 +512,11 @@ static void uvc_video_decode_data(struct uvc_streaming *stream,
 		return;
 
 	/* Copy the video data to the buffer. */
-	maxlen = buf->buf.length - buf->buf.bytesused;
-	mem = queue->mem + buf->buf.m.offset + buf->buf.bytesused;
+	maxlen = buf->length - buf->bytesused;
+	mem = buf->mem + buf->bytesused;
 	nbytes = min((unsigned int)len, maxlen);
 	memcpy(mem, data, nbytes);
-	buf->buf.bytesused += nbytes;
+	buf->bytesused += nbytes;
 
 	/* Complete the current frame if the buffer size was exceeded. */
 	if (len > maxlen) {
@@ -530,7 +529,7 @@ static void uvc_video_decode_end(struct uvc_streaming *stream,
 		struct uvc_buffer *buf, const __u8 *data, int len)
 {
 	/* Mark the buffer as done if the EOF marker is set. */
-	if (data[1] & UVC_STREAM_EOF && buf->buf.bytesused != 0) {
+	if (data[1] & UVC_STREAM_EOF && buf->bytesused != 0) {
 		uvc_trace(UVC_TRACE_FRAME, "Frame complete (EOF found).\n");
 		if (data[0] == len)
 			uvc_trace(UVC_TRACE_FRAME, "EOF in empty payload.\n");
@@ -568,8 +567,8 @@ static int uvc_video_encode_data(struct uvc_streaming *stream,
 	void *mem;
 
 	/* Copy video data to the URB buffer. */
-	mem = queue->mem + buf->buf.m.offset + queue->buf_used;
-	nbytes = min((unsigned int)len, buf->buf.bytesused - queue->buf_used);
+	mem = buf->mem + queue->buf_used;
+	nbytes = min((unsigned int)len, buf->bytesused - queue->buf_used);
 	nbytes = min(stream->bulk.max_payload_size - stream->bulk.payload_size,
 			nbytes);
 	memcpy(data, mem, nbytes);
@@ -624,7 +623,7 @@ static void uvc_video_decode_isoc(struct urb *urb, struct uvc_streaming *stream,
 			urb->iso_frame_desc[i].actual_length);
 
 		if (buf->state == UVC_BUF_STATE_READY) {
-			if (buf->buf.length != buf->buf.bytesused &&
+			if (buf->length != buf->bytesused &&
 			    !(stream->cur_format->flags &
 			      UVC_FMT_FLAG_COMPRESSED))
 				buf->error = 1;
@@ -724,9 +723,9 @@ static void uvc_video_encode_bulk(struct urb *urb, struct uvc_streaming *stream,
 	stream->bulk.payload_size += ret;
 	len -= ret;
 
-	if (buf->buf.bytesused == stream->queue.buf_used ||
+	if (buf->bytesused == stream->queue.buf_used ||
 	    stream->bulk.payload_size == stream->bulk.max_payload_size) {
-		if (buf->buf.bytesused == stream->queue.buf_used) {
+		if (buf->bytesused == stream->queue.buf_used) {
 			stream->queue.buf_used = 0;
 			buf->state = UVC_BUF_STATE_READY;
 			buf->buf.sequence = ++stream->sequence;
diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h
index 4c1392e..55f9171 100644
--- a/drivers/media/video/uvc/uvcvideo.h
+++ b/drivers/media/video/uvc/uvcvideo.h
@@ -328,6 +328,10 @@ struct uvc_buffer {
 	wait_queue_head_t wait;
 	enum uvc_buffer_state state;
 	unsigned int error;
+
+	void *mem;
+	unsigned int length;
+	unsigned int bytesused;
 };
 
 #define UVC_QUEUE_STREAMING		(1 << 0)
-- 
1.7.3.4


^ permalink raw reply related

* [PATCH 0/2] uvcvideo: videobuf2-vmalloc support
From: Laurent Pinchart @ 2011-10-24 15:42 UTC (permalink / raw)
  To: linux-media

Hi everybody,

The subject says it all. Now you can only blame me for not using video_ioctl2
(which I'm currently evaluating btw...) and the control framework :-)

Laurent Pinchart (2):
  uvcvideo: Move fields from uvc_buffer::buf to uvc_buffer
  uvcvideo: Use videobuf2-vmalloc

 drivers/media/video/uvc/Kconfig      |    1 +
 drivers/media/video/uvc/uvc_isight.c |   10 +-
 drivers/media/video/uvc/uvc_queue.c  |  554 +++++++++-------------------------
 drivers/media/video/uvc/uvc_v4l2.c   |   19 +-
 drivers/media/video/uvc/uvc_video.c  |   30 +-
 drivers/media/video/uvc/uvcvideo.h   |   37 +--
 6 files changed, 181 insertions(+), 470 deletions(-)

-- 
Regards,

Laurent Pinchart


^ permalink raw reply

* Re: [PATCH v2 3/5] regulator: helper routine to extract regulator_init_data
From: Shawn Guo @ 2011-10-24 15:51 UTC (permalink / raw)
  To: Grant Likely
  Cc: Mark Brown, Rajendra Nayak, patches, tony, devicetree-discuss,
	linux-kernel, linux-omap, lrg, linux-arm-kernel
In-Reply-To: <20111024145631.GB8708@ponder.secretlab.ca>

On Mon, Oct 24, 2011 at 04:56:31PM +0200, Grant Likely wrote:
> On Mon, Oct 24, 2011 at 10:51:40PM +0800, Shawn Guo wrote:
> > On Mon, Oct 24, 2011 at 03:59:50PM +0200, Grant Likely wrote:
> > > On Mon, Oct 24, 2011 at 09:40:26PM +0800, Shawn Guo wrote:
> > > > diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> > > > index 8fe132d..29dcf90 100644
> > > > --- a/drivers/regulator/core.c
> > > > +++ b/drivers/regulator/core.c
> > > > @@ -2673,7 +2673,8 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
> > > >         BLOCKING_INIT_NOTIFIER_HEAD(&rdev->notifier);
> > > > 
> > > >         /* find device_node and attach it */
> > > > -       rdev->dev.of_node = of_find_node_by_name(NULL, regulator_desc->name);
> > > > +       rdev->dev.of_node = of_find_node_by_name(dev->parent->of_node,
> > > > +                                                regulator_desc->name);
> > > 
> > > of_find_node_by_name() doesn't work that way.  The first argument is a
> > > starting point, but it doesn't restrict the search to children of a
> > > node.
> > > 
> > > for_each_child_of_node() is what you want to use when iterating over
> > > the children which unfortunately changes the structure of this
> > > function.
> > > 
> > The dev->parent->of_node is meant to point to node 'pmic: mc13892@0'.
> > And the intention here is not to iterate over the children, but to
> > start a search from a reasonable point rather than the top root node.
> 
> It is always better to attach the of_node at struct device
> registration time instead of searching the tree in common code.  The
> of_node should already be assigned by the time regulator_register() is
> called.

That's the problem we have.  There is no 'struct dev' to attach of_node
for each regulator by the time regulator_register() is called, because
the 'struct dev' for each regulator is created inside
regulator_register() as wrapped by 'struct regulator_dev'.

-- 
Regards,
Shawn


^ permalink raw reply

* [Buildroot] GnuPG
From: ilranzani @ 2011-10-24 15:40 UTC (permalink / raw)
  To: buildroot
In-Reply-To: <8167afaddbb08fc25202dbf489d78389@zacarias.com.ar>


Steps:
+ LIBKSBA
+ LIBASSUAN
=== pth
- gnupg
- gpgme
- opgk

While compiling PTH 2.0.7


./libtool: line 1300: func_opt_split: command not found
libtool: Version mismatch error.  This is libtool 2.2.10, but the
libtool: definition of this LT_INIT comes from an older release.
libtool: You should recreate aclocal.m4 with macros from libtool 2.2.10
libtool: and run autoconf again.
make[1]: *** [pth_uctx.lo] Error 63
make[1]: *** Waiting for unfinished jobs....



Gustavo Zacarias-2 wrote:
> 
> On 24.10.2011 08:12, ilranzani wrote:
> 
>> Nobody?
>>
>> (in buildroot there's already libgcrypt)
>>
>> UP UP UP ! :)
> 
> It's not too hard, you just need to add a couple of extra libraries 
> (packages) that it needs, IIRC libassuan and libksba.
> The rest of the mandatory dependencies are already available 
> (libgpg-error & libgcrypt).
> Regards.
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
> 
> 

-- 
View this message in context: http://old.nabble.com/GnuPG-tp29967586p32711202.html
Sent from the Buildroot (busybox) mailing list archive at Nabble.com.

^ permalink raw reply

* [PATCH v2] gpio: pl061: add DT binding support
From: Rob Herring @ 2011-10-24 15:40 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <4E7BBFF5.5090001@gmail.com>

Grant,

On 09/22/2011 06:08 PM, Rob Herring wrote:
> Grant,
> 
> On 08/10/2011 04:31 PM, Rob Herring wrote:
>> From: Rob Herring <rob.herring@calxeda.com>
>>
>> This adds devicetree binding support to the ARM pl061 driver removing the
>> platform_data dependency. When DT binding is used, the gpio numbering is
>> assigned dynamically. For now, interrupts are not supported with DT until
>> irqdomains learn dynamic irq assignment.
>>
>> Rather than add another case of -1, updating the driver to use NO_IRQ.
>>
>> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
>> Cc: Grant Likely <grant.likely@secretlab.ca>
>> ---
> 
> Ping. Any comments on this?
> 

Ping. Can you apply this for 3.2.

Rob

> Rob
>>
>> v2:
>> - Add other -1 to NO_IRQ conversions
>> - Drop DT irq support for now
>>
>>  drivers/gpio/gpio-pl061.c  |   31 +++++++++++++++++++++----------
>>  include/linux/amba/pl061.h |    3 +--
>>  2 files changed, 22 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
>> index 2c5a18f..093c90b 100644
>> --- a/drivers/gpio/gpio-pl061.c
>> +++ b/drivers/gpio/gpio-pl061.c
>> @@ -118,7 +118,7 @@ static int pl061_to_irq(struct gpio_chip *gc, unsigned offset)
>>  {
>>  	struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
>>  
>> -	if (chip->irq_base == (unsigned) -1)
>> +	if (chip->irq_base == NO_IRQ)
>>  		return -EINVAL;
>>  
>>  	return chip->irq_base + offset;
>> @@ -246,6 +246,18 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)
>>  	if (chip == NULL)
>>  		return -ENOMEM;
>>  
>> +	pdata = dev->dev.platform_data;
>> +	if (pdata) {
>> +		chip->gc.base = pdata->gpio_base;
>> +		chip->irq_base = pdata->irq_base;
>> +	} else if (dev->dev.of_node) {
>> +		chip->gc.base = -1;
>> +		chip->irq_base = NO_IRQ;
>> +	} else {
>> +		ret = -ENODEV;
>> +		goto free_mem;
>> +	}
>> +
>>  	if (!request_mem_region(dev->res.start,
>>  				resource_size(&dev->res), "pl061")) {
>>  		ret = -EBUSY;
>> @@ -267,14 +279,11 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)
>>  	chip->gc.get = pl061_get_value;
>>  	chip->gc.set = pl061_set_value;
>>  	chip->gc.to_irq = pl061_to_irq;
>> -	chip->gc.base = pdata->gpio_base;
>>  	chip->gc.ngpio = PL061_GPIO_NR;
>>  	chip->gc.label = dev_name(&dev->dev);
>>  	chip->gc.dev = &dev->dev;
>>  	chip->gc.owner = THIS_MODULE;
>>  
>> -	chip->irq_base = pdata->irq_base;
>> -
>>  	ret = gpiochip_add(&chip->gc);
>>  	if (ret)
>>  		goto iounmap;
>> @@ -283,7 +292,7 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)
>>  	 * irq_chip support
>>  	 */
>>  
>> -	if (chip->irq_base == (unsigned) -1)
>> +	if (chip->irq_base == NO_IRQ)
>>  		return 0;
>>  
>>  	writeb(0, chip->base + GPIOIE); /* disable irqs */
>> @@ -307,11 +316,13 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)
>>  	list_add(&chip->list, chip_list);
>>  
>>  	for (i = 0; i < PL061_GPIO_NR; i++) {
>> -		if (pdata->directions & (1 << i))
>> -			pl061_direction_output(&chip->gc, i,
>> -					pdata->values & (1 << i));
>> -		else
>> -			pl061_direction_input(&chip->gc, i);
>> +		if (pdata) {
>> +			if (pdata->directions & (1 << i))
>> +				pl061_direction_output(&chip->gc, i,
>> +						pdata->values & (1 << i));
>> +			else
>> +				pl061_direction_input(&chip->gc, i);
>> +		}
>>  
>>  		irq_set_chip_and_handler(i + chip->irq_base, &pl061_irqchip,
>>  					 handle_simple_irq);
>> diff --git a/include/linux/amba/pl061.h b/include/linux/amba/pl061.h
>> index 5ddd9ad..2412af9 100644
>> --- a/include/linux/amba/pl061.h
>> +++ b/include/linux/amba/pl061.h
>> @@ -7,8 +7,7 @@ struct pl061_platform_data {
>>  	unsigned	gpio_base;
>>  
>>  	/* number of the first IRQ.
>> -	 * If the IRQ functionality in not desired this must be set to
>> -	 * (unsigned) -1.
>> +	 * If the IRQ functionality in not desired this must be set to NO_IRQ.
>>  	 */
>>  	unsigned	irq_base;
>>  
> 

^ permalink raw reply

* Re: [lm-sensors] [PATCH 5/6] IIO:hwmon interface client driver.
From: Guenter Roeck @ 2011-10-24 15:39 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
	linus.ml.walleij@gmail.com, zdevai@gmail.com,
	linux@arm.linux.org.uk, arnd@arndb.de,
	broonie@opensource.wolfsonmicro.com, gregkh@suse.de,
	lm-sensors@lm-sensors.org, khali@linux-fr.org,
	thomas.petazzoni@free-electrons.com,
	maxime.ripard@free-electrons.com
In-Reply-To: <4EA53973.9080102@cam.ac.uk>

On Mon, 2011-10-24 at 06:09 -0400, Jonathan Cameron wrote:
[ ... ]
> >>> +/*
> >>> + * Assumes that IIO and hwmon operate in the same base units.
> >>> + * This is supposed to be true, but needs verification for
> >>> + * new channel types.
> >>> + */
> >>> +static ssize_t iio_hwmon_read_val(struct device *dev,
> >>> +				  struct device_attribute *attr,
> >>> +				  char *buf)
> >>> +{
> >>> +	long result;
> >>> +	int val, ret, scaleint, scalepart;
> >>> +	struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr);
> >>> +	struct iio_hwmon_state *state = dev_get_drvdata(dev);
> >>> +
> >>> +	/*
> >>> +	 * No locking between this pair, so theoretically possible
> >>> +	 * the scale has changed.
> >>> +	 */
> >>> +	ret = iio_read_channel_raw(state->channels[sattr->index],
> >>> +				   &val);
> >>> +	if (ret < 0)
> >>> +		return ret;
> >>> +
> >>> +	ret = iio_read_channel_scale(state->channels[sattr->index],
> >>> +				     &scaleint, &scalepart);
> >>> +	if (ret < 0)
> >>> +		return ret;
> >>> +	switch (ret) {
> >>> +	case IIO_VAL_INT:
> >>> +		result = val * scaleint;
> >>> +		break;
> >>> +	case IIO_VAL_INT_PLUS_MICRO:
> >>> +		result = (long)val * (long)scaleint +
> >>> +			(long)val * (long)scalepart / 1000000L;
> >>> +		break;
> >>> +	case IIO_VAL_INT_PLUS_NANO:
> >>> +		result = (long)val * (long)scaleint +
> >>> +			(long)val * (long)scalepart / 1000000000L;
> >>> +		break;
> >>
> >> Still easy to imagine that val * scalepart gets larger than 2147483647L
> >> (on machines where sizeof(long) = 4) ... it will already happen if the
> >> result of (val * scalepart / 1000000000) is larger than 2. 
> > Good point.  I really ought to have done the calcs.
> > If we have maximum possible value in here things will be ugly.
> > 
> > Worst case is scalepart is 9999999999. (could be done as 1 - 0.000000001
> > which would be nicer, but we don't specify a preference - from this
> > discussion I am suspecting we should!)
> > 
> > Looks like 64 bits is going to be a requirement as you say.
> >>
> >> What value range do you expect to see here ?
> >>
> >> If (val * scaleint) is already the milli-unit, scalepart would possibly
> >> only address fractions of milli-units. If so, the result of (val *
> >> scalepart / 1000000000L) might always be smaller than 1, ie 0. 
> > It certainly should be.
> >> If so, for the calculation to have any value, you might be better off using
> >> DIV_ROUND_CLOSEST(val * scalepart, 1000000000L).
> > Good idea.
> >>
> >> I am a bit confused by this anyway. Since hwmon in general reports
> >> milli-units, VAL_INT appears to reflect milli-units, VAL_INT_PLUS_MICRO
> >> really means nano-units, and IIO_VAL_INT_PLUS_NANO really means
> >> pico-units. Is this correct ?
> > Micro units of the scale factor.
> > 
> > Take my test part a max1363...
> > Scale is actually 0.5 so each adc count (e.g. raw value) is 0.5millivolts.
> > 
> > scale int here is 0,
> > scale part is 500,000 (so 0.5) and it returns IIO_VAL_INT_PLUS_MICRO.
> 
> How about the following?  It'll be extremely costly, but this isn't exactly
> a fast path!
> 
> 	case IIO_VAL_INT_PLUS_MICRO:
> 		result = (s64)val * (s64)scaleint +
> 			div_s64((s64)val * (s64)scalepart, 1000000LL);
> 		break;
> 	case IIO_VAL_INT_PLUS_NANO:
> 		result = (s64)val * (s64)scaleint +
> 			div_s64((s64)val * (s64)scalepart, 1000000000LL);
> 		break;

Is div_s64 really necessary, or would

		result = (long)val * (long)scaleint +
			DIV_ROUND_CLOSEST((s64)val * (s64)scalepart,
					 1000000000LL);

work as well ?

Thanks,
Guenter




_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply

* Re: [PATCH 5/6] IIO:hwmon interface client driver.
From: Guenter Roeck @ 2011-10-24 15:39 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
	linus.ml.walleij@gmail.com, zdevai@gmail.com,
	linux@arm.linux.org.uk, arnd@arndb.de,
	broonie@opensource.wolfsonmicro.com, gregkh@suse.de,
	lm-sensors@lm-sensors.org, khali@linux-fr.org,
	thomas.petazzoni@free-electrons.com,
	maxime.ripard@free-electrons.com
In-Reply-To: <4EA53973.9080102@cam.ac.uk>

On Mon, 2011-10-24 at 06:09 -0400, Jonathan Cameron wrote:
[ ... ]
> >>> +/*
> >>> + * Assumes that IIO and hwmon operate in the same base units.
> >>> + * This is supposed to be true, but needs verification for
> >>> + * new channel types.
> >>> + */
> >>> +static ssize_t iio_hwmon_read_val(struct device *dev,
> >>> +				  struct device_attribute *attr,
> >>> +				  char *buf)
> >>> +{
> >>> +	long result;
> >>> +	int val, ret, scaleint, scalepart;
> >>> +	struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr);
> >>> +	struct iio_hwmon_state *state = dev_get_drvdata(dev);
> >>> +
> >>> +	/*
> >>> +	 * No locking between this pair, so theoretically possible
> >>> +	 * the scale has changed.
> >>> +	 */
> >>> +	ret = iio_read_channel_raw(state->channels[sattr->index],
> >>> +				   &val);
> >>> +	if (ret < 0)
> >>> +		return ret;
> >>> +
> >>> +	ret = iio_read_channel_scale(state->channels[sattr->index],
> >>> +				     &scaleint, &scalepart);
> >>> +	if (ret < 0)
> >>> +		return ret;
> >>> +	switch (ret) {
> >>> +	case IIO_VAL_INT:
> >>> +		result = val * scaleint;
> >>> +		break;
> >>> +	case IIO_VAL_INT_PLUS_MICRO:
> >>> +		result = (long)val * (long)scaleint +
> >>> +			(long)val * (long)scalepart / 1000000L;
> >>> +		break;
> >>> +	case IIO_VAL_INT_PLUS_NANO:
> >>> +		result = (long)val * (long)scaleint +
> >>> +			(long)val * (long)scalepart / 1000000000L;
> >>> +		break;
> >>
> >> Still easy to imagine that val * scalepart gets larger than 2147483647L
> >> (on machines where sizeof(long) = 4) ... it will already happen if the
> >> result of (val * scalepart / 1000000000) is larger than 2. 
> > Good point.  I really ought to have done the calcs.
> > If we have maximum possible value in here things will be ugly.
> > 
> > Worst case is scalepart is 9999999999. (could be done as 1 - 0.000000001
> > which would be nicer, but we don't specify a preference - from this
> > discussion I am suspecting we should!)
> > 
> > Looks like 64 bits is going to be a requirement as you say.
> >>
> >> What value range do you expect to see here ?
> >>
> >> If (val * scaleint) is already the milli-unit, scalepart would possibly
> >> only address fractions of milli-units. If so, the result of (val *
> >> scalepart / 1000000000L) might always be smaller than 1, ie 0. 
> > It certainly should be.
> >> If so, for the calculation to have any value, you might be better off using
> >> DIV_ROUND_CLOSEST(val * scalepart, 1000000000L).
> > Good idea.
> >>
> >> I am a bit confused by this anyway. Since hwmon in general reports
> >> milli-units, VAL_INT appears to reflect milli-units, VAL_INT_PLUS_MICRO
> >> really means nano-units, and IIO_VAL_INT_PLUS_NANO really means
> >> pico-units. Is this correct ?
> > Micro units of the scale factor.
> > 
> > Take my test part a max1363...
> > Scale is actually 0.5 so each adc count (e.g. raw value) is 0.5millivolts.
> > 
> > scale int here is 0,
> > scale part is 500,000 (so 0.5) and it returns IIO_VAL_INT_PLUS_MICRO.
> 
> How about the following?  It'll be extremely costly, but this isn't exactly
> a fast path!
> 
> 	case IIO_VAL_INT_PLUS_MICRO:
> 		result = (s64)val * (s64)scaleint +
> 			div_s64((s64)val * (s64)scalepart, 1000000LL);
> 		break;
> 	case IIO_VAL_INT_PLUS_NANO:
> 		result = (s64)val * (s64)scaleint +
> 			div_s64((s64)val * (s64)scalepart, 1000000000LL);
> 		break;

Is div_s64 really necessary, or would

		result = (long)val * (long)scaleint +
			DIV_ROUND_CLOSEST((s64)val * (s64)scalepart,
					 1000000000LL);

work as well ?

Thanks,
Guenter

^ permalink raw reply

* [Buildroot] Some topics for the Buildroot Developer Day
From: Thomas Petazzoni @ 2011-10-24 15:38 UTC (permalink / raw)
  To: buildroot

Hello,

As discussed on IRC, I am posting below a list of topics that might be
discussed during the developer day. Note that this is just _my_ list of
topics, note the one of the Buildroot project as a whole. Moreover,
it's very likely that not all topics will be covered during our meeting
day. However, feel free to add your opinion and/or your additional
topics, especially if you can't make it to the Developer day.

Regards,

Thomas

ELCE 2011 meeting agenda
========================

 * Migration to the Ascii-doc format, what remains to be done ?
   Infrastructure on the web server side ?

 * Extract sources in a new output/sources/ directory, and do
   out-of-tree build of packages.

   Pros:

    - Allows more natural integration with the override source
      directory mechanism. No rsync needed here, especially useful for
      big packages such as the kernel.

    - Allows to extract only once the source code for utitilies built
      for the host and the target (X.org components, Glib/Gtk stack,
      etc.)

    - Should work fine for all CMake-based and autotools-based packages.

   Cons:

    - Not all packages support out-of-tree build. The infrastructure
      should support a <pkg>_OUTOFTREE boolean, defaulting to NO for
      all packages, overriden to YES for autotools-based and
      CMake-based packages. When set to NO, the infrastructure will
      have to copy/rsync the source code to the build directory. This
      adds an additional copy of the source code for packages that
      don't support out-of-tree build.

 * Website improvement. The website is ugly, never changes, not
   representative of the vivacity of the community. At least improve
   the design. Wiki ? Blog ?

 * Maintainance/patch review/merge. How to spread the load ? Should we
   move to a model with trusted maintainers for specific parts of
   Buildroot ? Usage of patchwork/Gerrit ?

 * Host packages visible in menuconfig. Discussion has taken place on
   the list, consensus reached between several contributors,
   implementation proposed. What do we do ?

   + proposal of Arnout to derive host dependencies from target
     dependencies.

 * Per-package device files handling, proposed by Maxime Ripard.

 * Testing infrastructure. Possible to put build results on the Web
   server ? Common format for them ?

 * Tracking of files installed by packages. Do we care ? Is this an
   important feature of Buildroot ? Won't the added complexity make
   Buildroot more complicated to understand ?

   Which solution ? Two solutions:

    - Change the installation steps of packages so that each package
      installs in a different directory.

      Pros:

        seems to be the cleanest solution.

        allows to easily detect packages overriding files installed by
        other packages.

      Cons:

        requires modifications of all gentargets packages to use
        $$(STAGING_DIR) and $$(TARGET_DIR) instead of $(STAGING_DIR)
        and $(TARGET_DIR).

        strange handling of host packages. DESTDIR isn't used, the
        prefix is the absolute path to HOST_DIR.

    - Keep installing package files in their normal directory, but
      detect new files and modified files.

      Pros:

        no need to change anything in the current package installation
        procedures.

      Cons:

        need to scan the TARGET_DIR, STAGING_DIR and HOST_DIR after
        every package installation.

        hard to detect modified/overwritten files, except by storing
        hashes of installed files.

 * Next big directions. What are the next big directions for Buildroot
   ? The major features we want to implement ?



-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply

* [PATCH 2/2] sparse, llvm: Fix struct code generation
From: Pekka Enberg @ 2011-10-24 15:37 UTC (permalink / raw)
  To: linux-sparse; +Cc: Pekka Enberg, Christopher Li, Jeff Garzik, Linus Torvalds
In-Reply-To: <1319470642-21031-1-git-send-email-penberg@kernel.org>

Use LLVMGetTypeByName() to look up struct data types to fix code generation for
structs that refer to themselves.

Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
---
 sparse-llvm.c               |   50 +++++++++++++++++++++++-------------------
 validation/backend/struct.c |    1 +
 2 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/sparse-llvm.c b/sparse-llvm.c
index 14744e5..5d1b79c 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -32,11 +32,11 @@ static inline bool symbol_is_fp_type(struct symbol *sym)
 	return sym->ctype.base_type == &fp_type;
 }
 
-static LLVMTypeRef symbol_type(struct symbol *sym);
+static LLVMTypeRef symbol_type(LLVMModuleRef module, struct symbol *sym);
 
 #define MAX_STRUCT_MEMBERS 64
 
-static LLVMTypeRef sym_struct_type(struct symbol *sym)
+static LLVMTypeRef sym_struct_type(LLVMModuleRef module, struct symbol *sym)
 {
 	LLVMTypeRef elem_types[MAX_STRUCT_MEMBERS];
 	struct symbol *member;
@@ -46,6 +46,10 @@ static LLVMTypeRef sym_struct_type(struct symbol *sym)
 
 	sprintf(buffer, "%.*s", sym->ident->len, sym->ident->name);
 
+	ret = LLVMGetTypeByName(module, buffer);
+	if (ret)
+		return ret;
+
 	ret = LLVMStructCreateNamed(LLVMGetGlobalContext(), buffer);
 
 	FOR_EACH_PTR(sym->symbol_list, member) {
@@ -53,7 +57,7 @@ static LLVMTypeRef sym_struct_type(struct symbol *sym)
 
 		assert(nr < MAX_STRUCT_MEMBERS);
 
-		member_type = symbol_type(member);
+		member_type = symbol_type(module, member);
 
 		elem_types[nr++] = member_type; 
 	} END_FOR_EACH_PTR(member);
@@ -62,9 +66,9 @@ static LLVMTypeRef sym_struct_type(struct symbol *sym)
 	return ret;
 }
 
-static LLVMTypeRef sym_ptr_type(struct symbol *sym)
+static LLVMTypeRef sym_ptr_type(LLVMModuleRef module, struct symbol *sym)
 {
-	LLVMTypeRef type = symbol_type(sym->ctype.base_type);
+	LLVMTypeRef type = symbol_type(module, sym->ctype.base_type);
 
 	return LLVMPointerType(type, 0);
 }
@@ -112,22 +116,22 @@ static LLVMTypeRef sym_basetype_type(struct symbol *sym)
 	return ret;
 }
 
-static LLVMTypeRef symbol_type(struct symbol *sym)
+static LLVMTypeRef symbol_type(LLVMModuleRef module, struct symbol *sym)
 {
 	LLVMTypeRef ret = NULL;
 
 	switch (sym->type) {
 	case SYM_NODE:
-		ret = symbol_type(sym->ctype.base_type);
+		ret = symbol_type(module, sym->ctype.base_type);
 		break;
 	case SYM_BASETYPE:
 		ret = sym_basetype_type(sym);
 		break;
 	case SYM_PTR:
-		ret = sym_ptr_type(sym);
+		ret = sym_ptr_type(module, sym);
 		break;
 	case SYM_STRUCT:
-		ret = sym_struct_type(sym);
+		ret = sym_struct_type(module, sym);
 		break;
 	default:
 		assert(0);
@@ -135,10 +139,10 @@ static LLVMTypeRef symbol_type(struct symbol *sym)
 	return ret;
 }
 
-static LLVMTypeRef insn_symbol_type(struct instruction *insn)
+static LLVMTypeRef insn_symbol_type(LLVMModuleRef module, struct instruction *insn)
 {
 	if (insn->type)
-		return symbol_type(insn->type);
+		return symbol_type(module, insn->type);
 
 	switch (insn->size) {
 		case 8:		return LLVMInt8Type();
@@ -234,7 +238,7 @@ static LLVMValueRef pseudo_to_value(struct function *fn, struct instruction *ins
 		break;
 	}
 	case PSEUDO_VAL:
-		result = LLVMConstInt(insn_symbol_type(insn), pseudo->value, 1);
+		result = LLVMConstInt(insn_symbol_type(fn->module, insn), pseudo->value, 1);
 		break;
 	case PSEUDO_ARG: {
 		result = LLVMGetParam(fn->fn, pseudo->nr - 1);
@@ -265,7 +269,7 @@ static LLVMTypeRef pseudo_type(struct function *fn, struct instruction *insn, ps
 
 	switch (pseudo->type) {
 	case PSEUDO_REG:
-		result = symbol_type(pseudo->def->type);
+		result = symbol_type(fn->module, pseudo->def->type);
 		break;
 	case PSEUDO_SYM: {
 		struct symbol *sym = pseudo->sym;
@@ -287,7 +291,7 @@ static LLVMTypeRef pseudo_type(struct function *fn, struct instruction *insn, ps
 		break;
 	}
 	case PSEUDO_VAL:
-		result = insn_symbol_type(insn);
+		result = insn_symbol_type(fn->module, insn);
 		break;
 	case PSEUDO_ARG:
 		result = LLVMTypeOf(LLVMGetParam(fn->fn, pseudo->nr - 1));
@@ -691,7 +695,7 @@ static void output_op_phi(struct function *fn, struct instruction *insn)
 	pseudo_t phi;
 	LLVMValueRef target;
 
-	target = LLVMBuildPhi(fn->builder, insn_symbol_type(insn),
+	target = LLVMBuildPhi(fn->builder, insn_symbol_type(fn->module, insn),
 				"phi");
 	int pll = 0;
 	FOR_EACH_PTR(insn->phi_list, phi) {
@@ -733,9 +737,9 @@ static void output_op_cast(struct function *fn, struct instruction *insn, LLVMOp
 	assert(!symbol_is_fp_type(insn->type));
 
 	if (insn->size < LLVMGetIntTypeWidth(LLVMTypeOf(src)))
-		target = LLVMBuildTrunc(fn->builder, src, insn_symbol_type(insn), target_name);
+		target = LLVMBuildTrunc(fn->builder, src, insn_symbol_type(fn->module, insn), target_name);
 	else
-		target = LLVMBuildCast(fn->builder, op, src, insn_symbol_type(insn), target_name);
+		target = LLVMBuildCast(fn->builder, op, src, insn_symbol_type(fn->module, insn), target_name);
 
 	insn->target->priv = target;
 }
@@ -749,7 +753,7 @@ static void output_op_copy(struct function *fn, struct instruction *insn,
 
 	pseudo_name(insn->target, target_name);
 	src = pseudo_to_value(fn, insn, pseudo);
-	const_type = insn_symbol_type(insn);
+	const_type = insn_symbol_type(fn->module, insn);
 
 	/*
 	 * This is nothing more than 'target = src'
@@ -910,12 +914,12 @@ static void output_fn(LLVMModuleRef module, struct entrypoint *ep)
 	FOR_EACH_PTR(base_type->arguments, arg) {
 		struct symbol *arg_base_type = arg->ctype.base_type;
 
-		arg_types[nr_args++] = symbol_type(arg_base_type);
+		arg_types[nr_args++] = symbol_type(module, arg_base_type);
 	} END_FOR_EACH_PTR(arg);
 
 	name = show_ident(sym->ident);
 
-	return_type = symbol_type(ret_type);
+	return_type = symbol_type(module, ret_type);
 
 	function.module = module;
 
@@ -972,7 +976,7 @@ static int output_data(LLVMModuleRef module, struct symbol *sym)
 	if (initializer) {
 		switch (initializer->type) {
 		case EXPR_VALUE:
-			initial_value = LLVMConstInt(symbol_type(sym), initializer->value, 1);
+			initial_value = LLVMConstInt(symbol_type(module, sym), initializer->value, 1);
 			break;
 		case EXPR_SYMBOL: {
 			struct symbol *sym = initializer->symbol;
@@ -984,14 +988,14 @@ static int output_data(LLVMModuleRef module, struct symbol *sym)
 			assert(0);
 		}
 	} else {
-		LLVMTypeRef type = symbol_type(sym);
+		LLVMTypeRef type = symbol_type(module, sym);
 
 		initial_value = LLVMConstNull(type);
 	}
 
 	name = show_ident(sym->ident);
 
-	data = LLVMAddGlobal(module, symbol_type(sym->ctype.base_type), name);
+	data = LLVMAddGlobal(module, symbol_type(module, sym->ctype.base_type), name);
 
 	LLVMSetLinkage(data, data_linkage(sym));
 
diff --git a/validation/backend/struct.c b/validation/backend/struct.c
index 9d0cb56..1afaf2d 100644
--- a/validation/backend/struct.c
+++ b/validation/backend/struct.c
@@ -6,6 +6,7 @@ struct symbol {
 	void			*p;
 	const char		*name;
 	struct ctype		ctype;
+	struct symbol		*next_id;
 };
 
 static struct symbol sym;
-- 
1.7.6.4


^ permalink raw reply related

* Re: [PATCH v4 0/4] ILK VT-d fix
From: Keith Packard @ 2011-10-24 15:37 UTC (permalink / raw)
  To: Woodhouse, David, Ben Widawsky
  Cc: Dave Airlie, intel-gfx@lists.freedesktop.org, Qu, Yan
In-Reply-To: <1319443974.13738.85.camel@shinybook.infradead.org>


[-- Attachment #1.1: Type: text/plain, Size: 396 bytes --]

On Mon, 24 Oct 2011 08:14:45 +0000, "Woodhouse, David" <david.woodhouse@intel.com> wrote:

> The IOMMU patches are now in Linus' tree and thus will be in the 3.1
> release. Are we going to push the graphics patches in time for the 3.1
> release too?

The graphics patches are in the 3.2 pull request; they'll be available
for the 3.1 stable series though.

-- 
keith.packard@intel.com

[-- Attachment #1.2: Type: application/pgp-signature, Size: 827 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply

* [PATCH 1/2] sparse, llvm: Use new LLVM type system API for structs
From: Pekka Enberg @ 2011-10-24 15:37 UTC (permalink / raw)
  To: linux-sparse; +Cc: Pekka Enberg, Christopher Li, Jeff Garzik, Linus Torvalds

To fix an issue with structs that refer to themselves:

  struct symbol {
          struct symbol *next;
  };

convert the code to use new type system API introduced in LLVM 3.0 so that
there's a LLVMTypeRef of the struct we can look up while walking through the
struct members.

Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
---
 sparse-llvm.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/sparse-llvm.c b/sparse-llvm.c
index fc0c2e9..14744e5 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -40,15 +40,26 @@ static LLVMTypeRef sym_struct_type(struct symbol *sym)
 {
 	LLVMTypeRef elem_types[MAX_STRUCT_MEMBERS];
 	struct symbol *member;
+	char buffer[256];
+	LLVMTypeRef ret;
 	unsigned nr = 0;
 
+	sprintf(buffer, "%.*s", sym->ident->len, sym->ident->name);
+
+	ret = LLVMStructCreateNamed(LLVMGetGlobalContext(), buffer);
+
 	FOR_EACH_PTR(sym->symbol_list, member) {
+		LLVMTypeRef member_type;
+
 		assert(nr < MAX_STRUCT_MEMBERS);
 
-		elem_types[nr++] = symbol_type(member);
+		member_type = symbol_type(member);
+
+		elem_types[nr++] = member_type; 
 	} END_FOR_EACH_PTR(member);
 
-	return LLVMStructType(elem_types, nr, 0 /* packed? */);
+	LLVMStructSetBody(ret, elem_types, nr, 0 /* packed? */); 
+	return ret;
 }
 
 static LLVMTypeRef sym_ptr_type(struct symbol *sym)
-- 
1.7.6.4


^ permalink raw reply related


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.