Skip to contentSkip to conversation

scsi: leapraid: Add new scsi driver

PATCH Superseded Hao Dongdong 2 participants 2 messages Nov 16, 2025 – Nov 18, 2025

Subsystems (3)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Hao Dongdong

author maintainer
#0 lore raw

PATCH v4 1/1 scsi: leapraid: Add new scsi driver

The LeapRAID driver provides support for LeapRAID PCIe RAID controllers, enabling communication between the host operating system, firmware, and hardware for efficient storage management.

The main source files are organized as follows:

leapraid_os.c:
Implements the scsi_host_template functions, PCIe device probing, and initialization routines, integrating the driver with the Linux SCSI subsystem.

leapraid_func.c:
Provides the core functional routines that handle low-level interactions with the controller firmware and hardware, including interrupt handling, topology management, and reset sequence processing, and other related operations.

leapraid_app.c:
Implements the ioctl interface, providing user-space tools access to device management and diagnostic operations.

leapraid_transport.c:
Interacts with the Linux SCSI transport layer to add SAS phys and ports.

leapraid_func.h:
Declares common data structures, constants, and function prototypes shared across the driver.

leapraid.h:
Provides global constants, register mappings, and interface definitions that facilitate communication between the driver and the controller firmware.

The leapraid_probe function is called when the driver detects a supported LeapRAID PCIe device. It allocates and initializes the Scsi_Host structure, configures hardware and firmware interfaces, and registers the host adapter with the Linux SCSI mid-layer.

After registration, the driver invokes scsi_scan_host() to initiate device discovery. The firmware then reports discovered logical and physical devices to the host through interrupt-driven events and synchronizes their operational states.

leapraid_adapter is the core data structure that encapsulates all resources and runtime state information maintained during driver operation, described as follows:

/**
* struct leapraid_adapter - Main LeapRaid adapter structure
* @list: List head for adapter management
* @shost: SCSI host structure
* @pdev: PCI device structure
* @iomem_base: I/O memory mapped base address
* @rep_msg_host_idx: Host index for reply messages
* @mask_int: Interrupt masking flag
* @timestamp_sync_cnt: Timestamp synchronization counter
* @adapter_attr: Adapter attributes
* @mem_desc: Memory descriptor
* @driver_cmds: Driver commands
* @dynamic_task_desc: Dynamic task descriptor
* @fw_evt_s: Firmware event structure
* @notification_desc: Notification descriptor
* @reset_desc: Reset descriptor
* @scan_dev_desc: Device scan descriptor
* @access_ctrl: Access control
* @fw_log_desc: Firmware log descriptor
* @dev_topo: Device topology
* @boot_devs: Boot devices
* @smart_poll_desc: SMART polling descriptor
*/

struct leapraid_adapter {
    struct list_head list;
    struct Scsi_Host *shost;
    struct pci_dev *pdev;
    struct leapraid_reg_base __iomem *iomem_base;
    u32 rep_msg_host_idx;
    bool mask_int;
    u32 timestamp_sync_cnt;

    struct leapraid_adapter_attr adapter_attr;
    struct leapraid_mem_desc mem_desc;
    struct leapraid_driver_cmds driver_cmds;
    struct leapraid_dynamic_task_desc dynamic_task_desc;
    struct leapraid_fw_evt_struct fw_evt_s;
    struct leapraid_notification_desc notification_desc;
    struct leapraid_reset_desc reset_desc;
    struct leapraid_scan_dev_desc scan_dev_desc;
    struct leapraid_access_ctrl access_ctrl;
    struct leapraid_fw_log_desc fw_log_desc;
    struct leapraid_dev_topo dev_topo;
    struct leapraid_boot_devs boot_devs;
    struct leapraid_smart_poll_desc smart_poll_desc;
};

Changes in v4:
- fix coding style issues across the LeapRAID driver
- refine commit messages and update leapraid.rst documentation
- Link to v3: https://lore.kernel.org/all/[email protected]/

Changes in v3:
- fix sparse warnings for writel() argument type mismatch
- Link to v2: https://lore.kernel.org/all/[email protected]/

Changes in v2:
- fix unused variable and undocumented struct member warnings
- refactor volume event handling and drive hotplug logic
- Link to v1: https://lore.kernel.org/all/[email protected]/

---
 Documentation/scsi/index.rst               |    1 +
 Documentation/scsi/leapraid.rst            |  137 +
 MAINTAINERS                                |    7 +
 drivers/scsi/Kconfig                       |    1 +
 drivers/scsi/Makefile                      |    1 +
 drivers/scsi/leapraid/Kconfig              |   14 +
 drivers/scsi/leapraid/Makefile             |   10 +
 drivers/scsi/leapraid/leapraid.h           | 2060 +++++
 drivers/scsi/leapraid/leapraid_app.c       |  686 ++
 drivers/scsi/leapraid/leapraid_func.c      | 8112 ++++++++++++++++++++
 drivers/scsi/leapraid/leapraid_func.h      | 1426 ++++
 drivers/scsi/leapraid/leapraid_os.c        | 2286 ++++++
 drivers/scsi/leapraid/leapraid_transport.c | 1250 +++
 13 files changed, 15991 insertions(+)
 create mode 100644 Documentation/scsi/leapraid.rst
 create mode 100644 drivers/scsi/leapraid/Kconfig
 create mode 100644 drivers/scsi/leapraid/Makefile
 create mode 100644 drivers/scsi/leapraid/leapraid.h
 create mode 100644 drivers/scsi/leapraid/leapraid_app.c
 create mode 100644 drivers/scsi/leapraid/leapraid_func.c
 create mode 100644 drivers/scsi/leapraid/leapraid_func.h
 create mode 100644 drivers/scsi/leapraid/leapraid_os.c
 create mode 100644 drivers/scsi/leapraid/leapraid_transport.c
Documentation/scsi/index.rst +1 -0
index f15a0f348ae4..52970f0159ca 100644
@@ -56,6 +56,7 @@ SCSI host adapter drivers
    g_NCR5380
    hpsa
    hptiop
+   leapraid
    libsas
    lpfc
    megaraid
Documentation/scsi/leapraid.rst new file +137 -0

137 lines not on this page · raw message

MAINTAINERS +7 -0
index 46126ce2f968..f64cbe8a6fa3 100644
@@ -14075,6 +14075,13 @@ S:	Maintained
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening
 F:	scripts/leaking_addresses.pl
 
+LEAPIO SCSI RAID DRIVER
+M:	Hao Dongdong <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	Documentation/scsi/leapraid.rst
+F:	drivers/scsi/leapraid/
+
 LED SUBSYSTEM
 M:	Lee Jones <[email protected]>
 M:	Pavel Machek <[email protected]>
drivers/scsi/Kconfig +1 -0
index 19d0884479a2..954101f6a0f7 100644
@@ -462,6 +462,7 @@ source "drivers/scsi/aic7xxx/Kconfig.aic79xx"
 source "drivers/scsi/aic94xx/Kconfig"
 source "drivers/scsi/hisi_sas/Kconfig"
 source "drivers/scsi/mvsas/Kconfig"
+source "drivers/scsi/leapraid/Kconfig"
 
 config SCSI_MVUMI
 	tristate "Marvell UMI driver"
drivers/scsi/Makefile +1 -0
index 16de3e41f94c..5b7bd119cd9f 100644
@@ -152,6 +152,7 @@ obj-$(CONFIG_CHR_DEV_SCH)	+= ch.o
 obj-$(CONFIG_SCSI_ENCLOSURE)	+= ses.o
 
 obj-$(CONFIG_SCSI_HISI_SAS) += hisi_sas/
+obj-$(CONFIG_SCSI_LEAPRAID) += leapraid/
 
 # This goes last, so that "real" scsi devices probe earlier
 obj-$(CONFIG_SCSI_DEBUG)	+= scsi_debug.o
drivers/scsi/leapraid/Kconfig new file +14 -0
new file mode 100644
index 000000000000..b539183b24a7
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+config SCSI_LEAPRAID
+	tristate "LeapIO RAID Adapter"
+	depends on PCI && SCSI
+	select SCSI_SAS_ATTRS
+	help
+	  This driver supports LeapIO PCIe-based Storage
+	  and RAID controllers.
+
+	  <http://www.leap-io.com>
+
+	  To compile this driver as a module, choose M here: the
+	  resulting kernel module will be named leapraid.
drivers/scsi/leapraid/Makefile new file +10 -0
new file mode 100644
index 000000000000..bdafc036cd00
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for the LEAPRAID drivers.
+#
+
+obj-$(CONFIG_SCSI_LEAPRAID) += leapraid.o
+leapraid-objs += leapraid_func.o \
+		leapraid_os.o \
+		leapraid_transport.o \
+		leapraid_app.o
drivers/scsi/leapraid/leapraid.h new file +2060 -0

