Skip to content

Commit

Permalink
scsi: megaraid_sas: Add 32 bit atomic descriptor support to AERO adap…
Browse files Browse the repository at this point in the history
…ters

Aero adapters provides Atomic Request Descriptor as an alternative method
for posting an entry onto a request queue. The posting of an Atomic Request
Descriptor is an atomic operation, providing a safe mechanism for multiple
processors on the host to post requests without synchronization. This
Atomic Request Descriptor format is identical to first 32 bits of Default
Request Descriptor and uses only 32 bits.

If Aero adapters support Atomic descriptor, driver should use it for
posting IOs and DCMDs to firmware.

Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Chandrakanth Patil authored and Martin K. Petersen committed Jun 27, 2019
1 parent 5f0bd87 commit 5885571
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
3 changes: 3 additions & 0 deletions drivers/scsi/megaraid/megaraid_sas.h
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,8 @@ enum FW_BOOT_CONTEXT {

#define MR_CAN_HANDLE_SYNC_CACHE_OFFSET 0X01000000

#define MR_ATOMIC_DESCRIPTOR_SUPPORT_OFFSET (1 << 24)

#define MR_CAN_HANDLE_64_BIT_DMA_OFFSET (1 << 25)

#define MEGASAS_WATCHDOG_THREAD_INTERVAL 1000
Expand Down Expand Up @@ -2395,6 +2397,7 @@ struct megasas_instance {
struct dentry *raidmap_dump;
#endif
u8 enable_fw_dev_list;
bool atomic_desc_support;
};
struct MR_LD_VF_MAP {
u32 size;
Expand Down
45 changes: 36 additions & 9 deletions drivers/scsi/megaraid/megaraid_sas_fusion.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,21 +277,17 @@ inline void megasas_return_cmd_fusion(struct megasas_instance *instance,
}

/**
* megasas_fire_cmd_fusion - Sends command to the FW
* @instance: Adapter soft state
* @req_desc: 64bit Request descriptor
*
* Perform PCI Write.
* megasas_write_64bit_req_desc - PCI writes 64bit request descriptor
* @instance: Adapter soft state
* @req_desc: 64bit Request descriptor
*/

static void
megasas_fire_cmd_fusion(struct megasas_instance *instance,
megasas_write_64bit_req_desc(struct megasas_instance *instance,
union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc)
{
#if defined(writeq) && defined(CONFIG_64BIT)
u64 req_data = (((u64)le32_to_cpu(req_desc->u.high) << 32) |
le32_to_cpu(req_desc->u.low));

writeq(req_data, &instance->reg_set->inbound_low_queue_port);
#else
unsigned long flags;
Expand All @@ -304,6 +300,25 @@ megasas_fire_cmd_fusion(struct megasas_instance *instance,
#endif
}

/**
* megasas_fire_cmd_fusion - Sends command to the FW
* @instance: Adapter soft state
* @req_desc: 32bit or 64bit Request descriptor
*
* Perform PCI Write. AERO SERIES supports 32 bit Descriptor.
* Prior to AERO_SERIES support 64 bit Descriptor.
*/
static void
megasas_fire_cmd_fusion(struct megasas_instance *instance,
union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc)
{
if (instance->atomic_desc_support)
writel(le32_to_cpu(req_desc->u.low),
&instance->reg_set->inbound_single_queue_port);
else
megasas_write_64bit_req_desc(instance, req_desc);
}

/**
* megasas_fusion_update_can_queue - Do all Adapter Queue depth related calculations here
* @instance: Adapter soft state
Expand Down Expand Up @@ -1171,7 +1186,8 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
break;
}

megasas_fire_cmd_fusion(instance, &req_desc);
/* For AERO also, IOC_INIT requires 64 bit descriptor write */
megasas_write_64bit_req_desc(instance, &req_desc);

wait_and_poll(instance, cmd, MFI_IO_TIMEOUT_SECS);

Expand All @@ -1181,6 +1197,17 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
goto fail_fw_init;
}

if (instance->adapter_type >= AERO_SERIES) {
scratch_pad_1 = megasas_readl
(instance, &instance->reg_set->outbound_scratch_pad_1);

instance->atomic_desc_support =
(scratch_pad_1 & MR_ATOMIC_DESCRIPTOR_SUPPORT_OFFSET) ? 1 : 0;

dev_info(&instance->pdev->dev, "FW supports atomic descriptor\t: %s\n",
instance->atomic_desc_support ? "Yes" : "No");
}

return 0;

fail_fw_init:
Expand Down

0 comments on commit 5885571

Please sign in to comment.