From: Randy Dunlap <rdunlap@infradead.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Markus Grabner <grabner@icg.tugraz.at>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] staging: line6: avoid __sync_fetch_and_{and,or}
Date: Fri, 21 Jun 2013 15:24:20 -0700 [thread overview]
Message-ID: <51C4D294.5060909@infradead.org> (raw)
In-Reply-To: <201306212155.36196.arnd@arndb.de>
On 06/21/13 12:55, Arnd Bergmann wrote:
> __sync_fetch_and_and and __sync_fetch_and_or are functions that are provided
> by gcc and depending on the target architecture may be implemented in libgcc,
> which is not always available in the kernel. This leads to a build failure
> on ARMv5:
and on x86_64.
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Thanks.
>
> drivers/built-in.o: In function `line6_pcm_release':
> :(.text+0x3bfe80): undefined reference to `__sync_fetch_and_and_4'
> drivers/built-in.o: In function `line6_pcm_acquire':
> :(.text+0x3bff30): undefined reference to `__sync_fetch_and_or_4'
>
> To work around this, we can use the kernel-provided cmpxchg macro.
>
> Build-tested only.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Markus Grabner <grabner@icg.tugraz.at>
>
> diff --git a/drivers/staging/line6/pcm.c b/drivers/staging/line6/pcm.c
> index 02f77d7..4795f12 100644
> --- a/drivers/staging/line6/pcm.c
> +++ b/drivers/staging/line6/pcm.c
> @@ -107,11 +107,15 @@ static bool test_flags(unsigned long flags0, unsigned long flags1,
>
> int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels)
> {
> - unsigned long flags_old =
> - __sync_fetch_and_or(&line6pcm->flags, channels);
> - unsigned long flags_new = flags_old | channels;
> - unsigned long flags_final = flags_old;
> - int err = 0;
> + unsigned long flags_old, flags_new, flags_final;
> + int err;
> +
> + do {
> + flags_old = ACCESS_ONCE(line6pcm->flags);
> + flags_new = flags_old | channels;
> + } while (cmpxchg(&line6pcm->flags, flags_old, flags_new) != flags_old);
> +
> + flags_final = flags_old;
>
> line6pcm->prev_fbuf = NULL;
>
> @@ -197,9 +201,12 @@ pcm_acquire_error:
>
> int line6_pcm_release(struct snd_line6_pcm *line6pcm, int channels)
> {
> - unsigned long flags_old =
> - __sync_fetch_and_and(&line6pcm->flags, ~channels);
> - unsigned long flags_new = flags_old & ~channels;
> + unsigned long flags_old, flags_new;
> +
> + do {
> + flags_old = ACCESS_ONCE(line6pcm->flags);
> + flags_new = flags_old & ~channels;
> + } while (cmpxchg(&line6pcm->flags, flags_old, flags_new) != flags_old);
>
> if (test_flags(flags_new, flags_old, LINE6_BITS_CAPTURE_STREAM))
> line6_unlink_audio_in_urbs(line6pcm);
> --
--
~Randy
prev parent reply other threads:[~2013-06-21 22:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-21 19:55 Arnd Bergmann
2013-06-21 22:24 ` Randy Dunlap [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51C4D294.5060909@infradead.org \
--to=rdunlap@infradead.org \
--cc=arnd@arndb.de \
--cc=grabner@icg.tugraz.at \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome