--- /dev/null
+From 7d18f0a14aa6a0d6bad39111c1fb655f07f71d59 Mon Sep 17 00:00:00 2001
+From: Linus Walleij <linus.walleij@linaro.org>
+Date: Tue, 16 Jan 2018 08:29:50 +0100
+Subject: gpio: No NULL owner
+
+From: Linus Walleij <linus.walleij@linaro.org>
+
+commit 7d18f0a14aa6a0d6bad39111c1fb655f07f71d59 upstream.
+
+Sometimes a GPIO is fetched with NULL as parent device, and
+that is just fine. So under these circumstances, avoid using
+dev_name() to provide a name for the GPIO line.
+
+Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
+Cc: Daniel Rosenberg <drosen@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpio/gpiolib.c | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+--- a/drivers/gpio/gpiolib.c
++++ b/drivers/gpio/gpiolib.c
+@@ -3204,6 +3204,8 @@ struct gpio_desc *__must_check gpiod_get
+ struct gpio_desc *desc = NULL;
+ int status;
+ enum gpio_lookup_flags lookupflags = 0;
++ /* Maybe we have a device name, maybe not */
++ const char *devname = dev ? dev_name(dev) : "?";
+
+ dev_dbg(dev, "GPIO lookup for consumer %s\n", con_id);
+
+@@ -3232,8 +3234,11 @@ struct gpio_desc *__must_check gpiod_get
+ return desc;
+ }
+
+- /* If a connection label was passed use that, else use the device name as label */
+- status = gpiod_request(desc, con_id ? con_id : dev_name(dev));
++ /*
++ * If a connection label was passed use that, else attempt to use
++ * the device name as label
++ */
++ status = gpiod_request(desc, con_id ? con_id : devname);
+ if (status < 0)
+ return ERR_PTR(status);
+
--- /dev/null
+From 42819eb7a0957cc340ad4ed8bba736bab5ebc464 Mon Sep 17 00:00:00 2001
+From: Martin Wilck <mwilck@suse.com>
+Date: Mon, 14 Aug 2017 22:12:37 +0200
+Subject: nvmet: don't overwrite identify sn/fr with 0-bytes
+
+From: Martin Wilck <mwilck@suse.com>
+
+commit 42819eb7a0957cc340ad4ed8bba736bab5ebc464 upstream.
+
+The merged version of my patch "nvmet: don't report 0-bytes in serial
+number" fails to remove two lines which should have been replaced,
+so that the space-padded strings are overwritten again with 0-bytes.
+Fix it.
+
+Fixes: 42de82a8b544 nvmet: don't report 0-bytes in serial number
+Signed-off-by: Martin Wilck <mwilck@suse.com>
+Reviewed-by: Sagi Grimberg <sagi@grimbeg.me>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/nvme/target/admin-cmd.c | 6 ------
+ 1 file changed, 6 deletions(-)
+
+--- a/drivers/nvme/target/admin-cmd.c
++++ b/drivers/nvme/target/admin-cmd.c
+@@ -197,12 +197,6 @@ static void nvmet_execute_identify_ctrl(
+ copy_and_pad(id->mn, sizeof(id->mn), model, sizeof(model) - 1);
+ copy_and_pad(id->fr, sizeof(id->fr), UTS_RELEASE, strlen(UTS_RELEASE));
+
+- memset(id->mn, ' ', sizeof(id->mn));
+- strncpy((char *)id->mn, "Linux", sizeof(id->mn));
+-
+- memset(id->fr, ' ', sizeof(id->fr));
+- strncpy((char *)id->fr, UTS_RELEASE, sizeof(id->fr));
+-
+ id->rab = 6;
+
+ /*
--- /dev/null
+From 42de82a8b544fa55670feef7d6f85085fba48fc0 Mon Sep 17 00:00:00 2001
+From: Martin Wilck <mwilck@suse.com>
+Date: Fri, 14 Jul 2017 00:25:31 +0200
+Subject: nvmet: don't report 0-bytes in serial number
+
+From: Martin Wilck <mwilck@suse.com>
+
+commit 42de82a8b544fa55670feef7d6f85085fba48fc0 upstream.
+
+The NVME standard mandates that the SN, MN, and FR fields of the Identify
+Controller Data Structure be "ASCII strings". That means that they may
+not contain 0-bytes, not even string terminators.
+
+Signed-off-by: Martin Wilck <mwilck@suse.com>
+Reviewed-by: Hannes Reinecke <hare@suse.de>
+[hch: fixed for the move of the serial field, updated description]
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/nvme/target/admin-cmd.c | 16 ++++++++++++++--
+ 1 file changed, 14 insertions(+), 2 deletions(-)
+
+--- a/drivers/nvme/target/admin-cmd.c
++++ b/drivers/nvme/target/admin-cmd.c
+@@ -166,11 +166,21 @@ out:
+ nvmet_req_complete(req, status);
+ }
+
++static void copy_and_pad(char *dst, int dst_len, const char *src, int src_len)
++{
++ int len = min(src_len, dst_len);
++
++ memcpy(dst, src, len);
++ if (dst_len > len)
++ memset(dst + len, ' ', dst_len - len);
++}
++
+ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
+ {
+ struct nvmet_ctrl *ctrl = req->sq->ctrl;
+ struct nvme_id_ctrl *id;
+ u16 status = 0;
++ const char model[] = "Linux";
+
+ id = kzalloc(sizeof(*id), GFP_KERNEL);
+ if (!id) {
+@@ -182,8 +192,10 @@ static void nvmet_execute_identify_ctrl(
+ id->vid = 0;
+ id->ssvid = 0;
+
+- memset(id->sn, ' ', sizeof(id->sn));
+- snprintf(id->sn, sizeof(id->sn), "%llx", ctrl->subsys->serial);
++ bin2hex(id->sn, &ctrl->subsys->serial,
++ min(sizeof(ctrl->subsys->serial), sizeof(id->sn) / 2));
++ copy_and_pad(id->mn, sizeof(id->mn), model, sizeof(model) - 1);
++ copy_and_pad(id->fr, sizeof(id->fr), UTS_RELEASE, strlen(UTS_RELEASE));
+
+ memset(id->mn, ' ', sizeof(id->mn));
+ strncpy((char *)id->mn, "Linux", sizeof(id->mn));
--- /dev/null
+From 2e7f5d2af2155084c6f7c86328d36e698cd84954 Mon Sep 17 00:00:00 2001
+From: Johannes Thumshirn <jthumshirn@suse.de>
+Date: Fri, 14 Jul 2017 15:36:55 +0200
+Subject: nvmet: Move serial number from controller to subsystem
+
+From: Johannes Thumshirn <jthumshirn@suse.de>
+
+commit 2e7f5d2af2155084c6f7c86328d36e698cd84954 upstream.
+
+The NVMe specification defines the serial number as:
+
+"Serial Number (SN): Contains the serial number for the NVM subsystem
+that is assigned by the vendor as an ASCII string. Refer to section
+7.10 for unique identifier requirements. Refer to section 1.5 for ASCII
+string requirements"
+
+So move it from the controller to the subsystem, where it belongs.
+
+Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
+Reviewed-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/nvme/target/admin-cmd.c | 2 +-
+ drivers/nvme/target/core.c | 5 ++---
+ drivers/nvme/target/nvmet.h | 2 +-
+ 3 files changed, 4 insertions(+), 5 deletions(-)
+
+--- a/drivers/nvme/target/admin-cmd.c
++++ b/drivers/nvme/target/admin-cmd.c
+@@ -183,7 +183,7 @@ static void nvmet_execute_identify_ctrl(
+ id->ssvid = 0;
+
+ memset(id->sn, ' ', sizeof(id->sn));
+- snprintf(id->sn, sizeof(id->sn), "%llx", ctrl->serial);
++ snprintf(id->sn, sizeof(id->sn), "%llx", ctrl->subsys->serial);
+
+ memset(id->mn, ' ', sizeof(id->mn));
+ strncpy((char *)id->mn, "Linux", sizeof(id->mn));
+--- a/drivers/nvme/target/core.c
++++ b/drivers/nvme/target/core.c
+@@ -743,9 +743,6 @@ u16 nvmet_alloc_ctrl(const char *subsysn
+ memcpy(ctrl->subsysnqn, subsysnqn, NVMF_NQN_SIZE);
+ memcpy(ctrl->hostnqn, hostnqn, NVMF_NQN_SIZE);
+
+- /* generate a random serial number as our controllers are ephemeral: */
+- get_random_bytes(&ctrl->serial, sizeof(ctrl->serial));
+-
+ kref_init(&ctrl->ref);
+ ctrl->subsys = subsys;
+
+@@ -904,6 +901,8 @@ struct nvmet_subsys *nvmet_subsys_alloc(
+ return NULL;
+
+ subsys->ver = NVME_VS(1, 2, 1); /* NVMe 1.2.1 */
++ /* generate a random serial number as our controllers are ephemeral: */
++ get_random_bytes(&subsys->serial, sizeof(subsys->serial));
+
+ switch (type) {
+ case NVME_NQN_NVME:
+--- a/drivers/nvme/target/nvmet.h
++++ b/drivers/nvme/target/nvmet.h
+@@ -110,7 +110,6 @@ struct nvmet_ctrl {
+
+ struct mutex lock;
+ u64 cap;
+- u64 serial;
+ u32 cc;
+ u32 csts;
+
+@@ -151,6 +150,7 @@ struct nvmet_subsys {
+ u16 max_qid;
+
+ u64 ver;
++ u64 serial;
+ char *subsysnqn;
+
+ struct config_group group;
nvme-pci-initialize-queue-memory-before-interrupts.patch
af_key-always-verify-length-of-provided-sadb_key.patch
x86-crypto-x86-fpu-remove-x86_feature_eager_fpu-ifdef-from-the-crc32c-code.patch
+nvmet-move-serial-number-from-controller-to-subsystem.patch
+nvmet-don-t-report-0-bytes-in-serial-number.patch
+nvmet-don-t-overwrite-identify-sn-fr-with-0-bytes.patch
+gpio-no-null-owner.patch