From: Dave Jiang <dave.jiang@intel.com> To: dan.j.williams@intel.com Cc: alison.schofield@intel.com, keescook@chromium.org, linux-nvdimm@lists.01.org, ebiggers3@gmail.com, dhowells@redhat.com, keyrings@vger.kernel.org Subject: [PATCH v10 10/12] nfit_test: add context to dimm_dev for nfit_test Date: Wed, 26 Sep 2018 13:47:40 -0700 [thread overview] Message-ID: <153799486070.71621.11412880339298606423.stgit@djiang5-desk3.ch.intel.com> (raw) In-Reply-To: <153799466529.71621.10728628542331983376.stgit@djiang5-desk3.ch.intel.com> In order to access the nfit_test context via sideband sysfs knobs, the dimm_dev needs to be more than struct device in order to point back to struct nfit_test. Wrapping the original struct device with a struct nfit_dimm_dev and saving the nfit_test as private driver data. Also changing the nfit_mem to be a member of struct nfit_dimm_dev instead of saving as private driver data of that device. This is in preparation for adding security DSM support and allowing the locking of DIMMs for testing via sideband. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> --- tools/testing/nvdimm/test/nfit.c | 41 +++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c index cffc2c5a778d..1d62222a10da 100644 --- a/tools/testing/nvdimm/test/nfit.c +++ b/tools/testing/nvdimm/test/nfit.c @@ -172,6 +172,11 @@ struct nfit_test_fw { u64 end_time; }; +struct nfit_dimm_dev { + struct device dev; + struct nfit_mem *nfit_mem; +}; + struct nfit_test { struct acpi_nfit_desc acpi_desc; struct platform_device pdev; @@ -203,7 +208,7 @@ struct nfit_test { unsigned long deadline; spinlock_t lock; } ars_state; - struct device *dimm_dev[NUM_DCR]; + struct nfit_dimm_dev dimm_dev[NUM_DCR]; struct nd_intel_smart *smart; struct nd_intel_smart_threshold *smart_threshold; struct badrange badrange; @@ -1018,7 +1023,8 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc, &t->smart_threshold[i - t->dcr_idx], &t->smart[i - t->dcr_idx], - &t->pdev.dev, t->dimm_dev[i]); + &t->pdev.dev, + &t->dimm_dev[i].dev); break; case ND_INTEL_SMART_INJECT: rc = nfit_test_cmd_smart_inject(buf, @@ -1026,7 +1032,8 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc, &t->smart_threshold[i - t->dcr_idx], &t->smart[i - t->dcr_idx], - &t->pdev.dev, t->dimm_dev[i]); + &t->pdev.dev, + &t->dimm_dev[i].dev); break; default: return -ENOTTY; @@ -1224,8 +1231,7 @@ static void put_dimms(void *data) int i; for (i = 0; i < t->num_dcr; i++) - if (t->dimm_dev[i]) - device_unregister(t->dimm_dev[i]); + device_unregister(&t->dimm_dev[i].dev); } static struct class *nfit_test_dimm; @@ -1327,19 +1333,27 @@ static const struct attribute_group *nfit_test_dimm_attribute_groups[] = { NULL, }; +static void dimm_dev_release(struct device *dev) +{ +} + static int nfit_test_dimm_init(struct nfit_test *t) { - int i; + int i, rc; if (devm_add_action_or_reset(&t->pdev.dev, put_dimms, t)) return -ENOMEM; for (i = 0; i < t->num_dcr; i++) { - t->dimm_dev[i] = device_create_with_groups(nfit_test_dimm, - &t->pdev.dev, 0, NULL, - nfit_test_dimm_attribute_groups, - "test_dimm%d", i + t->dcr_idx); - if (!t->dimm_dev[i]) - return -ENOMEM; + t->dimm_dev[i].dev.parent = &t->pdev.dev; + dev_set_name(&t->dimm_dev[i].dev, "test_dimm%d", + i + t->dcr_idx); + t->dimm_dev[i].dev.class = nfit_test_dimm; + t->dimm_dev[i].dev.groups = nfit_test_dimm_attribute_groups; + t->dimm_dev[i].dev.release = dimm_dev_release; + rc = device_register(&t->dimm_dev[i].dev); + if (rc < 0) + return rc; + dev_set_drvdata(&t->dimm_dev[i].dev, t); } return 0; } @@ -2680,8 +2694,7 @@ static int nfit_test_probe(struct platform_device *pdev) for (i = 0; i < NUM_DCR; i++) if (nfit_handle == handle[i]) - dev_set_drvdata(nfit_test->dimm_dev[i], - nfit_mem); + nfit_test->dimm_dev[i].nfit_mem = nfit_mem; } mutex_unlock(&acpi_desc->init_mutex); _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
WARNING: multiple messages have this Message-ID (diff)
From: Dave Jiang <dave.jiang@intel.com> To: dan.j.williams@intel.com Cc: alison.schofield@intel.com, keescook@chromium.org, linux-nvdimm@lists.01.org, ebiggers3@gmail.com, dhowells@redhat.com, keyrings@vger.kernel.org Subject: [PATCH v10 10/12] nfit_test: add context to dimm_dev for nfit_test Date: Wed, 26 Sep 2018 20:47:40 +0000 [thread overview] Message-ID: <153799486070.71621.11412880339298606423.stgit@djiang5-desk3.ch.intel.com> (raw) In-Reply-To: <153799466529.71621.10728628542331983376.stgit@djiang5-desk3.ch.intel.com> In order to access the nfit_test context via sideband sysfs knobs, the dimm_dev needs to be more than struct device in order to point back to struct nfit_test. Wrapping the original struct device with a struct nfit_dimm_dev and saving the nfit_test as private driver data. Also changing the nfit_mem to be a member of struct nfit_dimm_dev instead of saving as private driver data of that device. This is in preparation for adding security DSM support and allowing the locking of DIMMs for testing via sideband. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> --- tools/testing/nvdimm/test/nfit.c | 41 +++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c index cffc2c5a778d..1d62222a10da 100644 --- a/tools/testing/nvdimm/test/nfit.c +++ b/tools/testing/nvdimm/test/nfit.c @@ -172,6 +172,11 @@ struct nfit_test_fw { u64 end_time; }; +struct nfit_dimm_dev { + struct device dev; + struct nfit_mem *nfit_mem; +}; + struct nfit_test { struct acpi_nfit_desc acpi_desc; struct platform_device pdev; @@ -203,7 +208,7 @@ struct nfit_test { unsigned long deadline; spinlock_t lock; } ars_state; - struct device *dimm_dev[NUM_DCR]; + struct nfit_dimm_dev dimm_dev[NUM_DCR]; struct nd_intel_smart *smart; struct nd_intel_smart_threshold *smart_threshold; struct badrange badrange; @@ -1018,7 +1023,8 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc, &t->smart_threshold[i - t->dcr_idx], &t->smart[i - t->dcr_idx], - &t->pdev.dev, t->dimm_dev[i]); + &t->pdev.dev, + &t->dimm_dev[i].dev); break; case ND_INTEL_SMART_INJECT: rc = nfit_test_cmd_smart_inject(buf, @@ -1026,7 +1032,8 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc, &t->smart_threshold[i - t->dcr_idx], &t->smart[i - t->dcr_idx], - &t->pdev.dev, t->dimm_dev[i]); + &t->pdev.dev, + &t->dimm_dev[i].dev); break; default: return -ENOTTY; @@ -1224,8 +1231,7 @@ static void put_dimms(void *data) int i; for (i = 0; i < t->num_dcr; i++) - if (t->dimm_dev[i]) - device_unregister(t->dimm_dev[i]); + device_unregister(&t->dimm_dev[i].dev); } static struct class *nfit_test_dimm; @@ -1327,19 +1333,27 @@ static const struct attribute_group *nfit_test_dimm_attribute_groups[] = { NULL, }; +static void dimm_dev_release(struct device *dev) +{ +} + static int nfit_test_dimm_init(struct nfit_test *t) { - int i; + int i, rc; if (devm_add_action_or_reset(&t->pdev.dev, put_dimms, t)) return -ENOMEM; for (i = 0; i < t->num_dcr; i++) { - t->dimm_dev[i] = device_create_with_groups(nfit_test_dimm, - &t->pdev.dev, 0, NULL, - nfit_test_dimm_attribute_groups, - "test_dimm%d", i + t->dcr_idx); - if (!t->dimm_dev[i]) - return -ENOMEM; + t->dimm_dev[i].dev.parent = &t->pdev.dev; + dev_set_name(&t->dimm_dev[i].dev, "test_dimm%d", + i + t->dcr_idx); + t->dimm_dev[i].dev.class = nfit_test_dimm; + t->dimm_dev[i].dev.groups = nfit_test_dimm_attribute_groups; + t->dimm_dev[i].dev.release = dimm_dev_release; + rc = device_register(&t->dimm_dev[i].dev); + if (rc < 0) + return rc; + dev_set_drvdata(&t->dimm_dev[i].dev, t); } return 0; } @@ -2680,8 +2694,7 @@ static int nfit_test_probe(struct platform_device *pdev) for (i = 0; i < NUM_DCR; i++) if (nfit_handle = handle[i]) - dev_set_drvdata(nfit_test->dimm_dev[i], - nfit_mem); + nfit_test->dimm_dev[i].nfit_mem = nfit_mem; } mutex_unlock(&acpi_desc->init_mutex);
next prev parent reply other threads:[~2018-09-26 20:47 UTC|newest] Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-09-26 20:46 [PATCH v10 00/12] Adding security support for nvdimm Dave Jiang 2018-09-26 20:46 ` Dave Jiang 2018-09-26 20:46 ` [PATCH v10 01/12] nfit: add support for Intel DSM 1.7 commands Dave Jiang 2018-09-26 20:46 ` Dave Jiang 2018-09-26 20:46 ` [PATCH v10 02/12] libnvdimm: create keyring to store security keys Dave Jiang 2018-09-26 20:46 ` Dave Jiang 2018-09-26 20:47 ` [PATCH v10 03/12] nfit/libnvdimm: store dimm id as a member to struct nvdimm Dave Jiang 2018-09-26 20:47 ` Dave Jiang 2018-09-26 20:47 ` [PATCH v10 04/12] keys: export lookup_user_key to external users Dave Jiang 2018-09-26 20:47 ` Dave Jiang 2018-09-26 20:47 ` [PATCH v10 05/12] nfit/libnvdimm: add unlock of nvdimm support for Intel DIMMs Dave Jiang 2018-09-26 20:47 ` Dave Jiang 2018-09-26 20:47 ` [PATCH v10 06/12] nfit/libnvdimm: add set passphrase support for Intel nvdimms Dave Jiang 2018-09-26 20:47 ` Dave Jiang 2018-09-26 20:47 ` [PATCH v10 07/12] nfit/libnvdimm: add disable passphrase support to Intel nvdimm Dave Jiang 2018-09-26 20:47 ` Dave Jiang 2018-09-26 20:47 ` [PATCH v10 08/12] nfit/libnvdimm: add freeze security " Dave Jiang 2018-09-26 20:47 ` Dave Jiang 2018-09-26 20:47 ` [PATCH v10 09/12] nfit/libnvdimm: add support for issue secure erase DSM " Dave Jiang 2018-09-26 20:47 ` Dave Jiang 2018-09-26 20:47 ` Dave Jiang [this message] 2018-09-26 20:47 ` [PATCH v10 10/12] nfit_test: add context to dimm_dev for nfit_test Dave Jiang 2018-09-26 20:47 ` [PATCH v10 11/12] nfit_test: add test support for Intel nvdimm security DSMs Dave Jiang 2018-09-26 20:47 ` Dave Jiang 2018-09-26 20:47 ` [PATCH v10 12/12] libnvdimm: add documentation for nvdimm security support Dave Jiang 2018-09-26 20:47 ` Dave Jiang 2018-09-26 21:28 ` [PATCH v10 00/12] Adding security support for nvdimm Dan Williams 2018-09-26 21:28 ` Dan Williams 2018-09-28 8:17 ` [PATCH v10 02/12] libnvdimm: create keyring to store security keys David Howells 2018-09-28 8:17 ` David Howells 2018-09-28 8:24 ` [PATCH v10 05/12] nfit/libnvdimm: add unlock of nvdimm support for Intel DIMMs David Howells 2018-09-28 8:24 ` David Howells 2018-09-28 8:45 ` [PATCH v10 06/12] nfit/libnvdimm: add set passphrase support for Intel nvdimms David Howells 2018-09-28 8:45 ` David Howells 2018-09-28 9:28 ` David Howells 2018-09-28 9:28 ` David Howells
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=153799486070.71621.11412880339298606423.stgit@djiang5-desk3.ch.intel.com \ --to=dave.jiang@intel.com \ --cc=alison.schofield@intel.com \ --cc=dan.j.williams@intel.com \ --cc=dhowells@redhat.com \ --cc=ebiggers3@gmail.com \ --cc=keescook@chromium.org \ --cc=keyrings@vger.kernel.org \ --cc=linux-nvdimm@lists.01.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.