Date: Thu, 10 Oct 2019 22:49:45 +0000 (UTC) From: Conrad Meyer <cem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353417 - head/sys/dev/nvdimm Message-ID: <201910102249.x9AMnj8x049421@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: cem Date: Thu Oct 10 22:49:45 2019 New Revision: 353417 URL: https://svnweb.freebsd.org/changeset/base/353417 Log: nvdimm(4): Calculate and save memattr once; it never changes Refactor nvdimm_spa_memattr() routine and callers to just save the value at initialization and use the value directly. The reference value from NFIT, MemoryMapping, is read only once, so the associated memattr could never change. No functional change. Sponsored by: Dell EMC Isilon Modified: head/sys/dev/nvdimm/nvdimm_ns.c head/sys/dev/nvdimm/nvdimm_spa.c head/sys/dev/nvdimm/nvdimm_var.h Modified: head/sys/dev/nvdimm/nvdimm_ns.c ============================================================================== --- head/sys/dev/nvdimm/nvdimm_ns.c Thu Oct 10 20:33:55 2019 (r353416) +++ head/sys/dev/nvdimm/nvdimm_ns.c Thu Oct 10 22:49:45 2019 (r353417) @@ -72,6 +72,7 @@ nvdimm_create_namespaces(struct SPA_mapping *spa, ACPI (e->label.dimm_phys_addr - regions[0]->Address); ns->dev.spa_len = num_regions * e->label.raw_size; ns->dev.spa_efi_mem_flags = spa->dev.spa_efi_mem_flags; + ns->dev.spa_memattr = spa->dev.spa_memattr; asprintf(&name, M_NVDIMM, "spa%dns%d", spa->spa_nfit_idx, i); error = nvdimm_spa_dev_init(&ns->dev, name); free(name, M_NVDIMM); Modified: head/sys/dev/nvdimm/nvdimm_spa.c ============================================================================== --- head/sys/dev/nvdimm/nvdimm_spa.c Thu Oct 10 20:33:55 2019 (r353416) +++ head/sys/dev/nvdimm/nvdimm_spa.c Thu Oct 10 22:49:45 2019 (r353417) @@ -156,24 +156,24 @@ nvdimm_spa_type_from_uuid(struct uuid *uuid) } static vm_memattr_t -nvdimm_spa_memattr(struct nvdimm_spa_dev *dev) +nvdimm_spa_memattr(uint64_t efi_mem_flags) { vm_memattr_t mode; - if ((dev->spa_efi_mem_flags & EFI_MD_ATTR_WB) != 0) + if ((efi_mem_flags & EFI_MD_ATTR_WB) != 0) mode = VM_MEMATTR_WRITE_BACK; - else if ((dev->spa_efi_mem_flags & EFI_MD_ATTR_WT) != 0) + else if ((efi_mem_flags & EFI_MD_ATTR_WT) != 0) mode = VM_MEMATTR_WRITE_THROUGH; - else if ((dev->spa_efi_mem_flags & EFI_MD_ATTR_WC) != 0) + else if ((efi_mem_flags & EFI_MD_ATTR_WC) != 0) mode = VM_MEMATTR_WRITE_COMBINING; - else if ((dev->spa_efi_mem_flags & EFI_MD_ATTR_WP) != 0) + else if ((efi_mem_flags & EFI_MD_ATTR_WP) != 0) mode = VM_MEMATTR_WRITE_PROTECTED; - else if ((dev->spa_efi_mem_flags & EFI_MD_ATTR_UC) != 0) + else if ((efi_mem_flags & EFI_MD_ATTR_UC) != 0) mode = VM_MEMATTR_UNCACHEABLE; else { if (bootverbose) printf("SPA mapping attr %#lx unsupported\n", - dev->spa_efi_mem_flags); + efi_mem_flags); mode = VM_MEMATTR_UNCACHEABLE; } return (mode); @@ -189,7 +189,7 @@ nvdimm_spa_uio(struct nvdimm_spa_dev *dev, struct uio error = 0; if (dev->spa_kva == NULL) { - mattr = nvdimm_spa_memattr(dev); + mattr = dev->spa_memattr; bzero(&m, sizeof(m)); vm_page_initfake(&m, 0, mattr); ma = &m; @@ -288,7 +288,7 @@ nvdimm_spa_g_all_unmapped(struct nvdimm_spa_dev *dev, vm_memattr_t mattr; int i; - mattr = nvdimm_spa_memattr(dev); + mattr = dev->spa_memattr; for (i = 0; i < nitems(ma); i++) { bzero(&maa[i], sizeof(maa[i])); vm_page_initfake(&maa[i], dev->spa_phys_base + @@ -345,8 +345,7 @@ nvdimm_spa_g_thread(void *arg) pmap_flush_cache_phys_range( (vm_paddr_t)sc->dev->spa_phys_base, (vm_paddr_t)sc->dev->spa_phys_base + - sc->dev->spa_len, - nvdimm_spa_memattr(sc->dev)); + sc->dev->spa_len, sc->dev->spa_memattr); } /* * XXX flush IMC @@ -458,6 +457,7 @@ nvdimm_spa_init(struct SPA_mapping *spa, ACPI_NFIT_SYS nvdimm_SPA_uuid_list[spa_type].u_name, spa->dev.spa_efi_mem_flags); } + spa->dev.spa_memattr = nvdimm_spa_memattr(nfitaddr->MemoryMapping); if (!nvdimm_SPA_uuid_list[spa_type].u_usr_acc) return (0); @@ -476,7 +476,7 @@ nvdimm_spa_dev_init(struct nvdimm_spa_dev *dev, const int error, error1; error1 = pmap_large_map(dev->spa_phys_base, dev->spa_len, - &dev->spa_kva, nvdimm_spa_memattr(dev)); + &dev->spa_kva, dev->spa_memattr); if (error1 != 0) { printf("NVDIMM %s cannot map into KVA, error %d\n", name, error1); Modified: head/sys/dev/nvdimm/nvdimm_var.h ============================================================================== --- head/sys/dev/nvdimm/nvdimm_var.h Thu Oct 10 20:33:55 2019 (r353416) +++ head/sys/dev/nvdimm/nvdimm_var.h Thu Oct 10 22:49:45 2019 (r353417) @@ -114,6 +114,7 @@ enum SPA_mapping_type { struct nvdimm_spa_dev { int spa_domain; + vm_memattr_t spa_memattr; uint64_t spa_phys_base; uint64_t spa_len; uint64_t spa_efi_mem_flags;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910102249.x9AMnj8x049421>