--- zzzz-none-000/linux-4.19.183/drivers/scsi/sd.c 2021-03-24 10:07:39.000000000 +0000 +++ bcm63-7530ax-756/linux-4.19.183/drivers/scsi/sd.c 2023-06-28 08:54:19.000000000 +0000 @@ -301,6 +301,19 @@ } static DEVICE_ATTR_RO(FUA); + +#if defined(CONFIG_BCM_KF_SCSI_WRITE_PROTECT) && defined(CONFIG_BCM_SCSI_WRITE_PROTECT) +static ssize_t +write_protect_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct scsi_disk *sdkp = to_scsi_disk(dev); + + return sprintf(buf, "%u\n", sdkp->write_prot); +} +static DEVICE_ATTR_RO(write_protect); +#endif + + static ssize_t protection_type_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -531,6 +544,9 @@ static struct attribute *sd_disk_attrs[] = { &dev_attr_cache_type.attr, &dev_attr_FUA.attr, +#if defined(CONFIG_BCM_KF_SCSI_WRITE_PROTECT) && defined(CONFIG_BCM_SCSI_WRITE_PROTECT) + &dev_attr_write_protect.attr, +#endif &dev_attr_allow_restart.attr, &dev_attr_manage_start_stop.attr, &dev_attr_protection_type.attr, @@ -1575,9 +1591,13 @@ if (scsi_block_when_processing_errors(sdp)) { struct scsi_sense_hdr sshdr = { 0, }; - retval = scsi_test_unit_ready(sdp, SD_TIMEOUT, SD_MAX_RETRIES, - &sshdr); - + /* == 20210722 AVM/WKR - CHANGESET: STORAGE fix: TUR prevented STOP_UNIT on some hard_disks ==*/ + if (IS_ENABLED(CONFIG_AVM_KERNEL) && (!sdp->removable && sdkp->media_present)) { + retval = 0; + } else { + retval = scsi_test_unit_ready(sdp, SD_TIMEOUT, SD_MAX_RETRIES, + &sshdr); + } /* failed to execute TUR, assume media not present */ if (host_byte(retval)) { set_media_not_present(sdkp);