2,060 lines not on this page · raw message

drivers/scsi/leapraid/leapraid_app.c new file +686 -0

686 lines not on this page · raw message

drivers/scsi/leapraid/leapraid_func.c new file +8112 -0

59 lines not on this page · raw message

drivers/scsi/leapraid/leapraid_func.h new file +1426 -0

1,426 lines not on this page · raw message

drivers/scsi/leapraid/leapraid_os.c new file +2286 -0

2,286 lines not on this page · raw message

drivers/scsi/leapraid/leapraid_transport.c new file +1250 -0

1,250 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.25.1

Part of the diff is not shown here. View the raw message.

#1 lore raw
kernel test robot noticed the following build warnings:

Hi Hao,

kernel test robot noticed the following build warnings:

[auto build test WARNING on jejb-scsi/for-next]
[also build test WARNING on mkp-scsi/for-next linus/master v6.18-rc6 next-20251117] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Hao-Dongdong/scsi-leapraid-Add-new-scsi-driver/20251116-192921
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
patch link:    https://lore.kernel.org/r/20251116112803.28078-1-doubled%40leap-io-kernel.com
patch subject: [PATCH v4] scsi: leapraid: Add new scsi driver
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20251118/[email protected]/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251118/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/scsi/leapraid/leapraid_func.c:4794:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
    4794 |         default:
         |         ^
   drivers/scsi/leapraid/leapraid_func.c:4794:2: note: insert 'break;' to avoid fall-through
    4794 |         default:
         |         ^
         |         break; 

1 warning generated.

vim +4794 drivers/scsi/leapraid/leapraid_func.c

4741
4742 static void leapraid_fw_work(struct leapraid_adapter *adapter,
4743 struct leapraid_fw_evt_work *fw_evt)
4744 {
4745 struct leapraid_sas_dev *sas_dev;
4746
4747 adapter->fw_evt_s.cur_evt = fw_evt;
4748 leapraid_del_fw_evt_from_list(adapter, fw_evt);
4749 if (adapter->access_ctrl.host_removing ||
4750 adapter->access_ctrl.pcie_recovering) {
4751 leapraid_fw_evt_put(fw_evt);
4752 adapter->fw_evt_s.cur_evt = NULL;
4753 return;
4754 }
4755 switch (fw_evt->evt_type) {
4756 case LEAPRAID_EVT_SAS_DISCOVERY:
4757 {
4758 struct leapraid_evt_data_sas_disc *evt_data;
4759
4760 evt_data = fw_evt->evt_data;
4761 if (evt_data->reason_code ==
4762 LEAPRAID_EVT_SAS_DISC_RC_STARTED &&
4763 !adapter->dev_topo.card.phys_num)
4764 leapraid_sas_host_add(adapter, 0);
4765 break;
4766 }
4767 case LEAPRAID_EVT_SAS_TOPO_CHANGE_LIST:
4768 leapraid_sas_topo_chg_evt(adapter, fw_evt);
4769 break;
4770 case LEAPRAID_EVT_IR_CHANGE:
4771 leapraid_sas_ir_chg_evt(adapter, fw_evt);
4772 break;
4773 case LEAPRAID_EVT_SAS_ENCL_DEV_STATUS_CHANGE:
4774 leapraid_sas_enc_dev_stat_chg_evt(adapter, fw_evt);
4775 break;
4776 case LEAPRAID_EVT_REMOVE_DEAD_DEV:
4777 while (scsi_host_in_recovery(adapter->shost) ||
4778 adapter->access_ctrl.shost_recovering) {
4779 if (adapter->access_ctrl.host_removing ||
4780 adapter->fw_evt_s.fw_evt_cleanup)
4781 goto out;
4782
4783 ssleep(1);
4784 }
4785 leapraid_hardreset_async_logic(adapter);
4786 break;
4787 case LEAPRAID_EVT_TURN_ON_PFA_LED:
4788 sas_dev = leapraid_get_sas_dev_by_hdl(adapter,
4789 fw_evt->dev_handle);
4790 leapraid_set_led(adapter, sas_dev, true);
4791 break;
4792 case LEAPRAID_EVT_SCAN_DEV_DONE:
4793 adapter->scan_dev_desc.scan_start = false;

> 4794		default:

4795 break;
4796 }
4797 out:
4798 leapraid_fw_evt_put(fw_evt);
4799 adapter->fw_evt_s.cur_evt = NULL;
4800 }
4801

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki