LinuxPPC-Dev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] powerpc/opal_elog: Handle multiple writes to ack attribute
@ 2020-10-14  6:48 Aneesh Kumar K.V
  2020-10-14  7:14 ` Mahesh J Salgaonkar
  2020-10-16 11:32 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Aneesh Kumar K.V @ 2020-10-14  6:48 UTC (permalink / raw)
  To: linuxppc-dev, mpe
  Cc: Aneesh Kumar K.V, Oliver O'Halloran, Mahesh Salgaonkar

Even though we use self removing sysfs helper, we still need
to make sure we do the final kobject delete conditionally.
sysfs_remove_file_self() will handle parallel calls to remove
the sysfs attribute file and returns true only in the caller
that removed the attribute file. The other parallel callers
are returned false. Do the final kobject delete checking
the return value of sysfs_remove_file_self().

Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Cc: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
 arch/powerpc/platforms/powernv/opal-elog.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/opal-elog.c b/arch/powerpc/platforms/powernv/opal-elog.c
index 5e33b1fc67c2..37b380eef41a 100644
--- a/arch/powerpc/platforms/powernv/opal-elog.c
+++ b/arch/powerpc/platforms/powernv/opal-elog.c
@@ -72,9 +72,14 @@ static ssize_t elog_ack_store(struct elog_obj *elog_obj,
 			      const char *buf,
 			      size_t count)
 {
-	opal_send_ack_elog(elog_obj->id);
-	sysfs_remove_file_self(&elog_obj->kobj, &attr->attr);
-	kobject_put(&elog_obj->kobj);
+	/*
+	 * Try to self remove this attribute. If we are successful,
+	 * delete the kobject itself.
+	 */
+	if (sysfs_remove_file_self(&elog_obj->kobj, &attr->attr)) {
+		opal_send_ack_elog(elog_obj->id);
+		kobject_put(&elog_obj->kobj);
+	}
 	return count;
 }
 
-- 
2.26.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc/opal_elog: Handle multiple writes to ack attribute
  2020-10-14  6:48 [PATCH] powerpc/opal_elog: Handle multiple writes to ack attribute Aneesh Kumar K.V
@ 2020-10-14  7:14 ` Mahesh J Salgaonkar
  2020-10-16 11:32 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Mahesh J Salgaonkar @ 2020-10-14  7:14 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: Oliver O'Halloran, linuxppc-dev

On 2020-10-14 12:18:13 Wed, Aneesh Kumar K.V wrote:
> Even though we use self removing sysfs helper, we still need
> to make sure we do the final kobject delete conditionally.
> sysfs_remove_file_self() will handle parallel calls to remove
> the sysfs attribute file and returns true only in the caller
> that removed the attribute file. The other parallel callers
> are returned false. Do the final kobject delete checking
> the return value of sysfs_remove_file_self().
> 
> Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
> Cc: Oliver O'Halloran <oohall@gmail.com>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> ---
>  arch/powerpc/platforms/powernv/opal-elog.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/powernv/opal-elog.c b/arch/powerpc/platforms/powernv/opal-elog.c
> index 5e33b1fc67c2..37b380eef41a 100644
> --- a/arch/powerpc/platforms/powernv/opal-elog.c
> +++ b/arch/powerpc/platforms/powernv/opal-elog.c
> @@ -72,9 +72,14 @@ static ssize_t elog_ack_store(struct elog_obj *elog_obj,
>  			      const char *buf,
>  			      size_t count)
>  {
> -	opal_send_ack_elog(elog_obj->id);
> -	sysfs_remove_file_self(&elog_obj->kobj, &attr->attr);
> -	kobject_put(&elog_obj->kobj);
> +	/*
> +	 * Try to self remove this attribute. If we are successful,
> +	 * delete the kobject itself.
> +	 */
> +	if (sysfs_remove_file_self(&elog_obj->kobj, &attr->attr)) {
> +		opal_send_ack_elog(elog_obj->id);
> +		kobject_put(&elog_obj->kobj);
> +	}
>  	return count;
>  }

Looks good.

Reviewed-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>

Thanks,
-Mahesh.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc/opal_elog: Handle multiple writes to ack attribute
  2020-10-14  6:48 [PATCH] powerpc/opal_elog: Handle multiple writes to ack attribute Aneesh Kumar K.V
  2020-10-14  7:14 ` Mahesh J Salgaonkar
@ 2020-10-16 11:32 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2020-10-16 11:32 UTC (permalink / raw)
  To: mpe, Aneesh Kumar K.V, linuxppc-dev
  Cc: Oliver O'Halloran, Mahesh Salgaonkar

On Wed, 14 Oct 2020 12:18:13 +0530, Aneesh Kumar K.V wrote:
> Even though we use self removing sysfs helper, we still need
> to make sure we do the final kobject delete conditionally.
> sysfs_remove_file_self() will handle parallel calls to remove
> the sysfs attribute file and returns true only in the caller
> that removed the attribute file. The other parallel callers
> are returned false. Do the final kobject delete checking
> the return value of sysfs_remove_file_self().

Applied to powerpc/fixes.

[1/1] powerpc/opal_elog: Handle multiple writes to ack attribute
      https://git.kernel.org/powerpc/c/d4263b12a1a0e8816e021450be0765a1ad8bb53c

cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-14  6:48 [PATCH] powerpc/opal_elog: Handle multiple writes to ack attribute Aneesh Kumar K.V
2020-10-14  7:14 ` Mahesh J Salgaonkar
2020-10-16 11:32 ` Michael Ellerman

LinuxPPC-Dev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linuxppc-dev/0 linuxppc-dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linuxppc-dev linuxppc-dev/ https://lore.kernel.org/linuxppc-dev \
		linuxppc-dev@lists.ozlabs.org linuxppc-dev@ozlabs.org
	public-inbox-index linuxppc-dev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.ozlabs.lists.linuxppc-dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git