linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Lynch <nathanl@linux.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>,
	Laurent Dufour <ldufour@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org
Cc: ajd@linux.ibm.com, npiggin@gmail.com
Subject: Re: [PATCH] powerpc/rtas: upgrade internal arch spinlocks
Date: Tue, 17 Jan 2023 10:44:16 -0600	[thread overview]
Message-ID: <87ilh55cwv.fsf@linux.ibm.com> (raw)
In-Reply-To: <87k01n9vo7.fsf@mpe.ellerman.id.au>

Michael Ellerman <mpe@ellerman.id.au> writes:
> Nathan Lynch <nathanl@linux.ibm.com> writes:
>> Laurent Dufour <ldufour@linux.ibm.com> writes:
>>> On 10/01/2023 05:42:55, Nathan Lynch wrote:
>>>> --- a/arch/powerpc/include/asm/rtas-types.h
>>>> +++ b/arch/powerpc/include/asm/rtas-types.h
>>>> @@ -18,7 +18,7 @@ struct rtas_t {
>>>>  	unsigned long entry;		/* physical address pointer */
>>>>  	unsigned long base;		/* physical address pointer */
>>>>  	unsigned long size;
>>>> -	arch_spinlock_t lock;
>>>> +	raw_spinlock_t lock;
>>>>  	struct rtas_args args;
>>>>  	struct device_node *dev;	/* virtual address pointer */
>>>>  };
>>>> diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
>>>> index deded51a7978..a834726f18e3 100644
>>>> --- a/arch/powerpc/kernel/rtas.c
>>>> +++ b/arch/powerpc/kernel/rtas.c
>>>> @@ -61,7 +61,7 @@ static inline void do_enter_rtas(unsigned long args)
>>>>  }
>>>>  
>>>>  struct rtas_t rtas = {
>>>> -	.lock = __ARCH_SPIN_LOCK_UNLOCKED
>>>> +	.lock = __RAW_SPIN_LOCK_UNLOCKED(rtas.lock),
>>>>  };
>>>>  EXPORT_SYMBOL(rtas);
>>>
>>> This is not the scope of this patch, but the RTAS's lock is externalized
>>> through the structure rtas_t, while it is only used in that file.
>>>
>>> I think, this would be good, in case of future change about that lock, and
>>> in order to not break KABI, to move it out of that structure, and to define
>>> it statically in that file.
>>
>> Thanks for pointing this out.
>>
>> /* rtas-types.h */
>> struct rtas_t {
>> 	unsigned long entry;		/* physical address pointer */
>> 	unsigned long base;		/* physical address pointer */
>> 	unsigned long size;
>> 	raw_spinlock_t lock;
>> 	struct rtas_args args;
>> 	struct device_node *dev;	/* virtual address pointer */
>> };
>>
>> /* rtas.h */
>> extern struct rtas_t rtas;
>>
>> There's C and asm code outside of rtas.c that accesses rtas.entry,
>> rtas.base, rtas.size, and rtas.dev. But as you say, rtas.lock is used
>> only in rtas.c, and it's hard to imagine any legitimate external
>> use. This applies to the args member as well, since accesses must occur
>> under the lock.
>>
>> Making the lock and args private to rtas.c seems desirable on its own,
>> so I think that should be done first as a cleanup, followed by the
>> riskier arch -> raw lock conversion.
>
> I don't see any reason why `rtas` is exported at all.
>
> There might have been in the past, but I don't see one any more.
>
> So I'd be happy if we removed the EXPORT entirely. If it breaks
> something we can always put it back.

Agreed, I see no accesses of the rtas struct from code that can be built
as a module, and we can introduce nicer accessor functions in the future
if need arises. I will incorporate removal of EXPORT_SYMBOL(rtas).

      reply	other threads:[~2023-01-17 16:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10  4:42 [PATCH] powerpc/rtas: upgrade internal arch spinlocks Nathan Lynch
2023-01-12 15:17 ` Laurent Dufour
2023-01-12 17:25   ` Nathan Lynch
2023-01-16  0:20     ` Michael Ellerman
2023-01-17 16:44       ` Nathan Lynch [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=87ilh55cwv.fsf@linux.ibm.com \
    --to=nathanl@linux.ibm.com \
    --cc=ajd@linux.ibm.com \
    --cc=ldufour@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).