Re: [RFC PATCH v2 07/14] cxl/mem: Implement polled mode mailbox
From: Ben Widawsky <hidden>
Date: 2021-01-07 19:06:26
Also in:
linux-cxl, linux-pci, lkml
From: Ben Widawsky <hidden>
Date: 2021-01-07 19:06:26
Also in:
linux-cxl, linux-pci, lkml
On 20-12-08 16:24:11, Ben Widawsky wrote: [snip]
+static int cxl_mem_mbox_send_cmd(struct cxl_mem *cxlm,
+ struct mbox_cmd *mbox_cmd)
+{
+ u64 cmd, status;
+ size_t out_len;
+ int rc;
+
+ lockdep_assert_held(&cxlm->mbox_lock);
+
+ /*
+ * Here are the steps from 8.2.8.4 of the CXL 2.0 spec.
+ * 1. Caller reads MB Control Register to verify doorbell is clear
+ * 2. Caller writes Command Register
+ * 3. Caller writes Command Payload Registers if input payload is non-empty
+ * 4. Caller writes MB Control Register to set doorbell
+ * 5. Caller either polls for doorbell to be clear or waits for interrupt if configured
+ * 6. Caller reads MB Status Register to fetch Return code
+ * 7. If command successful, Caller reads Command Register to get Payload Length
+ * 8. If output payload is non-empty, host reads Command Payload Registers
+ */
+
+ /* #1 */
+ WARN_ON(cxl_doorbell_busy(cxlm));
+
+ /* #2 */
+ cxl_write_mbox_reg64(cxlm, CXLDEV_MB_CMD_OFFSET, mbox_cmd->opcode);
+
+ if (mbox_cmd->size_in) {
+ /* #3 */
+ CXL_SET_FIELD(mbox_cmd->size_in, CXLDEV_MB_CMD_PAYLOAD_LENGTH);
+ cxl_mbox_payload_fill(cxlm, mbox_cmd->payload,
+ mbox_cmd->size_in);
+ }There is a bug here where the payload length isn't written on input. It was working in v1. It will be fixed in v3. [snip]