Re: [PATCH v3 4/5] qla2xxx: Convert MAKE_HANDLE() from a define into an inline function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/20/20 12:21 AM, Daniel Wagner wrote:
On Wed, Feb 19, 2020 at 08:34:40PM -0800, Bart Van Assche wrote:
-#define MAKE_HANDLE(x, y) ((uint32_t)((((uint32_t)(x)) << 16) | (uint32_t)(y)))
+static inline uint32_t make_handle(uint16_t x, uint16_t y)
+{
+	return ((uint32_t)x << 16) | y;
+}
/*
   * I/O register
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 47bf60a9490a..1816660768da 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -530,7 +530,7 @@ __qla2x00_marker(struct scsi_qla_host *vha, struct qla_qpair *qpair,
  			int_to_scsilun(lun, (struct scsi_lun *)&mrk24->lun);
  			host_to_fcp_swap(mrk24->lun, sizeof(mrk24->lun));
  			mrk24->vp_index = vha->vp_idx;
-			mrk24->handle = MAKE_HANDLE(req->id, mrk24->handle);
+			mrk24->handle = make_handle(req->id, mrk24->handle);

The type of mrk24->handle is uint32_t and make_handle() is using type
uint16_t. Shouldn't the argument type for the y argument be uint32_t
as well?

Hi Daniel,

As one can see in __qla2x00_marker() a value is assigned to mrk24->handle() by __qla2x00_alloc_iocbs(). That function calls qla2xxx_get_next_handle() to determine the 'handle' value. The implementation of that last function is as follows:

uint32_t qla2xxx_get_next_handle(struct req_que *req)
{
	uint32_t index, handle = req->current_outstanding_cmd;

	for (index = 1; index < req->num_outstanding_cmds; index++) {
		handle++;
		if (handle == req->num_outstanding_cmds)
			handle = 1;
		if (!req->outstanding_cmds[handle])
			return handle;
	}

	return 0;
}

Since 'num_outstanding_cmds' is a 16-bit variable I think that guarantees that the code quoted in your e-mail passes a 16-bit value as the second argument to make_handle().

Additionally, if the second argument to make_handle() would be larger than 0x10000, the following code from qla2x00_status_entry() would map sts->handle to another queue and another command than those through wich the command was submitted to the firmware:

	handle = (uint32_t) LSW(sts->handle);
	que = MSW(sts->handle);
	req = ha->req_q_map[que];

Bart.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux