--- /dev/null
+From 28284943ac94014767ecc2f7b3c5747c4a5617a0 Mon Sep 17 00:00:00 2001
+From: Zhenyu Wang <zhenyuw@linux.intel.com>
+Date: Mon, 14 Sep 2020 11:03:02 +0800
+Subject: drm/i915/gvt: Fix port number for BDW on EDID region setup
+
+From: Zhenyu Wang <zhenyuw@linux.intel.com>
+
+commit 28284943ac94014767ecc2f7b3c5747c4a5617a0 upstream.
+
+Current BDW virtual display port is initialized as PORT_B, so need
+to use same port for VFIO EDID region, otherwise invalid EDID blob
+pointer is assigned which caused kernel null pointer reference. We
+might evaluate actual display hotplug for BDW to make this function
+work as expected, anyway this is always required to be fixed first.
+
+Reported-by: Alejandro Sior <aho@sior.be>
+Cc: Alejandro Sior <aho@sior.be>
+Fixes: 0178f4ce3c3b ("drm/i915/gvt: Enable vfio edid for all GVT supported platform")
+Reviewed-by: Hang Yuan <hang.yuan@intel.com>
+Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
+Link: http://patchwork.freedesktop.org/patch/msgid/20200914030302.2775505-1-zhenyuw@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/i915/gvt/vgpu.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+--- a/drivers/gpu/drm/i915/gvt/vgpu.c
++++ b/drivers/gpu/drm/i915/gvt/vgpu.c
+@@ -367,6 +367,7 @@ void intel_gvt_destroy_idle_vgpu(struct
+ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt,
+ struct intel_vgpu_creation_params *param)
+ {
++ struct drm_i915_private *dev_priv = gvt->gt->i915;
+ struct intel_vgpu *vgpu;
+ int ret;
+
+@@ -434,7 +435,10 @@ static struct intel_vgpu *__intel_gvt_cr
+ if (ret)
+ goto out_clean_sched_policy;
+
+- ret = intel_gvt_hypervisor_set_edid(vgpu, PORT_D);
++ if (IS_BROADWELL(dev_priv))
++ ret = intel_gvt_hypervisor_set_edid(vgpu, PORT_B);
++ else
++ ret = intel_gvt_hypervisor_set_edid(vgpu, PORT_D);
+ if (ret)
+ goto out_clean_sched_policy;
+
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- drivers/gpio/gpiolib.c | 34 ++++++++++++++++++++++++++++++----
+ drivers/gpio/gpiolib.c | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
-diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
-index 4fa075d49fbc9..6e813b13d6988 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
-@@ -836,6 +836,21 @@ static __poll_t lineevent_poll(struct file *filep,
+@@ -836,6 +836,21 @@ static __poll_t lineevent_poll(struct fi
return events;
}
static ssize_t lineevent_read(struct file *filep,
char __user *buf,
-@@ -845,9 +860,20 @@ static ssize_t lineevent_read(struct file *filep,
+@@ -845,9 +860,20 @@ static ssize_t lineevent_read(struct fil
struct lineevent_state *le = filep->private_data;
struct gpioevent_data ge;
ssize_t bytes_read = 0;
return -EINVAL;
do {
-@@ -883,10 +909,10 @@ static ssize_t lineevent_read(struct file *filep,
+@@ -883,10 +909,10 @@ static ssize_t lineevent_read(struct fil
break;
}
return bytes_read;
}
---
-2.25.1
-
--- /dev/null
+From 27ba3e8ff3ab86449e63d38a8d623053591e65fa Mon Sep 17 00:00:00 2001
+From: Damien Le Moal <damien.lemoal@wdc.com>
+Date: Tue, 15 Sep 2020 16:33:46 +0900
+Subject: scsi: sd: sd_zbc: Fix handling of host-aware ZBC disks
+
+From: Damien Le Moal <damien.lemoal@wdc.com>
+
+commit 27ba3e8ff3ab86449e63d38a8d623053591e65fa upstream.
+
+When CONFIG_BLK_DEV_ZONED is disabled, allow using host-aware ZBC disks as
+regular disks. In this case, ensure that command completion is correctly
+executed by changing sd_zbc_complete() to return good_bytes instead of 0
+and causing a hang during device probe (endless retries).
+
+When CONFIG_BLK_DEV_ZONED is enabled and a host-aware disk is detected to
+have partitions, it will be used as a regular disk. In this case, make sure
+to not do anything in sd_zbc_revalidate_zones() as that triggers warnings.
+
+Since all these different cases result in subtle settings of the disk queue
+zoned model, introduce the block layer helper function
+blk_queue_set_zoned() to generically implement setting up the effective
+zoned model according to the disk type, the presence of partitions on the
+disk and CONFIG_BLK_DEV_ZONED configuration.
+
+Link: https://lore.kernel.org/r/20200915073347.832424-2-damien.lemoal@wdc.com
+Fixes: b72053072c0b ("block: allow partitions on host aware zone devices")
+Cc: <stable@vger.kernel.org>
+Reported-by: Borislav Petkov <bp@alien8.de>
+Suggested-by: Christoph Hellwig <hch@infradead.org>
+Reviewed-by: Christoph Hellwig <hch@lst.de>
+Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
+Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ block/blk-settings.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
+ drivers/scsi/sd.c | 30 ++++++++++++++++++------------
+ drivers/scsi/sd.h | 2 +-
+ drivers/scsi/sd_zbc.c | 37 ++++++++++++++++++++++---------------
+ include/linux/blkdev.h | 2 ++
+ 5 files changed, 89 insertions(+), 28 deletions(-)
+
+--- a/block/blk-settings.c
++++ b/block/blk-settings.c
+@@ -832,6 +832,52 @@ bool blk_queue_can_use_dma_map_merging(s
+ }
+ EXPORT_SYMBOL_GPL(blk_queue_can_use_dma_map_merging);
+
++/**
++ * blk_queue_set_zoned - configure a disk queue zoned model.
++ * @disk: the gendisk of the queue to configure
++ * @model: the zoned model to set
++ *
++ * Set the zoned model of the request queue of @disk according to @model.
++ * When @model is BLK_ZONED_HM (host managed), this should be called only
++ * if zoned block device support is enabled (CONFIG_BLK_DEV_ZONED option).
++ * If @model specifies BLK_ZONED_HA (host aware), the effective model used
++ * depends on CONFIG_BLK_DEV_ZONED settings and on the existence of partitions
++ * on the disk.
++ */
++void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
++{
++ switch (model) {
++ case BLK_ZONED_HM:
++ /*
++ * Host managed devices are supported only if
++ * CONFIG_BLK_DEV_ZONED is enabled.
++ */
++ WARN_ON_ONCE(!IS_ENABLED(CONFIG_BLK_DEV_ZONED));
++ break;
++ case BLK_ZONED_HA:
++ /*
++ * Host aware devices can be treated either as regular block
++ * devices (similar to drive managed devices) or as zoned block
++ * devices to take advantage of the zone command set, similarly
++ * to host managed devices. We try the latter if there are no
++ * partitions and zoned block device support is enabled, else
++ * we do nothing special as far as the block layer is concerned.
++ */
++ if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED) ||
++ disk_has_partitions(disk))
++ model = BLK_ZONED_NONE;
++ break;
++ case BLK_ZONED_NONE:
++ default:
++ if (WARN_ON_ONCE(model != BLK_ZONED_NONE))
++ model = BLK_ZONED_NONE;
++ break;
++ }
++
++ disk->queue->limits.zoned = model;
++}
++EXPORT_SYMBOL_GPL(blk_queue_set_zoned);
++
+ static int __init blk_settings_init(void)
+ {
+ blk_max_low_pfn = max_low_pfn - 1;
+--- a/drivers/scsi/sd.c
++++ b/drivers/scsi/sd.c
+@@ -2966,26 +2966,32 @@ static void sd_read_block_characteristic
+
+ if (sdkp->device->type == TYPE_ZBC) {
+ /* Host-managed */
+- q->limits.zoned = BLK_ZONED_HM;
++ blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HM);
+ } else {
+ sdkp->zoned = (buffer[8] >> 4) & 3;
+- if (sdkp->zoned == 1 && !disk_has_partitions(sdkp->disk)) {
++ if (sdkp->zoned == 1) {
+ /* Host-aware */
+- q->limits.zoned = BLK_ZONED_HA;
++ blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HA);
+ } else {
+- /*
+- * Treat drive-managed devices and host-aware devices
+- * with partitions as regular block devices.
+- */
+- q->limits.zoned = BLK_ZONED_NONE;
+- if (sdkp->zoned == 2 && sdkp->first_scan)
+- sd_printk(KERN_NOTICE, sdkp,
+- "Drive-managed SMR disk\n");
++ /* Regular disk or drive managed disk */
++ blk_queue_set_zoned(sdkp->disk, BLK_ZONED_NONE);
+ }
+ }
+- if (blk_queue_is_zoned(q) && sdkp->first_scan)
++
++ if (!sdkp->first_scan)
++ goto out;
++
++ if (blk_queue_is_zoned(q)) {
+ sd_printk(KERN_NOTICE, sdkp, "Host-%s zoned block device\n",
+ q->limits.zoned == BLK_ZONED_HM ? "managed" : "aware");
++ } else {
++ if (sdkp->zoned == 1)
++ sd_printk(KERN_NOTICE, sdkp,
++ "Host-aware SMR disk used as regular disk\n");
++ else if (sdkp->zoned == 2)
++ sd_printk(KERN_NOTICE, sdkp,
++ "Drive-managed SMR disk\n");
++ }
+
+ out:
+ kfree(buffer);
+--- a/drivers/scsi/sd.h
++++ b/drivers/scsi/sd.h
+@@ -260,7 +260,7 @@ static inline blk_status_t sd_zbc_setup_
+ static inline unsigned int sd_zbc_complete(struct scsi_cmnd *cmd,
+ unsigned int good_bytes, struct scsi_sense_hdr *sshdr)
+ {
+- return 0;
++ return good_bytes;
+ }
+
+ static inline blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd,
+--- a/drivers/scsi/sd_zbc.c
++++ b/drivers/scsi/sd_zbc.c
+@@ -645,9 +645,18 @@ static int sd_zbc_revalidate_zones(struc
+ unsigned int nr_zones)
+ {
+ struct gendisk *disk = sdkp->disk;
++ struct request_queue *q = disk->queue;
++ u32 max_append;
+ int ret = 0;
+
+ /*
++ * There is nothing to do for regular disks, including host-aware disks
++ * that have partitions.
++ */
++ if (!blk_queue_is_zoned(q))
++ return 0;
++
++ /*
+ * Make sure revalidate zones are serialized to ensure exclusive
+ * updates of the scsi disk data.
+ */
+@@ -681,6 +690,19 @@ static int sd_zbc_revalidate_zones(struc
+ kvfree(sdkp->rev_wp_offset);
+ sdkp->rev_wp_offset = NULL;
+
++ if (ret) {
++ sdkp->zone_blocks = 0;
++ sdkp->nr_zones = 0;
++ sdkp->capacity = 0;
++ goto unlock;
++ }
++
++ max_append = min_t(u32, logical_to_sectors(sdkp->device, zone_blocks),
++ q->limits.max_segments << (PAGE_SHIFT - 9));
++ max_append = min_t(u32, max_append, queue_max_hw_sectors(q));
++
++ blk_queue_max_zone_append_sectors(q, max_append);
++
+ unlock:
+ mutex_unlock(&sdkp->rev_mutex);
+
+@@ -693,7 +715,6 @@ int sd_zbc_read_zones(struct scsi_disk *
+ struct request_queue *q = disk->queue;
+ unsigned int nr_zones;
+ u32 zone_blocks = 0;
+- u32 max_append;
+ int ret;
+
+ if (!sd_is_zoned(sdkp))
+@@ -726,20 +747,6 @@ int sd_zbc_read_zones(struct scsi_disk *
+ if (ret)
+ goto err;
+
+- /*
+- * On the first scan 'chunk_sectors' isn't setup yet, so calling
+- * blk_queue_max_zone_append_sectors() will result in a WARN(). Defer
+- * this setting to the second scan.
+- */
+- if (sdkp->first_scan)
+- return 0;
+-
+- max_append = min_t(u32, logical_to_sectors(sdkp->device, zone_blocks),
+- q->limits.max_segments << (PAGE_SHIFT - 9));
+- max_append = min_t(u32, max_append, queue_max_hw_sectors(q));
+-
+- blk_queue_max_zone_append_sectors(q, max_append);
+-
+ return 0;
+
+ err:
+--- a/include/linux/blkdev.h
++++ b/include/linux/blkdev.h
+@@ -354,6 +354,8 @@ struct queue_limits {
+ typedef int (*report_zones_cb)(struct blk_zone *zone, unsigned int idx,
+ void *data);
+
++void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model);
++
+ #ifdef CONFIG_BLK_DEV_ZONED
+
+ #define BLK_ALL_ZONES ((unsigned int)-1)
--- /dev/null
+From 6c5dee18756b4721ac8518c69b22ee8ac0c9c442 Mon Sep 17 00:00:00 2001
+From: Damien Le Moal <damien.lemoal@wdc.com>
+Date: Tue, 15 Sep 2020 16:33:47 +0900
+Subject: scsi: sd: sd_zbc: Fix ZBC disk initialization
+
+From: Damien Le Moal <damien.lemoal@wdc.com>
+
+commit 6c5dee18756b4721ac8518c69b22ee8ac0c9c442 upstream.
+
+Make sure to call sd_zbc_init_disk() when the sdkp->zoned field is known,
+that is, once sd_read_block_characteristics() is executed in
+sd_revalidate_disk(), so that host-aware disks also get initialized. To do
+so, move sd_zbc_init_disk() call in sd_zbc_revalidate_zones() and make sure
+to execute it for all zoned disks, including for host-aware disks used as
+regular disks as these disk zoned model may be changed back to BLK_ZONED_HA
+when partitions are deleted.
+
+Link: https://lore.kernel.org/r/20200915073347.832424-3-damien.lemoal@wdc.com
+Fixes: 5795eb443060 ("scsi: sd_zbc: emulate ZONE_APPEND commands")
+Cc: <stable@vger.kernel.org> # v5.8+
+Reported-by: Borislav Petkov <bp@alien8.de>
+Tested-by: Borislav Petkov <bp@suse.de>
+Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
+Reviewed-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/scsi/sd.c | 4 --
+ drivers/scsi/sd.h | 12 ------
+ drivers/scsi/sd_zbc.c | 94 +++++++++++++++++++++++++++-----------------------
+ 3 files changed, 52 insertions(+), 58 deletions(-)
+
+--- a/drivers/scsi/sd.c
++++ b/drivers/scsi/sd.c
+@@ -3404,10 +3404,6 @@ static int sd_probe(struct device *dev)
+ sdkp->first_scan = 1;
+ sdkp->max_medium_access_timeouts = SD_MAX_MEDIUM_TIMEOUTS;
+
+- error = sd_zbc_init_disk(sdkp);
+- if (error)
+- goto out_free_index;
+-
+ sd_revalidate_disk(gd);
+
+ gd->flags = GENHD_FL_EXT_DEVT;
+--- a/drivers/scsi/sd.h
++++ b/drivers/scsi/sd.h
+@@ -213,7 +213,6 @@ static inline int sd_is_zoned(struct scs
+
+ #ifdef CONFIG_BLK_DEV_ZONED
+
+-int sd_zbc_init_disk(struct scsi_disk *sdkp);
+ void sd_zbc_release_disk(struct scsi_disk *sdkp);
+ extern int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buffer);
+ extern void sd_zbc_print_zones(struct scsi_disk *sdkp);
+@@ -229,17 +228,6 @@ blk_status_t sd_zbc_prepare_zone_append(
+
+ #else /* CONFIG_BLK_DEV_ZONED */
+
+-static inline int sd_zbc_init(void)
+-{
+- return 0;
+-}
+-
+-static inline int sd_zbc_init_disk(struct scsi_disk *sdkp)
+-{
+- return 0;
+-}
+-
+-static inline void sd_zbc_exit(void) {}
+ static inline void sd_zbc_release_disk(struct scsi_disk *sdkp) {}
+
+ static inline int sd_zbc_read_zones(struct scsi_disk *sdkp,
+--- a/drivers/scsi/sd_zbc.c
++++ b/drivers/scsi/sd_zbc.c
+@@ -633,6 +633,45 @@ static int sd_zbc_check_capacity(struct
+ return 0;
+ }
+
++void sd_zbc_print_zones(struct scsi_disk *sdkp)
++{
++ if (!sd_is_zoned(sdkp) || !sdkp->capacity)
++ return;
++
++ if (sdkp->capacity & (sdkp->zone_blocks - 1))
++ sd_printk(KERN_NOTICE, sdkp,
++ "%u zones of %u logical blocks + 1 runt zone\n",
++ sdkp->nr_zones - 1,
++ sdkp->zone_blocks);
++ else
++ sd_printk(KERN_NOTICE, sdkp,
++ "%u zones of %u logical blocks\n",
++ sdkp->nr_zones,
++ sdkp->zone_blocks);
++}
++
++static int sd_zbc_init_disk(struct scsi_disk *sdkp)
++{
++ sdkp->zones_wp_offset = NULL;
++ spin_lock_init(&sdkp->zones_wp_offset_lock);
++ sdkp->rev_wp_offset = NULL;
++ mutex_init(&sdkp->rev_mutex);
++ INIT_WORK(&sdkp->zone_wp_offset_work, sd_zbc_update_wp_offset_workfn);
++ sdkp->zone_wp_update_buf = kzalloc(SD_BUF_SIZE, GFP_KERNEL);
++ if (!sdkp->zone_wp_update_buf)
++ return -ENOMEM;
++
++ return 0;
++}
++
++void sd_zbc_release_disk(struct scsi_disk *sdkp)
++{
++ kvfree(sdkp->zones_wp_offset);
++ sdkp->zones_wp_offset = NULL;
++ kfree(sdkp->zone_wp_update_buf);
++ sdkp->zone_wp_update_buf = NULL;
++}
++
+ static void sd_zbc_revalidate_zones_cb(struct gendisk *disk)
+ {
+ struct scsi_disk *sdkp = scsi_disk(disk);
+@@ -650,6 +689,19 @@ static int sd_zbc_revalidate_zones(struc
+ int ret = 0;
+
+ /*
++ * For all zoned disks, initialize zone append emulation data if not
++ * already done. This is necessary also for host-aware disks used as
++ * regular disks due to the presence of partitions as these partitions
++ * may be deleted and the disk zoned model changed back from
++ * BLK_ZONED_NONE to BLK_ZONED_HA.
++ */
++ if (sd_is_zoned(sdkp) && !sdkp->zone_wp_update_buf) {
++ ret = sd_zbc_init_disk(sdkp);
++ if (ret)
++ return ret;
++ }
++
++ /*
+ * There is nothing to do for regular disks, including host-aware disks
+ * that have partitions.
+ */
+@@ -754,45 +806,3 @@ err:
+
+ return ret;
+ }
+-
+-void sd_zbc_print_zones(struct scsi_disk *sdkp)
+-{
+- if (!sd_is_zoned(sdkp) || !sdkp->capacity)
+- return;
+-
+- if (sdkp->capacity & (sdkp->zone_blocks - 1))
+- sd_printk(KERN_NOTICE, sdkp,
+- "%u zones of %u logical blocks + 1 runt zone\n",
+- sdkp->nr_zones - 1,
+- sdkp->zone_blocks);
+- else
+- sd_printk(KERN_NOTICE, sdkp,
+- "%u zones of %u logical blocks\n",
+- sdkp->nr_zones,
+- sdkp->zone_blocks);
+-}
+-
+-int sd_zbc_init_disk(struct scsi_disk *sdkp)
+-{
+- if (!sd_is_zoned(sdkp))
+- return 0;
+-
+- sdkp->zones_wp_offset = NULL;
+- spin_lock_init(&sdkp->zones_wp_offset_lock);
+- sdkp->rev_wp_offset = NULL;
+- mutex_init(&sdkp->rev_mutex);
+- INIT_WORK(&sdkp->zone_wp_offset_work, sd_zbc_update_wp_offset_workfn);
+- sdkp->zone_wp_update_buf = kzalloc(SD_BUF_SIZE, GFP_KERNEL);
+- if (!sdkp->zone_wp_update_buf)
+- return -ENOMEM;
+-
+- return 0;
+-}
+-
+-void sd_zbc_release_disk(struct scsi_disk *sdkp)
+-{
+- kvfree(sdkp->zones_wp_offset);
+- sdkp->zones_wp_offset = NULL;
+- kfree(sdkp->zone_wp_update_buf);
+- sdkp->zone_wp_update_buf = NULL;
+-}
pipe-remove-pipe_wait-and-fix-wakeup-race-with-splic.patch
random32-restore-__latent_entropy-attribute-on-net_r.patch
gpiolib-fix-line-event-handling-in-syscall-compatibl.patch
+drm-i915-gvt-fix-port-number-for-bdw-on-edid-region-setup.patch
+scsi-sd-sd_zbc-fix-handling-of-host-aware-zbc-disks.patch
+scsi-sd-sd_zbc-fix-zbc-disk-initialization.patch