Date: Wed, 19 Nov 2025 21:44:36 +0000 From: Colin Percival <cperciva@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Wanpeng Qian <wanpengqian@gmail.com> Subject: git: 0ccc71de6284 - releng/15.0 - nvme: Refactor geom setting to function. Message-ID: <691e3a44.338a1.32b68dfa@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch releng/15.0 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=0ccc71de62848366446a86487d36983146609605 commit 0ccc71de62848366446a86487d36983146609605 Author: Wanpeng Qian <wanpengqian@gmail.com> AuthorDate: 2025-11-18 15:24:23 +0000 Commit: Colin Percival <cperciva@FreeBSD.org> CommitDate: 2025-11-19 21:37:12 +0000 nvme: Refactor geom setting to function. Refactor setting of geometry for the disk to its own function. No functional changes. Approved by: re (cperciva) Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D33032 (cherry picked from commit dffd882d12d2a71aca464f48209ec9ae6f393b15) (cherry picked from commit 31412fda9fa71d85a19604151d662ac65c301c2a) --- sys/cam/nvme/nvme_da.c | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c index 1c0d5e8381d8..330f4ca66e1e 100644 --- a/sys/cam/nvme/nvme_da.c +++ b/sys/cam/nvme/nvme_da.c @@ -643,6 +643,35 @@ ndacleanup(struct cam_periph *periph) cam_periph_lock(periph); } +static void +ndasetgeom(struct nda_softc *softc, struct cam_periph *periph) +{ + struct disk *disk = softc->disk; + struct ccb_pathinq cpi; + const struct nvme_namespace_data *nsd; + const struct nvme_controller_data *cd; + uint8_t flbas_fmt, lbads, vwc_present; + + nsd = nvme_get_identify_ns(periph); + cd = nvme_get_identify_cntrl(periph); + + flbas_fmt = NVMEV(NVME_NS_DATA_FLBAS_FORMAT, nsd->flbas); + lbads = NVMEV(NVME_NS_DATA_LBAF_LBADS, nsd->lbaf[flbas_fmt]); + disk->d_sectorsize = 1 << lbads; + disk->d_mediasize = (off_t)(disk->d_sectorsize * nsd->nsze); + disk->d_delmaxsize = disk->d_mediasize; + disk->d_flags = DISKFLAG_DIRECT_COMPLETION; + if (nvme_ctrlr_has_dataset_mgmt(cd)) + disk->d_flags |= DISKFLAG_CANDELETE; + vwc_present = NVMEV(NVME_CTRLR_DATA_VWC_PRESENT, cd->vwc); + if (vwc_present) + disk->d_flags |= DISKFLAG_CANFLUSHCACHE; + if ((cpi.hba_misc & PIM_UNMAPPED) != 0) { + disk->d_flags |= DISKFLAG_UNMAPPED_BIO; + softc->unmappedio = 1; + } +} + static void ndaasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg) @@ -846,7 +875,6 @@ ndaregister(struct cam_periph *periph, void *arg) const struct nvme_namespace_data *nsd; const struct nvme_controller_data *cd; char announce_buf[80]; - uint8_t flbas_fmt, lbads, vwc_present; u_int maxio; int quirks; @@ -903,21 +931,8 @@ ndaregister(struct cam_periph *periph, void *arg) else if (maxio > maxphys) maxio = maxphys; /* for safety */ disk->d_maxsize = maxio; - flbas_fmt = NVMEV(NVME_NS_DATA_FLBAS_FORMAT, nsd->flbas); - lbads = NVMEV(NVME_NS_DATA_LBAF_LBADS, nsd->lbaf[flbas_fmt]); - disk->d_sectorsize = 1 << lbads; - disk->d_mediasize = (off_t)(disk->d_sectorsize * nsd->nsze); - disk->d_delmaxsize = disk->d_mediasize; - disk->d_flags = DISKFLAG_DIRECT_COMPLETION; - if (nvme_ctrlr_has_dataset_mgmt(cd)) - disk->d_flags |= DISKFLAG_CANDELETE; - vwc_present = NVMEV(NVME_CTRLR_DATA_VWC_PRESENT, cd->vwc); - if (vwc_present) - disk->d_flags |= DISKFLAG_CANFLUSHCACHE; - if ((cpi.hba_misc & PIM_UNMAPPED) != 0) { - disk->d_flags |= DISKFLAG_UNMAPPED_BIO; - softc->unmappedio = 1; - } + ndasetgeom(softc, periph); + /* * d_ident and d_descr are both far bigger than the length of either * the serial or model number strings.help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?691e3a44.338a1.32b68dfa>
