提交 83d94276 编写于 作者: D Dave Jiang 提交者: Caspar Zhang

acpi/nfit, libnvdimm: Store dimm id as a member to struct nvdimm

to #27305291

commit d6548ae4d16dc231dec22860c9c472bcb991fb15 upstream.

The generated dimm id is needed for the sysfs attribute as well as being
used as the identifier/description for the security key. Since it's
constant and should never change, store it as a member of struct nvdimm.

As nvdimm_create() continues to grow parameters relative to NFIT driver
requirements, do not require other implementations to keep pace.
Introduce __nvdimm_create() to carry the new parameters and keep
nvdimm_create() with the long standing default api.
Signed-off-by: NDave Jiang <dave.jiang@intel.com>
Signed-off-by: NDan Williams <dan.j.williams@intel.com>

[ Shile: fixed conflict in drivers/acpi/nfit/nfit.h ]
Signed-off-by: NShile Zhang <shile.zhang@linux.alibaba.com>
Reviewed-by: NYang Shi <yang.shi@linux.alibaba.com>
上级 d7258548
...@@ -1625,18 +1625,10 @@ static DEVICE_ATTR_RO(flags); ...@@ -1625,18 +1625,10 @@ static DEVICE_ATTR_RO(flags);
static ssize_t id_show(struct device *dev, static ssize_t id_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct acpi_nfit_control_region *dcr = to_nfit_dcr(dev); struct nvdimm *nvdimm = to_nvdimm(dev);
struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
if (dcr->valid_fields & ACPI_NFIT_CONTROL_MFG_INFO_VALID) return sprintf(buf, "%s\n", nfit_mem->id);
return sprintf(buf, "%04x-%02x-%04x-%08x\n",
be16_to_cpu(dcr->vendor_id),
dcr->manufacturing_location,
be16_to_cpu(dcr->manufacturing_date),
be32_to_cpu(dcr->serial_number));
else
return sprintf(buf, "%04x-%08x\n",
be16_to_cpu(dcr->vendor_id),
be32_to_cpu(dcr->serial_number));
} }
static DEVICE_ATTR_RO(id); static DEVICE_ATTR_RO(id);
...@@ -1765,10 +1757,23 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc *acpi_desc, ...@@ -1765,10 +1757,23 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc *acpi_desc,
const guid_t *guid; const guid_t *guid;
int i; int i;
int family = -1; int family = -1;
struct acpi_nfit_control_region *dcr = nfit_mem->dcr;
/* nfit test assumes 1:1 relationship between commands and dsms */ /* nfit test assumes 1:1 relationship between commands and dsms */
nfit_mem->dsm_mask = acpi_desc->dimm_cmd_force_en; nfit_mem->dsm_mask = acpi_desc->dimm_cmd_force_en;
nfit_mem->family = NVDIMM_FAMILY_INTEL; nfit_mem->family = NVDIMM_FAMILY_INTEL;
if (dcr->valid_fields & ACPI_NFIT_CONTROL_MFG_INFO_VALID)
sprintf(nfit_mem->id, "%04x-%02x-%04x-%08x",
be16_to_cpu(dcr->vendor_id),
dcr->manufacturing_location,
be16_to_cpu(dcr->manufacturing_date),
be32_to_cpu(dcr->serial_number));
else
sprintf(nfit_mem->id, "%04x-%08x",
be16_to_cpu(dcr->vendor_id),
be32_to_cpu(dcr->serial_number));
adev = to_acpi_dev(acpi_desc); adev = to_acpi_dev(acpi_desc);
if (!adev) if (!adev)
return 0; return 0;
...@@ -1956,10 +1961,10 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc) ...@@ -1956,10 +1961,10 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc)
flush = nfit_mem->nfit_flush ? nfit_mem->nfit_flush->flush flush = nfit_mem->nfit_flush ? nfit_mem->nfit_flush->flush
: NULL; : NULL;
nvdimm = nvdimm_create(acpi_desc->nvdimm_bus, nfit_mem, nvdimm = __nvdimm_create(acpi_desc->nvdimm_bus, nfit_mem,
acpi_nfit_dimm_attribute_groups, acpi_nfit_dimm_attribute_groups,
flags, cmd_mask, flush ? flush->hint_count : 0, flags, cmd_mask, flush ? flush->hint_count : 0,
nfit_mem->flush_wpq); nfit_mem->flush_wpq, &nfit_mem->id[0]);
if (!nvdimm) if (!nvdimm)
return -ENOMEM; return -ENOMEM;
......
...@@ -176,6 +176,8 @@ struct nfit_memdev { ...@@ -176,6 +176,8 @@ struct nfit_memdev {
struct acpi_nfit_memory_map memdev[0]; struct acpi_nfit_memory_map memdev[0];
}; };
#define NFIT_DIMM_ID_LEN 22
/* assembled tables for a given dimm/memory-device */ /* assembled tables for a given dimm/memory-device */
struct nfit_mem { struct nfit_mem {
struct nvdimm *nvdimm; struct nvdimm *nvdimm;
...@@ -193,6 +195,7 @@ struct nfit_mem { ...@@ -193,6 +195,7 @@ struct nfit_mem {
struct list_head list; struct list_head list;
struct acpi_device *adev; struct acpi_device *adev;
struct acpi_nfit_desc *acpi_desc; struct acpi_nfit_desc *acpi_desc;
char id[NFIT_DIMM_ID_LEN+1];
struct resource *flush_wpq; struct resource *flush_wpq;
unsigned long dsm_mask; unsigned long dsm_mask;
int family; int family;
......
...@@ -395,10 +395,10 @@ struct attribute_group nvdimm_attribute_group = { ...@@ -395,10 +395,10 @@ struct attribute_group nvdimm_attribute_group = {
}; };
EXPORT_SYMBOL_GPL(nvdimm_attribute_group); EXPORT_SYMBOL_GPL(nvdimm_attribute_group);
struct nvdimm *nvdimm_create(struct nvdimm_bus *nvdimm_bus, void *provider_data, struct nvdimm *__nvdimm_create(struct nvdimm_bus *nvdimm_bus,
const struct attribute_group **groups, unsigned long flags, void *provider_data, const struct attribute_group **groups,
unsigned long cmd_mask, int num_flush, unsigned long flags, unsigned long cmd_mask, int num_flush,
struct resource *flush_wpq) struct resource *flush_wpq, const char *dimm_id)
{ {
struct nvdimm *nvdimm = kzalloc(sizeof(*nvdimm), GFP_KERNEL); struct nvdimm *nvdimm = kzalloc(sizeof(*nvdimm), GFP_KERNEL);
struct device *dev; struct device *dev;
...@@ -411,6 +411,8 @@ struct nvdimm *nvdimm_create(struct nvdimm_bus *nvdimm_bus, void *provider_data, ...@@ -411,6 +411,8 @@ struct nvdimm *nvdimm_create(struct nvdimm_bus *nvdimm_bus, void *provider_data,
kfree(nvdimm); kfree(nvdimm);
return NULL; return NULL;
} }
nvdimm->dimm_id = dimm_id;
nvdimm->provider_data = provider_data; nvdimm->provider_data = provider_data;
nvdimm->flags = flags; nvdimm->flags = flags;
nvdimm->cmd_mask = cmd_mask; nvdimm->cmd_mask = cmd_mask;
...@@ -427,7 +429,7 @@ struct nvdimm *nvdimm_create(struct nvdimm_bus *nvdimm_bus, void *provider_data, ...@@ -427,7 +429,7 @@ struct nvdimm *nvdimm_create(struct nvdimm_bus *nvdimm_bus, void *provider_data,
return nvdimm; return nvdimm;
} }
EXPORT_SYMBOL_GPL(nvdimm_create); EXPORT_SYMBOL_GPL(__nvdimm_create);
int alias_dpa_busy(struct device *dev, void *data) int alias_dpa_busy(struct device *dev, void *data)
{ {
......
...@@ -43,6 +43,7 @@ struct nvdimm { ...@@ -43,6 +43,7 @@ struct nvdimm {
atomic_t busy; atomic_t busy;
int id, num_flush; int id, num_flush;
struct resource *flush_wpq; struct resource *flush_wpq;
const char *dimm_id;
}; };
/** /**
......
...@@ -182,10 +182,19 @@ const char *nvdimm_name(struct nvdimm *nvdimm); ...@@ -182,10 +182,19 @@ const char *nvdimm_name(struct nvdimm *nvdimm);
struct kobject *nvdimm_kobj(struct nvdimm *nvdimm); struct kobject *nvdimm_kobj(struct nvdimm *nvdimm);
unsigned long nvdimm_cmd_mask(struct nvdimm *nvdimm); unsigned long nvdimm_cmd_mask(struct nvdimm *nvdimm);
void *nvdimm_provider_data(struct nvdimm *nvdimm); void *nvdimm_provider_data(struct nvdimm *nvdimm);
struct nvdimm *nvdimm_create(struct nvdimm_bus *nvdimm_bus, void *provider_data, struct nvdimm *__nvdimm_create(struct nvdimm_bus *nvdimm_bus,
const struct attribute_group **groups, unsigned long flags, void *provider_data, const struct attribute_group **groups,
unsigned long cmd_mask, int num_flush, unsigned long flags, unsigned long cmd_mask, int num_flush,
struct resource *flush_wpq); struct resource *flush_wpq, const char *dimm_id);
static inline struct nvdimm *nvdimm_create(struct nvdimm_bus *nvdimm_bus,
void *provider_data, const struct attribute_group **groups,
unsigned long flags, unsigned long cmd_mask, int num_flush,
struct resource *flush_wpq)
{
return __nvdimm_create(nvdimm_bus, provider_data, groups, flags,
cmd_mask, num_flush, flush_wpq, NULL);
}
const struct nd_cmd_desc *nd_cmd_dimm_desc(int cmd); const struct nd_cmd_desc *nd_cmd_dimm_desc(int cmd);
const struct nd_cmd_desc *nd_cmd_bus_desc(int cmd); const struct nd_cmd_desc *nd_cmd_bus_desc(int cmd);
u32 nd_cmd_in_size(struct nvdimm *nvdimm, int cmd, u32 nd_cmd_in_size(struct nvdimm *nvdimm, int cmd,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册