Received: by 10.213.65.68 with SMTP id h4csp276824imn; Fri, 23 Mar 2018 04:32:51 -0700 (PDT) X-Google-Smtp-Source: AG47ELtvZiidYAyoAV8nQjBrMjUELIsiiUXDCt+HROcE/yGcMNHbbMXXgRavFUDVwzmy1QDw8M4U X-Received: by 10.99.112.25 with SMTP id l25mr6590965pgc.412.1521804771190; Fri, 23 Mar 2018 04:32:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521804771; cv=none; d=google.com; s=arc-20160816; b=ltH73bOyrd1b7c3wcWiWL4wMd/E8iv/S6ZWfrijiupJqD2dc3Uvlq+1dXEfHvn7zxQ VFTr78p34DhCVbjHcSMfV2Js87YJoLS62NbbUOG6ynWxhISJnTvV4lQHYG4QYRQ0eOmA XE+xsp5WjlnbH78zOmzR0N69De8zXO3nSdY9HhW9HrkBMVknl5XHJ2qVAX2vuyu/3+Y8 twNCq+UKYnlq4O1xQuNkP0xIwcnTi9r2SHwVwBRMd6qJjBxk4Mx5krl14YgAHmBEZllO EwmJd0CFQUCxgi1SF62fZ3qtILk+v8VskksP9w5pj1S3ID+fYa3K+ofclehhL/7f7pmg He0g== 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=QfCFCc82uiMLEtJtXMIJMIAL3arcdQ8qLGbEW+3yWWE=; b=Dcj8vQBorqw57m81KB7ntaJcMnlG7CtMnYBfXsMmfS+EapQbNXj2D1NyOOOfPy2bRv 1RB336HfPs1pc+Zafr3T/ABNNGdClwAbPRroCoAhFZT0VDwDXkw2OoBTH2pw/vsexM58 MI69L6Pg0/3gjFesQlNrJ/hZh5R0zYkoFLfrh3UCnlB6PLDdoYBA6rDYZWEtZohdeML4 SepEU790z8NJuTEgAAFiUtzxTao00Fk52rLAwNW0WTozoGrYuwzdzH1CxmpZWwpmADMF m1TEvm+B2Jx7isDD659rwl9FyRx4XaAnSv4+pXVfE5a6u+/Ptm3Mk1UQra4acP1FiicS v19Q== 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 w128si6515917pfw.415.2018.03.23.04.32.36; Fri, 23 Mar 2018 04:32:51 -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 S1755149AbeCWKGA (ORCPT + 99 others); Fri, 23 Mar 2018 06:06:00 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40582 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755081AbeCWKFx (ORCPT ); Fri, 23 Mar 2018 06:05:53 -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 07780CD1; Fri, 23 Mar 2018 10:05:52 +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.9 032/177] scsi: virtio_scsi: Always try to read VPD pages Date: Fri, 23 Mar 2018 10:52:40 +0100 Message-Id: <20180323094206.594552915@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094205.090519271@linuxfoundation.org> References: <20180323094205.090519271@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.9-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 @@ -705,6 +706,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 @@ -776,6 +799,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,