Date: Thu, 17 Dec 2020 13:17:26 +0000 (UTC) From: Michal Meloun <mmel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r368717 - stable/12/sys/dev/nvme Message-ID: <202012171317.0BHDHQoO027692@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mmel Date: Thu Dec 17 13:17:26 2020 New Revision: 368717 URL: https://svnweb.freebsd.org/changeset/base/368717 Log: 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. Modified: stable/12/sys/dev/nvme/nvme.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/nvme/nvme.h ============================================================================== --- stable/12/sys/dev/nvme/nvme.h Thu Dec 17 13:07:15 2020 (r368716) +++ stable/12/sys/dev/nvme/nvme.h Thu Dec 17 13:17:26 2020 (r368717) @@ -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->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_contro 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_namespa 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 nvm 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 nvm 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_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_t 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_statu 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_s s->ctrlr[i].rkey = le64toh(s->ctrlr[i].rkey); nvme_le128toh((void *)s->ctrlr[i].hostid); } +#endif } #endif /* __NVME_H__ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202012171317.0BHDHQoO027692>