diff mbox series

[14/19] cxl/region: Clarify locking requirements of cxl_region_attach()

Message ID 168592157618.1948938.9911784721014622223.stgit@dwillia2-xfh.jf.intel.com
State New, archived
Headers show
Series cxl: Device memory setup | expand

Commit Message

Dan Williams June 4, 2023, 11:32 p.m. UTC
In preparation for cxl_region_attach() being called for kernel initiated
region creation, enforce the locking context with explicit lockdep
assertions.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/cxl/core/region.c |    3 +++
 1 file changed, 3 insertions(+)

Comments

Jonathan Cameron June 6, 2023, 2:35 p.m. UTC | #1
On Sun, 04 Jun 2023 16:32:56 -0700
Dan Williams <dan.j.williams@intel.com> wrote:

> In preparation for cxl_region_attach() being called for kernel initiated
> region creation, enforce the locking context with explicit lockdep
> assertions.
> 
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Dave Jiang June 13, 2023, 11:45 p.m. UTC | #2
On 6/4/23 16:32, Dan Williams wrote:
> In preparation for cxl_region_attach() being called for kernel initiated
> region creation, enforce the locking context with explicit lockdep
> assertions.
> 
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>

> ---
>   drivers/cxl/core/region.c |    3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 4d8dbfedd64a..defc2f0e43e3 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -1587,6 +1587,9 @@ static int cxl_region_attach(struct cxl_region *cxlr,
>   	struct cxl_dport *dport;
>   	int rc = -ENXIO;
>   
> +	lockdep_assert_held_write(&cxl_region_rwsem);
> +	lockdep_assert_held_read(&cxl_dpa_rwsem);
> +
>   	if (cxled->mode != cxlr->mode) {
>   		dev_dbg(&cxlr->dev, "%s region mode: %d mismatch: %d\n",
>   			dev_name(&cxled->cxld.dev), cxlr->mode, cxled->mode);
>
diff mbox series

Patch

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 4d8dbfedd64a..defc2f0e43e3 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -1587,6 +1587,9 @@  static int cxl_region_attach(struct cxl_region *cxlr,
 	struct cxl_dport *dport;
 	int rc = -ENXIO;
 
+	lockdep_assert_held_write(&cxl_region_rwsem);
+	lockdep_assert_held_read(&cxl_dpa_rwsem);
+
 	if (cxled->mode != cxlr->mode) {
 		dev_dbg(&cxlr->dev, "%s region mode: %d mismatch: %d\n",
 			dev_name(&cxled->cxld.dev), cxlr->mode, cxled->mode);