Skip to content

vioscsi: fix issue with SCSI adapter surprise removal not taking effect #1350

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

Merged
merged 1 commit into from
May 26, 2025

Conversation

zjmletang
Copy link
Member

for the problem description
please visit #1331

Signed-off-by: Zhang JianMing [email protected]

@YanVugenfirer
Copy link
Collaborator

Can one of the admins verify this patch?

@@ -1169,7 +1169,7 @@ VioScsiAdapterControl(IN PVOID DeviceExtension, IN SCSI_ADAPTER_CONTROL_TYPE Con
{
RhelDbgPrint(TRACE_LEVEL_VERBOSE, " ScsiQuerySupportedControlTypes\n");
ControlTypeList = (PSCSI_SUPPORTED_CONTROL_TYPE_LIST)Parameters;
AdjustedMaxControlType = (ControlTypeList->MaxControlType < 5) ? ControlTypeList->MaxControlType : 5;
AdjustedMaxControlType = (ControlTypeList->MaxControlType < 17) ? ControlTypeList->MaxControlType : 17;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s switch to using MS defined enums for a better code readability:

typedef enum _SCSI_ADAPTER_CONTROL_TYPE {
    ScsiQuerySupportedControlTypes = 0,
    ScsiStopAdapter,
    ScsiRestartAdapter,
    ScsiSetBootConfig,
    ScsiSetRunningConfig,
    ScsiPowerSettingNotification,
    ScsiAdapterPower,
    ScsiAdapterPoFxPowerRequired,
    ScsiAdapterPoFxPowerActive,
    ScsiAdapterPoFxPowerSetFState,
    ScsiAdapterPoFxPowerControl,
    ScsiAdapterPrepareForBusReScan,
    ScsiAdapterSystemPowerHints,
    ScsiAdapterFilterResourceRequirements,
    ScsiAdapterPoFxMaxOperationalPower,
    ScsiAdapterPoFxSetPerfState,
    ScsiAdapterSurpriseRemoval,
    ScsiAdapterSerialNumber,
    ScsiAdapterCryptoOperation,
    ScsiAdapterQueryFruId,
    ScsiAdapterSetEventLogging,
    ScsiAdapterReportInternalData,
    ScsiAdapterControlMax,
    MakeAdapterControlTypeSizeOfUlong = 0xffffffff
} SCSI_ADAPTER_CONTROL_TYPE, *PSCSI_ADAPTER_CONTROL_TYPE;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YanVugenfirer ,I have changed one of the implementations to use MS-defined enums. This version will result in some additional iterations in the for loop compared to the previous version; however, I understand that this part of the code is not performance-sensitive, so it shouldn't be a major concern.

Additionally, I believe there is another method of implementation that is quite good, as demonstrated in Microsoft's miniport sample. I chose the current modification mainly to maintain consistency with the previous style.
image

@zjmletang zjmletang force-pushed the fix_vioscsi branch 2 times, most recently from 8d69943 to 7699db5 Compare April 25, 2025 08:46
for the problem description
please visit virtio-win#1331
Signed-off-by: Zhang JianMing [email protected]
@YanVugenfirer
Copy link
Collaborator

ok to test

@YanVugenfirer YanVugenfirer merged commit a227c6f into virtio-win:master May 26, 2025
4 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants