Skip to contentSkip to conversation

scsi: fnic: Annotate fnic_nvme functions with __must_hold()

PATCH Applied Bart Van Assche 3 participants 4 messages Oct 18 – Oct 29

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: fnic: Annotate fnic_nvme functions with __must_hold()

Add __must_hold() annotations for fnic_lock to nvfnic_process_ls_abts_rsp(), nvfnic_ls_rsp_recv(), nvfnic_delete_tport(), and nvfnic_add_tport() in drivers/scsi/fnic/fnic_nvme.c.

Document that callers must hold fnic_lock on entry and exit because these functions temporarily release and reacquire fnic_lock, and suppress context imbalance warnings reported by lock context analysis and sparse.

---
 drivers/scsi/fnic/fnic_nvme.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/scsi/fnic/fnic_nvme.c +4 -0
index 00d9d5d439a3..d1b327c5c5e0 100644
@@ -1284,6 +1284,7 @@ void nvfnic_fcpio_cmpl(struct fnic_io_req *io_req)
 
 void nvfnic_process_ls_abts_rsp(struct fnic_iport_s *iport,
 		struct fc_frame_header *fchdr)
+	__must_hold(&iport->fnic->fnic_lock)
 {
 	uint32_t tport_fcid;
 	struct fnic_tport_s *tport;
@@ -1348,6 +1349,7 @@ void nvfnic_process_ls_abts_rsp(struct fnic_iport_s *iport,
  */
 void nvfnic_ls_rsp_recv(struct fnic_iport_s *iport,
 		struct fc_frame_header *fchdr, int len)
+	__must_hold(&iport->fnic->fnic_lock)
 {
 	uint8_t *fcid;
 	uint32_t tport_fcid;
@@ -2086,6 +2088,7 @@ void nvfnic_exch_reset(struct fnic_iport_s *iport, struct fnic_tport_s *tport)
 void nvfnic_delete_tport(struct fnic_iport_s *iport,
 						struct fnic_tport_s *tport,
 						unsigned long flags)
+	__must_hold(&iport->fnic->fnic_lock)
 {
 	struct fnic *fnic = iport->fnic;
 	int ret;
@@ -2179,6 +2182,7 @@ void nvfnic_delete_tport(struct fnic_iport_s *iport,
 
 int nvfnic_add_tport(struct fnic *fnic, struct fnic_tport_s *tport,
 		     unsigned long flags)
+	__must_hold(&fnic->fnic_lock)
 {
 	struct fnic_iport_s *iport = &fnic->iport;
 	struct nvme_fc_port_info pinfo;
Tested-by on v1 1/1
#1 lore raw
Quoted 5 lines · Bart Van Assche

Add __must_hold() annotations for fnic_lock to nvfnic_process_ls_abts_rsp(), nvfnic_ls_rsp_recv(), nvfnic_delete_tport(), and nvfnic_add_tport() in drivers/scsi/fnic/fnic_nvme.c.

Quoted 8 lines

Document that callers must hold fnic_lock on entry and exit because these functions temporarily release and reacquire fnic_lock, and suppress context imbalance warnings reported by lock context analysis and sparse.

Quoted 40 lines
---
 drivers/scsi/fnic/fnic_nvme.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/scsi/fnic/fnic_nvme.c +4 -0
index 00d9d5d439a3..d1b327c5c5e0 100644
@@ -1284,6 +1284,7 @@ void nvfnic_fcpio_cmpl(struct fnic_io_req *io_req)
 
 void nvfnic_process_ls_abts_rsp(struct fnic_iport_s *iport,
 		struct fc_frame_header *fchdr)
+	__must_hold(&iport->fnic->fnic_lock)
 {
 	uint32_t tport_fcid;
 	struct fnic_tport_s *tport;
@@ -1348,6 +1349,7 @@ void nvfnic_process_ls_abts_rsp(struct fnic_iport_s *iport,
  */
 void nvfnic_ls_rsp_recv(struct fnic_iport_s *iport,
 		struct fc_frame_header *fchdr, int len)
+	__must_hold(&iport->fnic->fnic_lock)
 {
 	uint8_t *fcid;
 	uint32_t tport_fcid;
@@ -2086,6 +2088,7 @@ void nvfnic_exch_reset(struct fnic_iport_s *iport, struct fnic_tport_s *tport)
 void nvfnic_delete_tport(struct fnic_iport_s *iport,
 						struct fnic_tport_s *tport,
 						unsigned long flags)
+	__must_hold(&iport->fnic->fnic_lock)
 {
 	struct fnic *fnic = iport->fnic;
 	int ret;
@@ -2179,6 +2182,7 @@ void nvfnic_delete_tport(struct fnic_iport_s *iport,
 
 int nvfnic_add_tport(struct fnic *fnic, struct fnic_tport_s *tport,
 		     unsigned long flags)
+	__must_hold(&fnic->fnic_lock)
 {
 	struct fnic_iport_s *iport = &fnic->iport;
 	struct nvme_fc_port_info pinfo;
Signature · 2 lines
Cheers,
Nathan
maintainer Applied
#2 lore raw
In reply to Bart Van Assche

Bart,

Quoted 4 lines

Add __must_hold() annotations for fnic_lock to nvfnic_process_ls_abts_rsp(), nvfnic_ls_rsp_recv(), nvfnic_delete_tport(), and nvfnic_add_tport() in drivers/scsi/fnic/fnic_nvme.c.

Applied to 7.4/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen
maintainer Applied
#3 lore raw
In reply to Bart Van Assche
Quoted 11 lines · Bart Van Assche

Add __must_hold() annotations for fnic_lock to nvfnic_process_ls_abts_rsp(), nvfnic_ls_rsp_recv(), nvfnic_delete_tport(), and nvfnic_add_tport() in drivers/scsi/fnic/fnic_nvme.c.

Document that callers must hold fnic_lock on entry and exit because these functions temporarily release and reacquire fnic_lock, and suppress context imbalance warnings reported by lock context analysis and sparse.

[...]

Applied to 7.4/scsi-queue, thanks!

[1/1] scsi: fnic: Annotate fnic_nvme functions with __must_hold()

      https://git.kernel.org/mkp/scsi/c/cd02f87668a8
Signature · 1 line
Martin K. Petersen