Linux CXL
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: <alison.schofield@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Ben Widawsky <bwidawsk@kernel.org>,
	Dave Jiang <dave.jiang@intel.com>, <linux-cxl@vger.kernel.org>
Subject: Re: [PATCH 4/5] tools/testing/cxl: Mock the Clear Poison mailbox command
Date: Wed, 30 Nov 2022 15:01:33 +0000	[thread overview]
Message-ID: <20221130150133.0000310c@Huawei.com> (raw)
In-Reply-To: <be25fbaea1dd583b22bb71748331a2b76d0dd62e.1669781852.git.alison.schofield@intel.com>

On Tue, 29 Nov 2022 20:34:36 -0800
alison.schofield@intel.com wrote:

> From: Alison Schofield <alison.schofield@intel.com>
> 
> Mock the clear of poison by deleting the device:address entry from
> the cxl_test array: mock_poison[]. Behave like a real CXL device and do
> not fail if the address is not in the poison list, but offer a dev_dbg()
> message.
> 
> Unlike a real CXL device, no data is written to the address being cleared.
> 
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Trivial comment inline. Subject to comment on previous patch about
doing per device injected poison lists...

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  tools/testing/cxl/test/mem.c | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c
> index 98acb9a644df..9d794fbe5ee1 100644
> --- a/tools/testing/cxl/test/mem.c
> +++ b/tools/testing/cxl/test/mem.c
> @@ -48,6 +48,10 @@ static struct cxl_cel_entry mock_cel[] = {
>  		.opcode = cpu_to_le16(CXL_MBOX_OP_INJECT_POISON),
>  		.effect = cpu_to_le16(0),
>  	},
> +	{
> +		.opcode = cpu_to_le16(CXL_MBOX_OP_CLEAR_POISON),
> +		.effect = cpu_to_le16(0),
> +	},
>  };
>  
>  /* See CXL 2.0 Table 181 Get Health Info Output Payload */
> @@ -244,6 +248,35 @@ static bool mock_poison_found(struct cxl_dev_state *cxlds, u64 dpa)
>  	return false;
>  }
>  
> +static bool mock_poison_del(struct cxl_dev_state *cxlds, u64 dpa)
> +{
> +	for (int i = 0; i < MOCK_INJECT_POISON_MAX; i++) {
> +		if (mock_poison[i].cxlds == cxlds &&
> +		    mock_poison[i].dpa == dpa) {
> +			mock_poison[i].cxlds = NULL;
> +			return true;
> +		}
> +	}
> +	return false;
> +}
> +
> +static int mock_clear_poison(struct cxl_dev_state *cxlds,
> +			     struct cxl_mbox_cmd *cmd)
> +{
> +	struct cxl_mbox_clear_poison *pi = cmd->payload_in;
> +

Odd blank line. I'd put it after the next line instead.

> +	u64 dpa = le64_to_cpu(pi->address);
> +	/*
> +	 * A real CXL device will write pi->write_data to the address
> +	 * being cleared. In this mock, just delete this address from
> +	 * the mock poison list.
> +	 */
> +	if (!mock_poison_del(cxlds, dpa))
> +		dev_dbg(cxlds->dev, "DPA: 0x%llx not in poison list\n", dpa);
> +
> +	return 0;
> +}
> +
>  static int mock_inject_poison(struct cxl_dev_state *cxlds,
>  			      struct cxl_mbox_cmd *cmd)
>  {
> @@ -321,6 +354,9 @@ static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *
>  	case CXL_MBOX_OP_INJECT_POISON:
>  		rc = mock_inject_poison(cxlds, cmd);
>  		break;
> +	case CXL_MBOX_OP_CLEAR_POISON:
> +		rc = mock_clear_poison(cxlds, cmd);
> +		break;
>  	default:
>  		break;
>  	}


  reply	other threads:[~2022-11-30 15:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30  4:34 [PATCH 0/5] cxl: CXL Inject & Clear Poison alison.schofield
2022-11-30  4:34 ` [PATCH 1/5] cxl/memdev: Add support for the Inject Poison mailbox command alison.schofield
2022-11-30 14:31   ` Jonathan Cameron
2022-11-30 14:40     ` Jonathan Cameron
2022-12-01 16:42       ` Dave Jiang
2022-12-08  4:20         ` Alison Schofield
2022-12-01 17:26   ` Dave Jiang
2022-12-08  4:17     ` Alison Schofield
2022-12-04 22:04   ` Dan Williams
2022-12-08  4:16     ` Alison Schofield
2022-11-30  4:34 ` [PATCH 2/5] cxl/memdev: Add support for the Clear " alison.schofield
2022-11-30 14:43   ` Jonathan Cameron
2022-12-01 20:14     ` Alison Schofield
2022-12-01 17:54   ` Dave Jiang
2022-12-01 20:09     ` Alison Schofield
2022-11-30  4:34 ` [PATCH 3/5] tools/testing/cxl: Mock the Inject " alison.schofield
2022-11-30 14:58   ` Jonathan Cameron
2022-12-08  4:47     ` Alison Schofield
2022-12-08 14:53       ` Jonathan Cameron
2022-11-30  4:34 ` [PATCH 4/5] tools/testing/cxl: Mock the Clear " alison.schofield
2022-11-30 15:01   ` Jonathan Cameron [this message]
2022-11-30  4:34 ` [PATCH 5/5] tools/testing/cxl: Use injected poison for Get Poison List alison.schofield
2022-11-30 15:15   ` Jonathan Cameron
2022-12-08  4:30     ` Alison Schofield
2022-12-08 14:54       ` Jonathan Cameron

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=20221130150133.0000310c@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=alison.schofield@intel.com \
    --cc=bwidawsk@kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=vishal.l.verma@intel.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