git: d9b3bba2f302 - main - mpr: endianess fix for set/get dpm page0

From: Robert Wing <rew_at_FreeBSD.org>
Date: Thu, 01 Feb 2024 02:47:11 UTC
The branch main has been updated by rew:

URL: https://cgit.FreeBSD.org/src/commit/?id=d9b3bba2f3022f1b577fb7a18c523c92551d8257

commit d9b3bba2f3022f1b577fb7a18c523c92551d8257
Author:     Robert Wing <rew@FreeBSD.org>
AuthorDate: 2024-02-01 02:33:05 +0000
Commit:     Robert Wing <rew@FreeBSD.org>
CommitDate: 2024-02-01 02:33:05 +0000

    mpr: endianess fix for set/get dpm page0
    
    Reviewed by:    oshogbo, imp
    Sponsored by:   Klara, Inc.
    Sponsored by:   Datazap
    Differential Revision:  https://reviews.freebsd.org/D43505
---
 sys/dev/mpr/mpr_config.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/sys/dev/mpr/mpr_config.c b/sys/dev/mpr/mpr_config.c
index 768f69cdc89f..b7882feed158 100644
--- a/sys/dev/mpr/mpr_config.c
+++ b/sys/dev/mpr/mpr_config.c
@@ -547,8 +547,8 @@ mpr_config_get_dpm_pg0(struct mpr_softc *sc, Mpi2ConfigReply_t *mpi_reply,
 	request->ExtPageType = MPI2_CONFIG_EXTPAGETYPE_DRIVER_MAPPING;
 	request->Header.PageNumber = 0;
 	request->ExtPageLength = request->Header.PageVersion = 0;
-	request->PageAddress = sc->max_dpm_entries <<
-	    MPI2_DPM_PGAD_ENTRY_COUNT_SHIFT;
+	request->PageAddress = htole32(sc->max_dpm_entries <<
+	    MPI2_DPM_PGAD_ENTRY_COUNT_SHIFT);
 	cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
 	cm->cm_data = NULL;
 	error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP);
@@ -597,8 +597,8 @@ mpr_config_get_dpm_pg0(struct mpr_softc *sc, Mpi2ConfigReply_t *mpi_reply,
 	request->ExtPageType = MPI2_CONFIG_EXTPAGETYPE_DRIVER_MAPPING;
 	request->Header.PageNumber = 0;
 	request->Header.PageVersion = mpi_reply->Header.PageVersion;
-	request->PageAddress = sc->max_dpm_entries <<
-	    MPI2_DPM_PGAD_ENTRY_COUNT_SHIFT;
+	request->PageAddress = htole32(sc->max_dpm_entries <<
+	    MPI2_DPM_PGAD_ENTRY_COUNT_SHIFT);
 	request->ExtPageLength = mpi_reply->ExtPageLength;
 	cm->cm_length = le16toh(request->ExtPageLength) * 4;
 	cm->cm_sge = &request->PageBufferSGE;
@@ -684,9 +684,8 @@ int mpr_config_set_dpm_pg0(struct mpr_softc *sc, Mpi2ConfigReply_t *mpi_reply,
 	request->ExtPageType = MPI2_CONFIG_EXTPAGETYPE_DRIVER_MAPPING;
 	request->Header.PageNumber = 0;
 	request->ExtPageLength = request->Header.PageVersion = 0;
-	/* We can remove below two lines ????*/
-	request->PageAddress = 1 << MPI2_DPM_PGAD_ENTRY_COUNT_SHIFT;
-	request->PageAddress |= htole16(entry_idx);
+	request->PageAddress = htole32(
+		(1 << MPI2_DPM_PGAD_ENTRY_COUNT_SHIFT) | entry_idx);
 	cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
 	cm->cm_data = NULL;
 	error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP);
@@ -736,8 +735,8 @@ int mpr_config_set_dpm_pg0(struct mpr_softc *sc, Mpi2ConfigReply_t *mpi_reply,
 	request->Header.PageNumber = 0;
 	request->Header.PageVersion = mpi_reply->Header.PageVersion;
 	request->ExtPageLength = mpi_reply->ExtPageLength;
-	request->PageAddress = 1 << MPI2_DPM_PGAD_ENTRY_COUNT_SHIFT;
-	request->PageAddress |= htole16(entry_idx);
+	request->PageAddress = htole32(
+		(1 << MPI2_DPM_PGAD_ENTRY_COUNT_SHIFT) | entry_idx);
 	cm->cm_length = le16toh(mpi_reply->ExtPageLength) * 4;
 	cm->cm_sge = &request->PageBufferSGE;
 	cm->cm_sglsize = sizeof(MPI2_SGE_IO_UNION);