All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Dmitriy Cherkasov <dmitriy@mperpetuo.com>
Cc: "xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai] xenomai/ipipe arm64 port
Date: Fri, 2 Oct 2015 13:55:00 +0200	[thread overview]
Message-ID: <20151002115500.GP31137@hermes.click-hack.org> (raw)
In-Reply-To: <20151002100142.GN31137@hermes.click-hack.org>

On Fri, Oct 02, 2015 at 12:01:42PM +0200, Gilles Chanteperdrix wrote:
> On Thu, Oct 01, 2015 at 04:51:51PM -0700, Dmitriy Cherkasov wrote:
> > The following changes since commit 17095784c6d3d44dc7f1512ffab9bb957e298466:
> > 
> >    cobalt/arm64: leave mm tracking to the pipeline (2015-09-17 15:08:34 
> > +0200)
> > 
> > are available in the git repository at:
> > 
> >    http://gitlab.mperpetuo.com/it/xenomai-3.git arm64-fp
> 
> Ok, I retrieved your code, some comments inlined:
> 
> > /*
> > static void enable_fpsimd(void) {
> > 	__asm__ __volatile__("mrs x1, cpacr_el1\n\
> > 			orr x1, x1, #(0x3 << 20)\n\
> > 			msr cpacr_el1, x1\n\
> > 			isb" : : : "x1", "memory", "cc");
> > }
> 
> > static void disable_fpsimd(void) {
> > 	__asm__ __volatile__("mrs x1, cpacr_el1\n\
> > 				and x1, x1, #~(0x3 << 20)\n\
> > 				msr cpacr_el1, x1\n\
> > 				isb" : : : "x1", "memory", "cc");
> > }
> 
> Coding style: braces at the beginning of line, and you probably want to
> make these functions inline.

Also, hardcoding a register may not be a good idea. Especially x1,
since if I understand correctly, it is used as function argument, so
by using x1, you may be forcing the compiler to do some useless
register saves and load. And also, the only instructions which
requires inline assembley are msr, mrs, and isb.

So, I would do something like:

static inline long get_cpacr(void)
{
	long result;
	__asm__ ("mrs %0, cpacr_el1": "=r"(result) : /* */ : "memory", "cc");
	return result;
}

static inline set_cpacr(long val)
{
	__asm__ __volatile__ (
		"msr cpacr_el1, %0\n\"
		"isb" : /* */ : "r"(val) : "memory", "cc");
}

then define enable_fpsimd/disable_fpsimd in plain C, using these
building blocks. Also, I do not see why these instructions require
clobbering memory and cc, but here you know better than I do.

-- 
					    Gilles.
https://click-hack.org


  reply	other threads:[~2015-10-02 11:55 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-25  0:13 [Xenomai] xenomai/ipipe arm64 port Don Mahurin
2015-08-25 14:08 ` Philippe Gerum
2015-08-25 15:20   ` Jorge Ramirez Ortiz
2015-08-25 16:13     ` Jan Kiszka
2015-08-25 17:07       ` Jorge Ramirez Ortiz
2015-08-25 17:34         ` Jorge Ramirez Ortiz
2015-08-25 17:36           ` Jan Kiszka
2015-08-25 17:54             ` Jorge Ramirez Ortiz
2015-08-25 18:03               ` Jan Kiszka
2015-08-25 17:34         ` Jan Kiszka
2015-08-25 18:02           ` Jorge Ramirez Ortiz
2015-08-25 18:05   ` Don Mahurin
2015-08-25 18:34     ` Jorge Ramirez Ortiz
2015-08-25 18:36     ` Jan Kiszka
2015-08-25 18:43     ` Philippe Gerum
2015-08-25 18:52   ` Gilles Chanteperdrix
2015-08-26 14:40 ` Jorge Ramirez Ortiz
2015-08-26 16:30   ` Don Mahurin
2015-08-27 17:07 ` Jorge Ramirez Ortiz
2015-08-27 21:56   ` Don Mahurin
2015-09-01 17:45 ` Jorge Ramirez Ortiz
     [not found]   ` <CAPuu0=jX6ig5L7SJrmPVOhCmOm=gwxEmTafTpOqzE85hOji8CA@mail.gmail.com>
2015-09-01 19:11     ` Jorge Ramirez Ortiz
2015-09-01 19:24       ` Philippe Gerum
2015-09-01 20:14         ` Jorge Ramirez Ortiz
2015-09-01 21:02           ` Hongfei Cheng
2015-09-02  0:43           ` Don Mahurin
2015-09-07 16:03             ` Philippe Gerum
2015-09-24 19:39             ` Dmitriy Cherkasov
2015-09-25 15:02               ` Gilles Chanteperdrix
2015-09-25 17:14                 ` Dmitriy Cherkasov
2015-09-25 18:01                   ` Gilles Chanteperdrix
2015-09-26 11:24                     ` Gilles Chanteperdrix
2015-09-28 23:57                       ` Dmitriy Cherkasov
2015-09-29  0:12                         ` Gilles Chanteperdrix
2015-09-29 12:54                           ` Jorge Ramirez Ortiz
2015-09-29 17:31                             ` Dmitriy Cherkasov
2015-09-29 17:47                               ` Gilles Chanteperdrix
2015-09-29 20:17                                 ` Jorge Ramirez Ortiz
2015-09-29 17:05                           ` Don Mahurin
2015-09-29 14:14                         ` Lennart Sorensen
2015-09-29 20:49                           ` Gilles Chanteperdrix
2015-10-01 23:51                             ` Dmitriy Cherkasov
2015-10-02 10:01                               ` Gilles Chanteperdrix
2015-10-02 11:55                                 ` Gilles Chanteperdrix [this message]
2015-10-02 20:18                                   ` Dmitriy Cherkasov
2015-10-03  9:53                                     ` Philippe Gerum
2015-10-03 10:01                                       ` Philippe Gerum
2015-10-03 10:05                                         ` Philippe Gerum
2015-09-01 19:30       ` Philippe Gerum
2015-09-01 20:47         ` Jorge Ramirez Ortiz
2015-09-01 19:44       ` Gilles Chanteperdrix

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=20151002115500.GP31137@hermes.click-hack.org \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=dmitriy@mperpetuo.com \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.