-
Notifications
You must be signed in to change notification settings - Fork 92
Driver supports HRDT trustraid D3100s controllers. #917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Driver supports HRDT trustraid D3100s controllers. #917
Conversation
Reviewer's GuideThis PR introduces a new TrustRaid SCSI driver under drivers/scsi/trustraid, implementing smartpqi core logic with SIS and SAS transport layers, integrating the trustrlib support library, updating build scripts and Kconfig to enable CONFIG_SCSI_TRUSTRAID, and registering HRDT TrustRaid D3100s PCI IDs. ER diagram for TrustRaid driver queue and request structureserDiagram
PQI_CTRL_INFO ||--o{ PQI_QUEUE_GROUP : has
PQI_QUEUE_GROUP ||--o{ PQI_IO_REQUEST : manages
PQI_QUEUE_GROUP ||--|| TRUSTRLIB_QUEUE_GROUP : "trustrlib_data"
PQI_IO_REQUEST ||--|| TRUSTRLIB_IO_REQUEST : "trustrlib_data"
PQI_CTRL_INFO ||--|| TRUSTRLIB_CTRL_INFO : "trustrlib_data"
TRUSTRLIB_CTRL_INFO ||--|| TRUSTRLIB_TEMPLATE : "template"
Class diagram for new TrustRaid driver core typesclassDiagram
class pqi_ctrl_info {
+unsigned int ctrl_id
+struct pci_dev *pci_dev
+struct pqi_ctrl_registers __iomem *registers
+struct pqi_device_registers __iomem *pqi_registers
+struct pqi_admin_queues admin_queues
+struct pqi_queue_group queue_groups[PQI_MAX_QUEUE_GROUPS]
+struct pqi_event_queue event_queue
+struct trustrlib_ops *trustrlib
+void *trustrlib_data
...
}
class pqi_queue_group {
+struct pqi_ctrl_info *ctrl_info
+void *iq_element_array[2]
+void *oq_element_array
+struct trustrlib_queue_group *trustrlib_data
...
}
class trustrlib_ctrl_info {
+struct pqi_ctrl_info *ctrl_info
+struct timer_list poll_complete_queue_timer
+struct work_struct check_iq_hang_work
+struct pqi_queue_group *check_queue_group
+struct delayed_work recheck_iq_hang_work
+struct pqi_queue_group *recheck_queue_group
+struct trustrlib_template *template
}
class trustrlib_queue_group {
+atomic_t inflight_num
+spinlock_t complete_lock
+u8 iq_hanging[2]
}
class trustrlib_io_request {
+spinlock_t lock
+atomic_t in_interrupt_or_timedout
+u8 timedout_count
}
class trustrlib_ops {
+set_aio_request_id(void*, void*)
+set_aio_r1_request_id(void*, void*)
+set_aio_r56_request_id(void*, void*)
+set_raid_request_id(void*, void*)
+get_and_update_io_request(void*, void*)
+free_io_request(void*)
+eh_timed_out(void*)
+reset_io_request_index(void*)
+process_io_intr(void*, void*)
+set_sg_table_size(void*, void*)
+alloc_hw_queue(void*, u16)
+start_io(void*, void*, int)
+init_ctrl(trustrlib_template*, void*, void*)
+uninit_ctrl(void*)
+init_works(void*)
+uninit_works(void*)
+init_queue_group(void*)
+init_io_request(void*)
+uninit_queue_group(void*)
+uninit_io_request(void*)
}
pqi_ctrl_info --> pqi_queue_group : has many
pqi_ctrl_info --> trustrlib_ops : uses
pqi_ctrl_info --> trustrlib_ctrl_info : trustrlib_data
pqi_queue_group --> trustrlib_queue_group : trustrlib_data
trustrlib_ctrl_info --> trustrlib_template : template
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Hi @Tech-Hurray. Thanks for your PR. 😃 |
Hi @Tech-Hurray. Thanks for your PR. I'm waiting for a deepin-community member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
deepin pr auto reviewBased on the code in the project repository provided by the user and the user's requirements, generate new code or modify existing code. The output format is: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Tech-Hurray - I've reviewed your changes and found some issues that need to be addressed.
- smartpqi.h is extremely large; consider splitting it into focused headers (e.g. register definitions, queue structures, and function prototypes) to improve readability and maintainability.
- The many PCI_VENDOR_ID_* macros added here duplicate definitions elsewhere; centralizing vendor ID constants in a common header would reduce duplication and simplify future updates.
- trustrlib_match_cpu hard-codes support for specific Loongson and SW64 models; consider adding a fallback or override mechanism so unsupported CPUs fail gracefully rather than silently blocking the driver.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- smartpqi.h is extremely large; consider splitting it into focused headers (e.g. register definitions, queue structures, and function prototypes) to improve readability and maintainability.
- The many PCI_VENDOR_ID_* macros added here duplicate definitions elsewhere; centralizing vendor ID constants in a common header would reduce duplication and simplify future updates.
- trustrlib_match_cpu hard-codes support for specific Loongson and SW64 models; consider adding a fallback or override mechanism so unsupported CPUs fail gracefully rather than silently blocking the driver.
## Individual Comments
### Comment 1
<location> `drivers/scsi/trustraid/trustrlib.c:430` </location>
<code_context>
+ data_direction);
+}
+
+static int pqi_build_inquiry_raid_path_request(struct pqi_ctrl_info *ctrl_info,
+ struct pqi_raid_path_request *request,
+ u8 *scsi3addr, void *buffer, size_t buffer_length)
</code_context>
<issue_to_address>
Unused commented-out CDB fields.
If cdb[1] and cdb[2] are not needed, please remove the commented-out lines to keep the codebase clean.
</issue_to_address>
### Comment 2
<location> `drivers/scsi/trustraid/trustrlib.c:961` </location>
<code_context>
+ return NULL;
+}
+
+static inline bool list_on_list(struct list_head *entry)
+{
+ return !(entry->next == NULL || entry->next == LIST_POISON1 || entry->next == entry);
</code_context>
<issue_to_address>
list_on_list() may not be reliable for all list_head states.
The current checks may miss some corrupted list states. Using kernel helpers like list_empty() is recommended for more robust detection.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
static inline bool list_on_list(struct list_head *entry)
{
return !(entry->next == NULL || entry->next == LIST_POISON1 || entry->next == entry);
}
=======
static inline bool list_on_list(struct list_head *entry)
{
return !list_empty(entry);
}
>>>>>>> REPLACE
</suggested_fix>
### Comment 3
<location> `drivers/scsi/trustraid/trustrlib.c:1046` </location>
<code_context>
+ return 0;
+}
+
+static void pqi_list_del(struct list_head *entry)
+{
+ list_del(entry);
</code_context>
<issue_to_address>
Redundant pointer nullification after list_del.
Setting entry->next and entry->prev to NULL after list_del is unnecessary and could mask issues if the list_head is reused. Remove this, or use list_del_init if re-initialization is required.
</issue_to_address>
### Comment 4
<location> `drivers/scsi/trustraid/smartpqi_init.c:1212` </location>
<code_context>
+ return rc;
+}
+
+static int pqi_report_phys_luns(struct pqi_ctrl_info *ctrl_info, void **buffer)
+{
+ int rc;
</code_context>
<issue_to_address>
Possible memory leak if rpl_16byte_wwid_list allocation fails.
Free rpl_list before returning -ENOMEM to prevent a memory leak in this error path.
</issue_to_address>
### Comment 5
<location> `drivers/scsi/trustraid/smartpqi_init.c:1342` </location>
<code_context>
+ device->lun = lun;
+}
+
+static void pqi_assign_bus_target_lun(struct pqi_scsi_dev *device)
+{
+ u8 *scsi3addr;
</code_context>
<issue_to_address>
Potential for uninitialized bus/target/lun values for physical devices.
Since bus/target/lun are set to default values and assignment is deferred, verify that all usages for physical devices account for this and do not rely on these fields being initialized earlier.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
data_direction); | ||
} | ||
|
||
static int pqi_build_inquiry_raid_path_request(struct pqi_ctrl_info *ctrl_info, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: Unused commented-out CDB fields.
If cdb[1] and cdb[2] are not needed, please remove the commented-out lines to keep the codebase clean.
drivers/scsi/trustraid/trustrlib.c
Outdated
static inline bool list_on_list(struct list_head *entry) | ||
{ | ||
return !(entry->next == NULL || entry->next == LIST_POISON1 || entry->next == entry); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): list_on_list() may not be reliable for all list_head states.
The current checks may miss some corrupted list states. Using kernel helpers like list_empty() is recommended for more robust detection.
static inline bool list_on_list(struct list_head *entry) | |
{ | |
return !(entry->next == NULL || entry->next == LIST_POISON1 || entry->next == entry); | |
} | |
static inline bool list_on_list(struct list_head *entry) | |
{ | |
return !list_empty(entry); | |
} |
return 0; | ||
} | ||
|
||
static void pqi_list_del(struct list_head *entry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: Redundant pointer nullification after list_del.
Setting entry->next and entry->prev to NULL after list_del is unnecessary and could mask issues if the list_head is reused. Remove this, or use list_del_init if re-initialization is required.
return rc; | ||
} | ||
|
||
static int pqi_report_phys_luns(struct pqi_ctrl_info *ctrl_info, void **buffer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Possible memory leak if rpl_16byte_wwid_list allocation fails.
Free rpl_list before returning -ENOMEM to prevent a memory leak in this error path.
device->lun = lun; | ||
} | ||
|
||
static void pqi_assign_bus_target_lun(struct pqi_scsi_dev *device) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question (bug_risk): Potential for uninitialized bus/target/lun values for physical devices.
Since bus/target/lun are set to default values and assignment is deferred, verify that all usages for physical devices account for this and do not rely on these fields being initialized earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds native support for HRDT TrustRaid D3100s controllers via a new PQI-based SCSI driver under drivers/scsi/trustraid.
- Introduces a trustrlib wrapper library for CPU/platform-specific I/O operations.
- Splits the smartpqi core into SIS legacy and SAS transport modules.
- Updates the build system (Makefile/Kconfig) to enable CONFIG_SCSI_TRUSTRAID.
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
drivers/scsi/trustraid/trustrlib.h | Define the trustrlib API, templates, ops, and structs |
drivers/scsi/trustraid/trustrlib.c | Implement trustrlib routines, IO processing, cpu match |
drivers/scsi/trustraid/smartpqi_sis.h | Declare legacy SIS interface functions |
drivers/scsi/trustraid/smartpqi_sis.c | Implement SIS commands and controller interactions |
drivers/scsi/trustraid/smartpqi_sas_transport.c | Implement SAS transport layer and BSG SMP handling |
drivers/scsi/trustraid/smartpqi.h | Add core PQI definitions, structures, and templates |
drivers/scsi/trustraid/Makefile | Build rules for trustraid modules |
drivers/scsi/trustraid/Kconfig | Add config entry for SCSI_TRUSTRAID |
drivers/scsi/Makefile | Integrate trustraid into the SCSI build |
drivers/scsi/Kconfig | Include trustraid Kconfig in the SCSI subsystem |
drivers/scsi/trustraid/trustrlib.c
Outdated
void *context) | ||
{ | ||
struct completion *waiting = context; | ||
printk(KERN_INFO "pqi_check_inquiry_complete: io_request %p context %p\n", io_request, context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using printk for logging in driver code; use dev_info() or dev_dbg() with the device context for proper logging levels and rate limiting.
Copilot uses AI. Check for mistakes.
drivers/scsi/trustraid/trustrlib.c
Outdated
return; | ||
if (inflight_num < 0) { | ||
dev_err(&ctrl_info->pci_dev->dev, | ||
"pqi_poll_complete_queue: unexcepted inflight_num %d, queue_group %p\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct the typo in the log message: "unexcepted" should be "unexpected".
"pqi_poll_complete_queue: unexcepted inflight_num %d, queue_group %p\n", | |
"pqi_poll_complete_queue: unexpected inflight_num %d, queue_group %p\n", |
Copilot uses AI. Check for mistakes.
drivers/scsi/trustraid/trustrlib.c
Outdated
@@ -0,0 +1,1229 @@ | |||
#include <linux/module.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add MODULE_LICENSE("GPL"); (and optionally MODULE_AUTHOR/MODULE_DESCRIPTION) to declare the license and prevent kernel taint warnings.
Copilot uses AI. Check for mistakes.
drivers/scsi/trustraid/trustrlib.h
Outdated
#ifndef _TRUSTRLIB_IMPL_H_ | ||
#define _TRUSTRLIB_IMPL_H_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The include guard macro name (TRUSTRLIB_IMPL_H) doesn't match the header filename; consider renaming it to TRUSTRLIB_H for clarity and consistency.
#ifndef _TRUSTRLIB_IMPL_H_ | |
#define _TRUSTRLIB_IMPL_H_ | |
#ifndef _TRUSTRLIB_H_ | |
#define _TRUSTRLIB_H_ |
Copilot uses AI. Check for mistakes.
343aefc
to
bef6255
Compare
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Avenger-285714 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This driver is to support HRDT trustraid D3100s controllers.
Summary by Sourcery
Add support for HRDT TrustRaid D3100s controllers by introducing a new PQI-based SCSI driver under drivers/scsi/trustraid and enabling it via CONFIG_SCSI_TRUSTRAID.
New Features:
Enhancements:
Build: