aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Meloun <mmel@FreeBSD.org>2020-12-17 13:17:26 +0000
committerMichal Meloun <mmel@FreeBSD.org>2020-12-17 13:17:26 +0000
commitcc644ecca2d8d2666a53d810d00badefb1c8b0ad (patch)
tree4e9039e8d6d0c76d220b432decfd5b47b178526e
parent50d4917c9fece31d4aeb91ab2c4fa36296d75e86 (diff)
downloadsrc-cc644ecca2d8d2666a53d810d00badefb1c8b0ad.tar.gz
src-cc644ecca2d8d2666a53d810d00badefb1c8b0ad.zip
MFC r368167,r368187,r368203:
r368167: NVME: Don't try to swap data on little endian machines. These swapping functions violate BUSDMA contract - we cannot write to armed (by bus_dmamap_sync(PRE_..)) buffers. Remove them at least from little endian machines until a better solution will be developed. r368187: Unbreak r368167 in userland. Decorate unused arguments. r368203: Always use the __unused attribute even for potentially unused parameters.
Notes
Notes: svn path=/stable/12/; revision=368717
-rw-r--r--sys/dev/nvme/nvme.h67
1 files changed, 50 insertions, 17 deletions
diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h
index 1065fce3ae56..41d5362f6982 100644
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -1738,8 +1738,9 @@ extern int nvme_use_nvd;
/* Endianess conversion functions for NVMe structs */
static inline
-void nvme_completion_swapbytes(struct nvme_completion *s)
+void nvme_completion_swapbytes(struct nvme_completion *s __unused)
{
+#if _BYTE_ORDER != _LITTLE_ENDIAN
s->cdw0 = le32toh(s->cdw0);
/* omit rsvd1 */
@@ -1747,22 +1748,26 @@ void nvme_completion_swapbytes(struct nvme_completion *s)
s->sqid = le16toh(s->sqid);
/* omit cid */
s->status = le16toh(s->status);
+#endif
}
static inline
-void nvme_power_state_swapbytes(struct nvme_power_state *s)
+void nvme_power_state_swapbytes(struct nvme_power_state *s __unused)
{
+#if _BYTE_ORDER != _LITTLE_ENDIAN
s->mp = le16toh(s->mp);
s->enlat = le32toh(s->enlat);
s->exlat = le32toh(s->exlat);
s->idlp = le16toh(s->idlp);
s->actp = le16toh(s->actp);
+#endif
}
static inline
-void nvme_controller_data_swapbytes(struct nvme_controller_data *s)
+void nvme_controller_data_swapbytes(struct nvme_controller_data *s __unused)
{
+#if _BYTE_ORDER != _LITTLE_ENDIAN
int i;
s->vid = le16toh(s->vid);
@@ -1808,11 +1813,13 @@ void nvme_controller_data_swapbytes(struct nvme_controller_data *s)
s->mnan = le32toh(s->mnan);
for (i = 0; i < 32; i++)
nvme_power_state_swapbytes(&s->power_state[i]);
+#endif
}
static inline
-void nvme_namespace_data_swapbytes(struct nvme_namespace_data *s)
+void nvme_namespace_data_swapbytes(struct nvme_namespace_data *s __unused)
{
+#if _BYTE_ORDER != _LITTLE_ENDIAN
int i;
s->nsze = le64toh(s->nsze);
@@ -1835,11 +1842,14 @@ void nvme_namespace_data_swapbytes(struct nvme_namespace_data *s)
s->endgid = le16toh(s->endgid);
for (i = 0; i < 16; i++)
s->lbaf[i] = le32toh(s->lbaf[i]);
+#endif
}
static inline
-void nvme_error_information_entry_swapbytes(struct nvme_error_information_entry *s)
+void nvme_error_information_entry_swapbytes(
+ struct nvme_error_information_entry *s __unused)
{
+#if _BYTE_ORDER != _LITTLE_ENDIAN
s->error_count = le64toh(s->error_count);
s->sqid = le16toh(s->sqid);
@@ -1850,10 +1860,11 @@ void nvme_error_information_entry_swapbytes(struct nvme_error_information_entry
s->nsid = le32toh(s->nsid);
s->csi = le64toh(s->csi);
s->ttsi = le16toh(s->ttsi);
+#endif
}
static inline
-void nvme_le128toh(void *p)
+void nvme_le128toh(void *p __unused)
{
#if _BYTE_ORDER != _LITTLE_ENDIAN
/* Swap 16 bytes in place */
@@ -1865,14 +1876,14 @@ void nvme_le128toh(void *p)
tmp[i] = tmp[15-i];
tmp[15-i] = b;
}
-#else
- (void)p;
#endif
}
static inline
-void nvme_health_information_page_swapbytes(struct nvme_health_information_page *s)
+void nvme_health_information_page_swapbytes(
+ struct nvme_health_information_page *s __unused)
{
+#if _BYTE_ORDER != _LITTLE_ENDIAN
int i;
s->temperature = le16toh(s->temperature);
@@ -1894,48 +1905,61 @@ void nvme_health_information_page_swapbytes(struct nvme_health_information_page
s->tmt2tc = le32toh(s->tmt2tc);
s->ttftmt1 = le32toh(s->ttftmt1);
s->ttftmt2 = le32toh(s->ttftmt2);
+#endif
}
static inline
-void nvme_firmware_page_swapbytes(struct nvme_firmware_page *s)
+void nvme_firmware_page_swapbytes(struct nvme_firmware_page *s __unused)
{
+#if _BYTE_ORDER != _LITTLE_ENDIAN
int i;
for (i = 0; i < 7; i++)
s->revision[i] = le64toh(s->revision[i]);
+#endif
}
static inline
-void nvme_ns_list_swapbytes(struct nvme_ns_list *s)
+void nvme_ns_list_swapbytes(struct nvme_ns_list *s __unused)
{
+#if _BYTE_ORDER != _LITTLE_ENDIAN
int i;
for (i = 0; i < 1024; i++)
s->ns[i] = le32toh(s->ns[i]);
+#endif
}
static inline
-void nvme_command_effects_page_swapbytes(struct nvme_command_effects_page *s)
+void nvme_command_effects_page_swapbytes(
+ struct nvme_command_effects_page *s __unused)
{
+#if _BYTE_ORDER != _LITTLE_ENDIAN
int i;
for (i = 0; i < 256; i++)
s->acs[i] = le32toh(s->acs[i]);
for (i = 0; i < 256; i++)
s->iocs[i] = le32toh(s->iocs[i]);
+#endif
}
static inline
-void nvme_res_notification_page_swapbytes(struct nvme_res_notification_page *s)
+void nvme_res_notification_page_swapbytes(
+ struct nvme_res_notification_page *s __unused)
{
+#if _BYTE_ORDER != _LITTLE_ENDIAN
s->log_page_count = le64toh(s->log_page_count);
s->nsid = le32toh(s->nsid);
+#endif
}
static inline
-void nvme_sanitize_status_page_swapbytes(struct nvme_sanitize_status_page *s)
+void nvme_sanitize_status_page_swapbytes(
+ struct nvme_sanitize_status_page *s __unused)
{
+#if _BYTE_ORDER != _LITTLE_ENDIAN
s->sprog = le16toh(s->sprog);
s->sstat = le16toh(s->sstat);
s->scdw10 = le32toh(s->scdw10);
@@ -1945,11 +1969,13 @@ void nvme_sanitize_status_page_swapbytes(struct nvme_sanitize_status_page *s)
s->etfownd = le32toh(s->etfownd);
s->etfbewnd = le32toh(s->etfbewnd);
s->etfcewnd = le32toh(s->etfcewnd);
+#endif
}
static inline
-void intel_log_temp_stats_swapbytes(struct intel_log_temp_stats *s)
+void intel_log_temp_stats_swapbytes(struct intel_log_temp_stats *s __unused)
{
+#if _BYTE_ORDER != _LITTLE_ENDIAN
s->current = le64toh(s->current);
s->overtemp_flag_last = le64toh(s->overtemp_flag_last);
@@ -1960,11 +1986,14 @@ void intel_log_temp_stats_swapbytes(struct intel_log_temp_stats *s)
s->max_oper_temp = le64toh(s->max_oper_temp);
s->min_oper_temp = le64toh(s->min_oper_temp);
s->est_offset = le64toh(s->est_offset);
+#endif
}
static inline
-void nvme_resv_status_swapbytes(struct nvme_resv_status *s, size_t size)
+void nvme_resv_status_swapbytes(struct nvme_resv_status *s __unused,
+ size_t size __unused)
{
+#if _BYTE_ORDER != _LITTLE_ENDIAN
u_int i, n;
s->gen = le32toh(s->gen);
@@ -1975,11 +2004,14 @@ void nvme_resv_status_swapbytes(struct nvme_resv_status *s, size_t size)
s->ctrlr[i].hostid = le64toh(s->ctrlr[i].hostid);
s->ctrlr[i].rkey = le64toh(s->ctrlr[i].rkey);
}
+#endif
}
static inline
-void nvme_resv_status_ext_swapbytes(struct nvme_resv_status_ext *s, size_t size)
+void nvme_resv_status_ext_swapbytes(struct nvme_resv_status_ext *s __unused,
+ size_t size __unused)
{
+#if _BYTE_ORDER != _LITTLE_ENDIAN
u_int i, n;
s->gen = le32toh(s->gen);
@@ -1990,6 +2022,7 @@ void nvme_resv_status_ext_swapbytes(struct nvme_resv_status_ext *s, size_t size)
s->ctrlr[i].rkey = le64toh(s->ctrlr[i].rkey);
nvme_le128toh((void *)s->ctrlr[i].hostid);
}
+#endif
}
#endif /* __NVME_H__ */