Received: by 10.213.65.68 with SMTP id h4csp237215imn; Fri, 23 Mar 2018 03:36:34 -0700 (PDT) X-Google-Smtp-Source: AG47ELuSLR3NAaK6cZhSoHPQ56nktXzsKjDx0sxnJr0gHVdvdHboQfqD2d0+T5Bj1Bu5Uwm/lKUP X-Received: by 10.101.74.136 with SMTP id b8mr7262763pgu.260.1521801394877; Fri, 23 Mar 2018 03:36:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521801394; cv=none; d=google.com; s=arc-20160816; b=mPnzAxVOa/awyDeZxSny3cfI7JnWwKmnSvCQCmasUdar92GXhcJfWLjiQx7xxnE7Tc 7/CkXzPofCR0tXPizT+RG9kZiD94Mdw/z5Tj/ZCy8+v1nnNINl0ChUru2fls9i7V30t2 d2hMnnm0dlczq8Iswj7yL3F2fIt9un4Wb3ISZ5gDUneB3yvDvF506ET4wGDN7bKuSwWV 6vJWG6kx3+Fu2esB+EDXRS0mb3VKiMWGMRiKNOHcQY3bUxjrrFAPTiR2ioS8SvBc9zq0 mNf4VTLaNu3gdC9NPbzo9oZcLTnKj/DYqxel0kaDCpxGqUW+np+f9TnkMKdLLQj9mJCg GnTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=B13j0NPpD4wwVnHBwioEIf1zbfq3h0cM/clJT7O5rt0=; b=nQkCiok4e40zWqHFpkN1a4zYP9RpUE2ZAOHLHBC24FBkTFLEyHFOig4AqSTVyspkAH R1yqNsVjBKoxiYr8EoERyrt+UKTizBd3/vq3eIsPypL0gUUOCAoPulONf+RDpN/XcHGR HXUUHMAlOIr1T5HsHKC535C0LLAY68k8gWVsBRS0rY5gec/5kHpTKrYFqXudLbH6WyR3 8Dj+lQawBFGxNmkSec27OpUv/cz6KZFi7k+mU/3PwBRkpmUAf6F8BiRv/kXYj6piVp/E wc8u7gNZKmAqxitUo5ZddVdI2D3/QGhSeeeqMdT2b8+M9Lb8ygcvrgLlTa068S73Vh9M or5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 75si5859593pga.647.2018.03.23.03.36.20; Fri, 23 Mar 2018 03:36:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756110AbeCWKfU (ORCPT + 99 others); Fri, 23 Mar 2018 06:35:20 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47440 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933870AbeCWKR6 (ORCPT ); Fri, 23 Mar 2018 06:17:58 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id AFAAAF12; Fri, 23 Mar 2018 10:17:57 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Gibson , Paolo Bonzini , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 3.18 12/47] scsi: virtio_scsi: Always try to read VPD pages Date: Fri, 23 Mar 2018 10:55:03 +0100 Message-Id: <20180323094248.649887397@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094248.117679641@linuxfoundation.org> References: <20180323094248.117679641@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Gibson [ Upstream commit 25d1d50e23275e141e3a3fe06c25a99f4c4bf4e0 ] Passed through SCSI targets may have transfer limits which come from the host SCSI controller or something on the host side other than the target itself. To make this work properly, the hypervisor can adjust the target's VPD information to advertise these limits. But for that to work, the guest has to look at the VPD pages, which we won't do by default if it is an SPC-2 device, even if it does actually support it. This adds a workaround to address this, forcing devices attached to a virtio-scsi controller to always check the VPD pages. This is modelled on a similar workaround for the storvsc (Hyper-V) SCSI controller, although that exists for slightly different reasons. A specific case which causes this is a volume from IBM's IPR RAID controller (which presents as an SPC-2 device, although it does support VPD) passed through with qemu's 'scsi-block' device. [mkp: fixed typo] Signed-off-by: David Gibson Acked-by: Paolo Bonzini Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/virtio_scsi.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #define VIRTIO_SCSI_MEMPOOL_SZ 64 @@ -664,6 +665,28 @@ static int virtscsi_device_reset(struct return virtscsi_tmf(vscsi, cmd); } +static int virtscsi_device_alloc(struct scsi_device *sdevice) +{ + /* + * Passed through SCSI targets (e.g. with qemu's 'scsi-block') + * may have transfer limits which come from the host SCSI + * controller or something on the host side other than the + * target itself. + * + * To make this work properly, the hypervisor can adjust the + * target's VPD information to advertise these limits. But + * for that to work, the guest has to look at the VPD pages, + * which we won't do by default if it is an SPC-2 device, even + * if it does actually support it. + * + * So, set the blist to always try to read the VPD pages. + */ + sdevice->sdev_bflags = BLIST_TRY_VPD_PAGES; + + return 0; +} + + /** * virtscsi_change_queue_depth() - Change a virtscsi target's queue depth * @sdev: Virtscsi target whose queue depth to change @@ -752,6 +775,7 @@ static struct scsi_host_template virtscs .change_queue_depth = virtscsi_change_queue_depth, .eh_abort_handler = virtscsi_abort, .eh_device_reset_handler = virtscsi_device_reset, + .slave_alloc = virtscsi_device_alloc, .can_queue = 1024, .dma_boundary = UINT_MAX,