Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp539090ybb; Thu, 28 Mar 2019 07:25:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyN+rgoYUo7W01Nfc5Ec8ToOW5W1eLJrlXZDV/dl8cg/JusBqHlRSjMNnE6NJ7AR1vFgyys X-Received: by 2002:a65:6489:: with SMTP id e9mr24896516pgv.364.1553783147916; Thu, 28 Mar 2019 07:25:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553783147; cv=none; d=google.com; s=arc-20160816; b=HB9tcEbj6kef8eXPTUa2U3kJQ7+9/+zTzsucrHiOdVUN+R/FAhoa6s6A30TLFFKsow wFhARcFNDUMv2sPnTzpiMfm9LFdI1yIWsHPJV+Dvv7FdkKDcEVYMgmZCZUW2CT3YGVBk 3BB82UhZoB59bE3O43IxDOM++Erhk3Tz8hJLY6RIa5jNzh+gAF27HWscwE4IymKRW5ox hpOQ1P9TWSf00MRCfLv2k0BXT1uQ8gpOM1qNn/sa+3jY3qWwAjjfoYxfT1MhvyzVLn4v nsX8A7WTF3Wn1qOb/aMScgaw+HveJoidXNQX4VxTDL6Ia3A2nJPqMKekt4bqa9Jrj1ta /OeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=knP2kYlxVBKdIyjtsNetwud8bh9DYn8imArZXQOJl7Q=; b=pp+EwBqLPGkXEZx2TxV8/XEwHpWh7qRCCIrGwsJGduqxTi4JqS/vzMOicv3qqc9nUe rvPcIUrBX5nehMath/4Jb7zMneo1rkSXBnI71DllZxLbI5LaSZ6EhQjOemp6bEp+QKak V3mPyCCLGzkcEm1eURalr1OSq+X/g4wDKwwmfXQJai1Y+rHdnvHS+fTyJ7jRYb2X2HqH btZ5ExLbNVwddIczMW1dWdHXbe0GIuOZvtBVpKsJ/GIAVZWHTWZknRWqZq/jsxM3dhzN a4j6iB/BPkygbH0YU9MiAwM+qJt+2cmUwdop6at4KXqhjhVoKsW59WazivpkLlbEDq38 BrWw== 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 78si732013pga.566.2019.03.28.07.25.31; Thu, 28 Mar 2019 07:25:47 -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 S1726252AbfC1OYr (ORCPT + 99 others); Thu, 28 Mar 2019 10:24:47 -0400 Received: from mx2.suse.de ([195.135.220.15]:57632 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725875AbfC1OYr (ORCPT ); Thu, 28 Mar 2019 10:24:47 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CFD2DAEF2; Thu, 28 Mar 2019 14:24:44 +0000 (UTC) Subject: Re: [Qemu-devel] megasas: Unexpected response from lun 1 while scanning, scan aborted To: Dongli Zhang Cc: qemu-block@nongnu.org, linux-scsi@vger.kernel.org, megaraidlinux.pdl@broadcom.com, linux-kernel@vger.kernel.org, qemu-devel@nongnu.org References: <9c3849cf-86c6-4568-bff5-1050b445322d@default> <442316ee-8800-275c-85e9-a5d054a28e63@oracle.com> From: Hannes Reinecke Message-ID: <78e04dbb-de4f-3d1b-973d-6cb906a13e42@suse.de> Date: Thu, 28 Mar 2019 15:24:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <442316ee-8800-275c-85e9-a5d054a28e63@oracle.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/28/19 1:47 AM, Dongli Zhang wrote: > > > On 3/27/19 7:31 PM, Hannes Reinecke wrote: >> On 3/26/19 5:47 PM, Dongli Zhang wrote: >>> I am reporting an error that the scsi lun cannot initialize successfully when I >>> am emulating megasas scsi controller with qemu. >>> >>> I am not sure if this is issue in qemu or linux kernel. >>> >>> When 'lun=1' is specified, there is "Unexpected response from lun 1 while >>> scanning, scan aborted". >>> >>> Everything works well if 'lun=0' is specified. >>> >>> >>> Below is the qemu cmdline involved: >>> >>> -device megasas,id=scsi0 \ >>> -device scsi-hd,drive=drive0,bus=scsi0.0,lun=1 \ >>> -drive file=/home/zhang/img/test.img,if=none,id=drive0,format=raw >>> >>> >>> Below is the syslog related to 'scsi|SCSI' >>> >>> # dmesg | grep SCSI >>> [    0.392494] SCSI subsystem initialized >>> [    0.460666] Block layer SCSI generic (bsg) driver version 0.4 loaded (major >>> 251) >>> [    0.706788] sd 1:0:0:0: [sda] Attached SCSI disk >>> # dmesg | grep scsi >>> [    0.511643] scsi host0: Avago SAS based MegaRAID driver >>> [    0.523302] scsi 0:2:0:0: Unexpected response from lun 1 while scanning, >>> scan aborted >>> [    0.540364] scsi host1: ata_piix >>> [    0.540780] scsi host2: ata_piix >>> [    0.702396] scsi 1:0:0:0: Direct-Access     ATA      QEMU HARDDISK    2.5+ >>> PQ: 0 ANSI: 5 >>> >>> When 'lun=1' is changed to 'lun=0', there is no issue. >>> >>> Thank you very much! >>> >> That's an artifact from the megasas emulation in quemu. >> Megasas (internally) can't handle LUN numbers (the RAID part only knows about >> 'disks'), so I took the decision to not expose devices with LUN != 0. >> Please use a different SCSI target number, not a non-zero LUN number. > > The guest kernel is able to detect the disk if lun is always 0, while target > number is changed: > > -device scsi-hd,drive=drive0,bus=scsi0.0,channel=0,scsi-id=0,lun=0 > -device scsi-hd,drive=drive1,bus=scsi0.0,channel=0,scsi-id=1,lun=0 > > # dmesg | grep scsi > [ 0.935999] scsi host0: ata_piix > [ 0.936401] scsi host1: ata_piix > [ 1.100945] scsi 0:0:0:0: Direct-Access ATA QEMU HARDDISK 2.5+ > PQ: 0 ANSI: 5 > [ 1.102409] sd 0:0:0:0: Attached scsi generic sg0 type 0 > [ 1.672952] scsi host2: Avago SAS based MegaRAID driver > [ 1.683886] scsi 2:2:0:0: Direct-Access QEMU QEMU HARDDISK 2.5+ > PQ: 0 ANSI: 5 > [ 1.684915] scsi 2:2:1:0: Direct-Access QEMU QEMU HARDDISK 2.5+ > PQ: 0 ANSI: 5 > [ 1.701529] sd 2:2:0:0: Attached scsi generic sg1 type 0 > [ 1.704795] sd 2:2:1:0: Attached scsi generic sg2 type 0 > # dmesg | grep SCSI > [ 0.111015] SCSI subsystem initialized > [ 0.904712] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 246) > [ 1.121174] sd 0:0:0:0: [sda] Attached SCSI disk > [ 1.703739] sd 2:2:0:0: [sdb] Attached SCSI disk > [ 1.706964] sd 2:2:1:0: [sdc] Attached SCSI disk > > > > If device with LUN != 0 will not be exposed, why not set max_lun = 0 as what > qemu lsi is doing? > > diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c > index a56317e..c966ee0 100644 > --- a/hw/scsi/megasas.c > +++ b/hw/scsi/megasas.c > @@ -2298,7 +2298,7 @@ static void megasas_scsi_uninit(PCIDevice *d) > static const struct SCSIBusInfo megasas_scsi_info = { > .tcq = true, > .max_target = MFI_MAX_LD, > - .max_lun = 255, > + .max_lun = 0, > > .transfer_data = megasas_xfer_complete, > .get_sg_list = megasas_get_sg_list, > Hmm. Good point. In _theory_ one could just jbod mode, in which case _all_ LUNs are exposed. But then we could probably adjust it, based on which mode is selected. I'll check. Cheers, Hannes -- Dr. Hannes Reinecke Teamlead Storage & Networking hare@suse.de +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg)