diff mbox series

[RFC,02/11] nvmet: Export nvmet_add_async_event and add definitions

Message ID 20250313052222.178524-3-michael.christie@oracle.com (mailing list archive)
State New
Headers show
Series nvmet: Add NVMe target mdev/vfio driver | expand

Commit Message

Mike Christie March 13, 2025, 5:18 a.m. UTC
This exports nvmet_add_async_event and adds some AER definitions that
will be used by the nvmet_mdev_pci driver.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/nvme/target/core.c | 1 +
 include/linux/nvme.h       | 2 ++
 2 files changed, 3 insertions(+)

Comments

Christoph Hellwig March 13, 2025, 6:36 a.m. UTC | #1
On Thu, Mar 13, 2025 at 12:18:03AM -0500, Mike Christie wrote:
> This exports nvmet_add_async_event and adds some AER definitions that
> will be used by the nvmet_mdev_pci driver.

Can you add a little explanation why mdev needs it by pci-epf not?
Mike Christie March 13, 2025, 5:50 p.m. UTC | #2
On 3/13/25 1:36 AM, Christoph Hellwig wrote:
> On Thu, Mar 13, 2025 at 12:18:03AM -0500, Mike Christie wrote:
>> This exports nvmet_add_async_event and adds some AER definitions that
>> will be used by the nvmet_mdev_pci driver.
> 
> Can you add a little explanation why mdev needs it by pci-epf not?
> 

It's due to how the drivers handle NVME_REG_DBS. The mdev driver
registers a callback where when we get a write to the memory at
NVME_REG_DBS + N, the callback is run. If we get:

NVME_REG_DBS + ... some invalid queue

we were going to send a NVME_AER_ERROR_INVALID_DB_REG.

The pci-epf driver just checks the specific queues:

sq->db = NVME_REG_DBS + (sqid * 2 * sizeof(u32));
...
sq->tail = nvmet_pci_epf_bar_read32(ctrl, sq->db);
while (sq->tail ...) {

so doesn't see if the host where to do a invalid write.
diff mbox series

Patch

diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index f896d1fd3326..4de534eafd89 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -214,6 +214,7 @@  void nvmet_add_async_event(struct nvmet_ctrl *ctrl, u8 event_type,
 
 	queue_work(nvmet_wq, &ctrl->async_event_work);
 }
+EXPORT_SYMBOL_GPL(nvmet_add_async_event);
 
 static void nvmet_add_to_changed_ns_log(struct nvmet_ctrl *ctrl, __le32 nsid)
 {
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 2dc05b1c3283..a7b8bcef20fb 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -806,6 +806,8 @@  enum {
 };
 
 enum {
+	NVME_AER_ERROR_INVALID_DB_REG	= 0x00,
+	NVME_AER_ERROR_INVALID_DB_VALUE = 0x01,
 	NVME_AER_ERROR_PERSIST_INT_ERR	= 0x03,
 };