All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: Ira Weiny <ira.weiny@intel.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Dan Williams <dan.j.williams@intel.com>,
	Jonathan Cameron <jonathan.cameron@huawei.com>
Cc: <linux-acpi@vger.kernel.org>, <linux-cxl@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Dan Carpenter <dan.carpenter@linaro.org>,
	"Ira Weiny" <ira.weiny@intel.com>
Subject: Re: [PATCH] acpi/ghes: Prevent sleeping with spinlock held
Date: Fri, 2 Feb 2024 10:58:08 -0800	[thread overview]
Message-ID: <65bd3b4073afd_7193229489@dwillia2-mobl3.amr.corp.intel.com.notmuch> (raw)
In-Reply-To: <20240202-cxl-cper-smatch-v1-1-7a4103c7f5a0@intel.com>

Ira Weiny wrote:
> Smatch caught that cxl_cper_post_event() is called with a spinlock held
> or preemption disabled.[1]  There is no need for the callback to sleep.
> 
> Replace the RW semaphore with a RW lock.
> 
> A static call was considered but ARM does not select HAVE_STATIC_CALL
> and in that case setting the function pointer uses a RW semaphore.
> 
> [1] https://lore.kernel.org/all/b963c490-2c13-4b79-bbe7-34c6568423c7@moroto.mountain/
> 
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
> ---
>  drivers/acpi/apei/ghes.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
> index 7b7c605166e0..bdc0ec2813a3 100644
> --- a/drivers/acpi/apei/ghes.c
> +++ b/drivers/acpi/apei/ghes.c
> @@ -39,6 +39,7 @@
>  #include <linux/aer.h>
>  #include <linux/nmi.h>
>  #include <linux/sched/clock.h>
> +#include <linux/spinlock.h>
>  #include <linux/uuid.h>
>  #include <linux/ras.h>
>  #include <linux/task_work.h>
> @@ -677,7 +678,7 @@ static void ghes_defer_non_standard_event(struct acpi_hest_generic_data *gdata,
>  /*
>   * Only a single callback can be registered for CXL CPER events.
>   */
> -static DECLARE_RWSEM(cxl_cper_rw_sem);
> +static DEFINE_RWLOCK(cxl_callback_lock);
>  static cxl_cper_callback cper_callback;
>  
>  /* CXL Event record UUIDs are formatted as GUIDs and reported in section type */
> @@ -721,14 +722,14 @@ static void cxl_cper_post_event(enum cxl_event_type event_type,
>  		return;
>  	}
>  
> -	guard(rwsem_read)(&cxl_cper_rw_sem);
> +	guard(read_lock_irqsave)(&cxl_callback_lock);
>  	if (cper_callback)
>  		cper_callback(event_type, rec);

This does not help because cxl_cper_event_call() takes a sleeping
device_lock().

      reply	other threads:[~2024-02-02 18:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-02 18:16 [PATCH] acpi/ghes: Prevent sleeping with spinlock held Ira Weiny
2024-02-02 18:58 ` Dan Williams [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=65bd3b4073afd_7193229489@dwillia2-mobl3.amr.corp.intel.com.notmuch \
    --to=dan.j.williams@intel.com \
    --cc=dan.carpenter@linaro.org \
    --cc=ira.weiny@intel.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@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 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.