Received: by 10.213.65.68 with SMTP id h4csp248269imn; Fri, 23 Mar 2018 03:53:44 -0700 (PDT) X-Google-Smtp-Source: AG47ELun5hoBuTjX0VFd7Yqwlh0HWC1ERWJKx3Cj1bJ1IpcTr/NVWvjKUwWowaZecmpwjjNkh8S4 X-Received: by 10.101.96.134 with SMTP id t6mr10103137pgu.58.1521802424861; Fri, 23 Mar 2018 03:53:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521802424; cv=none; d=google.com; s=arc-20160816; b=dpkGXxHw74ttC9Byg5L4+oJcoF9awko+iCX969oazfRmQI9jg0p+A4Q9KtSbj6Rr9T 1z500cOWRBpQF0LghH2DU3K8/IaHXuXvxdGl+Yl/PLWeZ9oyUVfZZxi3UqNpu8oM0CQ5 eRldsCMzdT8As1sn77F4veUtVm1IlWk2ugXMfeC3X86OZB0VTQ1UhRlYG3ooTqSyBntJ nAvbBhiuf/dNIJi5L5+SOGEIXFbT1AibbM1OJ9k12f0J+myhgluu/2bhpEDidKsy8mDb tk9hXFI/1K5SWnbfTCQVX8IFYtYLf3qu4bkXnM2fulJoPVxu5QpztAKGn0yIoGVBoNwc Gr7w== 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=eW6w2kDYuzHzUE2CVyst3Ze74PkzGadryGNFIz/pl94=; b=l+IYyicPK0ElQx5qXrr00Xib/JruUmDERlHhk4oNZL3fKrOnTUCDhP0anUc8F2kXEJ B+Hx6CYriLttHoHzFe8QWoUf050ls1zYAKsVKS6t6+8eFxKiM/ChSAGar4rj65Ypr4Y6 5jwVNnZG7vnPH9r3B3fs3AH4mc+dRzbwOky5eL8GmvfT5CJCuOW5BliSjB0hDDCOK3mL Jnbm2Y8jSSSA1iAemOccz0srJ7+yonEgDiqgl+CAuJVMCXmm9SiDatKf5ITQnCPhr7Pa hICw7yRK5zZXStH8trgmDudZtu0EBzVRt5X/+MUr15okaLCDG6tvaGUntrlYXQva/AG8 gaWw== 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 c1-v6si8142184plz.102.2018.03.23.03.53.30; Fri, 23 Mar 2018 03:53:44 -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 S933190AbeCWKO0 (ORCPT + 99 others); Fri, 23 Mar 2018 06:14:26 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45174 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756007AbeCWKOX (ORCPT ); Fri, 23 Mar 2018 06:14:23 -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 A63071224; Fri, 23 Mar 2018 10:14:22 +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 4.4 22/97] scsi: virtio_scsi: Always try to read VPD pages Date: Fri, 23 Mar 2018 10:54:09 +0100 Message-Id: <20180323094158.812011199@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094157.535925724@linuxfoundation.org> References: <20180323094157.535925724@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 4.4-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 @@ -704,6 +705,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 @@ -775,6 +798,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,