From patchwork Fri Jul 14 10:59:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1807731 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hZsAKdqo; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R2T6s6CgKz20cB for ; Fri, 14 Jul 2023 21:01:09 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qKGWu-0006vz-PL; Fri, 14 Jul 2023 07:00:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKGWs-0006vD-Ep for qemu-devel@nongnu.org; Fri, 14 Jul 2023 07:00:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKGWn-00059J-Oa for qemu-devel@nongnu.org; Fri, 14 Jul 2023 07:00:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689332400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LIaN5QbqMfJRoUfWCwELYAOMsonyWMKqvnsX5ZBOVyo=; b=hZsAKdqonjM81OK+eKRX+l/RjqDI/EAjcFgIGDrGjVF5Psij4c7nRLsYNLU1vhQr4kOGD7 4jB8nyoWHaoOKhYTeEhxi//YCpwfmpMqU3go2+dMBrTced2vwDFps8qE7Xpwjmgat4Ux+4 iIqvOk33MGd2t9a8ndsWEOe4iv4LBGA= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-591-ptdcfYj0P3qM6e7gLoyBLw-1; Fri, 14 Jul 2023 06:59:59 -0400 X-MC-Unique: ptdcfYj0P3qM6e7gLoyBLw-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3fa976b8b6fso9719085e9.3 for ; Fri, 14 Jul 2023 03:59:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689332397; x=1691924397; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LIaN5QbqMfJRoUfWCwELYAOMsonyWMKqvnsX5ZBOVyo=; b=hrSCkZTo/xSNnor+ZMsmvEUZF+d/WrYhaI5daI2k7sowtbql2tnTdrvV1s8ncPDwdF hqKU40d5PQ1iyiSpQYR9eZRRquEKRJ0w9nG0ieja1aqKWQjn6v3ajn/gJDf0TGBUJJEd 9Z8yT5ft7f2YXQmhVJ/7GLMRoBYW/SqW8Ue8MFP6+4AeSMzmEoQt80mqBZCDgYDIR/4e Pe1VnQWxS48VCXo1Tj0s4We5d5lD6HrAURlYsB3yDRxAV/W97V4k6sWycen3W4Slvu1i 8GX/YqBj5wDRHo9L4AX5ZDwnT4a2rWVv/tfqC2oYxODwibsuCKw/ee+8H1/HdXrmDfrO Vrnw== X-Gm-Message-State: ABy/qLYYTBz9AHRISpOxHATV+sjDYoXKU1eftFQkmJRwwnbf43WOXMyI M5acep7k/P+xJMlqPm2uMReObSuh0Dyg73mR7UjjgHLn9LRactyR/ValniEkwReFLbGyPB01KkQ 2oUV7agnVjiRcw3ulV3tLICi6GxguWPK/xlOBJdGSMrRcZ2C8gWHXT3yjlj0j9E45UKPwgus4rc k= X-Received: by 2002:a05:600c:21c4:b0:3fb:b3f8:506b with SMTP id x4-20020a05600c21c400b003fbb3f8506bmr3719983wmj.24.1689332397482; Fri, 14 Jul 2023 03:59:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlEKqDmnaK25g9vSJmecSj+4wPjjaoRo5ReIXaKbKFABjCKPAaMTXJ9vGJmChfK/FxpETvF/vw== X-Received: by 2002:a05:600c:21c4:b0:3fb:b3f8:506b with SMTP id x4-20020a05600c21c400b003fbb3f8506bmr3719964wmj.24.1689332397061; Fri, 14 Jul 2023 03:59:57 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id m17-20020a7bce11000000b003fc07e17d4esm1184717wmc.2.2023.07.14.03.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 03:59:56 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Olaf Hering , Bernhard Beschow , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 1/5] hw/ide/piix: properly initialize the BMIBA register Date: Fri, 14 Jul 2023 12:59:49 +0200 Message-ID: <20230714105953.223485-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230714105953.223485-1-pbonzini@redhat.com> References: <20230714105953.223485-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Olaf Hering According to the 82371FB documentation (82371FB.pdf, 2.3.9. BMIBA-BUS MASTER INTERFACE BASE ADDRESS REGISTER, April 1997), the register is 32bit wide. To properly reset it to default values, all 32bit need to be cleared. Bit #0 "Resource Type Indicator (RTE)" needs to be enabled. The initial change wrote just the lower 8 bit, leaving parts of the "Bus Master Interface Base Address" address at bit 15:4 unchanged. Fixes: e6a71ae327 ("Add support for 82371FB (Step A1) and Improved support for 82371SB (Function 1)") Signed-off-by: Olaf Hering Reviewed-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20230712074721.14728-1-olaf@aepfle.de> Signed-off-by: Paolo Bonzini --- hw/ide/piix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 151f206046e..4e5e12935f5 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -117,7 +117,7 @@ static void piix_ide_reset(DeviceState *dev) pci_set_word(pci_conf + PCI_COMMAND, 0x0000); pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM | PCI_STATUS_FAST_BACK); - pci_set_byte(pci_conf + 0x20, 0x01); /* BMIBA: 20-23h */ + pci_set_long(pci_conf + 0x20, 0x1); /* BMIBA: 20-23h */ } static bool pci_piix_init_bus(PCIIDEState *d, unsigned i, Error **errp) From patchwork Fri Jul 14 10:59:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1807734 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gM++wNo4; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R2T7448Srz20bY for ; Fri, 14 Jul 2023 21:01:20 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qKGX0-0006wH-Dh; Fri, 14 Jul 2023 07:00:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKGWu-0006vi-Cb for qemu-devel@nongnu.org; Fri, 14 Jul 2023 07:00:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKGWq-0005H7-D9 for qemu-devel@nongnu.org; Fri, 14 Jul 2023 07:00:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689332402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gjHq5pV5Ng8uzkPYy0p5CUtaFNNkTOHcIqNt3429rqY=; b=gM++wNo46LWT4O6ZH5CrffGIlKa8YtxD0bQSTSg69Owsr0MvevEye8qvb6lPkVDCKdinyB 7/GQiG+gUOUHTmd4KwJwpNN/oPIZGxsJ88CsRMZMe16eMXvZE/4mksvuTW+9Oxft8AtcdI oFwRiw/smoVll8OjxWvwRUkSWlyL9do= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-335-sCKZCJT3PRq41TOxSvpXig-1; Fri, 14 Jul 2023 07:00:01 -0400 X-MC-Unique: sCKZCJT3PRq41TOxSvpXig-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3f5df65fa35so9875375e9.3 for ; Fri, 14 Jul 2023 04:00:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689332399; x=1691924399; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gjHq5pV5Ng8uzkPYy0p5CUtaFNNkTOHcIqNt3429rqY=; b=f0bN6qf0juiaH/j8w+/3KYCASAgOvUhGOwi4yP/IMm7fY5SM+IgjtYwi0smyruEuC+ eCiH39Sq6CKJUVOMM40eNevTptjBYqQGJH/QdGDMR4Ey3Me+vHd500OY9c7L8yWZS/Ht 358iTMKz1/KNYxOqORiRarKScra9rQtlNP6JA8CApN9fL0c902pEMXGdSJpsflgopis/ aP/cS/4zw4FtqySe2oA9iGdAzS1EHrFxV7ZaC+px7uJZ0z52B/BqykGRCd82zwKDEJqU KVxw2TApK2MIajl6oQgwc8kAMcCpeoVfFKBHncS+44+9MIfowJAkHkQcZrcwvXSiEx1B za6w== X-Gm-Message-State: ABy/qLYKLnodzwiZKsd6puEkeNEC23uaI2TEQAYGKoxem1y4HPCyCOZB xFmlRphTSO6BddEFmkPf2mtPe3F7ETS5gPIpXV2LCKpEAO7/UP8o4e00t1HVbJUnPgmYoXMye1D 6I0W2xC1jqyzzar28nvUpJU+wFQxY0oSYdCKIesPCCD0EIc+EasAn41l/eOOgqCdGo1cYDOyGK8 c= X-Received: by 2002:a05:600c:2254:b0:3fa:984d:7e9f with SMTP id a20-20020a05600c225400b003fa984d7e9fmr3589895wmm.6.1689332399262; Fri, 14 Jul 2023 03:59:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlGlZzZ2mqeqQmUYb0Hki51VmOV0qHbdm/hoT6mO6M85AXbAqjUkBQ6TpJSQ9Suk0xrgWGdIcg== X-Received: by 2002:a05:600c:2254:b0:3fa:984d:7e9f with SMTP id a20-20020a05600c225400b003fa984d7e9fmr3589875wmm.6.1689332398842; Fri, 14 Jul 2023 03:59:58 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id v9-20020a1cf709000000b003fc00892c13sm1151415wmh.35.2023.07.14.03.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 03:59:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Matthew Rosato , Thomas Huth Subject: [PULL 2/5] kconfig: Add PCIe devices to s390x machines Date: Fri, 14 Jul 2023 12:59:50 +0200 Message-ID: <20230714105953.223485-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230714105953.223485-1-pbonzini@redhat.com> References: <20230714105953.223485-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Cédric Le Goater It is useful to extend the number of available PCIe devices to KVM guests for passthrough scenarios and also to expose these models to a different (big endian) architecture. Introduce a new config PCIE_DEVICES to select models, Intel Ethernet adapters and one USB controller. These devices all support MSI-X which is a requirement on s390x as legacy INTx are not supported. Cc: Matthew Rosato Cc: Paolo Bonzini Cc: Thomas Huth Signed-off-by: Cédric Le Goater Message-ID: <20230712080146.839113-1-clg@redhat.com> Signed-off-by: Paolo Bonzini --- configs/devices/s390x-softmmu/default.mak | 1 + hw/net/Kconfig | 4 ++-- hw/pci/Kconfig | 3 +++ hw/s390x/Kconfig | 3 ++- hw/usb/Kconfig | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/configs/devices/s390x-softmmu/default.mak b/configs/devices/s390x-softmmu/default.mak index f2287a133f3..6d87bc8b4b0 100644 --- a/configs/devices/s390x-softmmu/default.mak +++ b/configs/devices/s390x-softmmu/default.mak @@ -7,6 +7,7 @@ #CONFIG_VFIO_CCW=n #CONFIG_VIRTIO_PCI=n #CONFIG_WDT_DIAG288=n +#CONFIG_PCIE_DEVICES=n # Boards: # diff --git a/hw/net/Kconfig b/hw/net/Kconfig index 98e00be4f93..7fcc0d7faa2 100644 --- a/hw/net/Kconfig +++ b/hw/net/Kconfig @@ -41,12 +41,12 @@ config E1000_PCI config E1000E_PCI_EXPRESS bool - default y if PCI_DEVICES + default y if PCI_DEVICES || PCIE_DEVICES depends on PCI_EXPRESS && MSI_NONBROKEN config IGB_PCI_EXPRESS bool - default y if PCI_DEVICES + default y if PCI_DEVICES || PCIE_DEVICES depends on PCI_EXPRESS && MSI_NONBROKEN config RTL8139_PCI diff --git a/hw/pci/Kconfig b/hw/pci/Kconfig index 77f8b005ffb..fe70902cd82 100644 --- a/hw/pci/Kconfig +++ b/hw/pci/Kconfig @@ -8,6 +8,9 @@ config PCI_EXPRESS config PCI_DEVICES bool +config PCIE_DEVICES + bool + config MSI_NONBROKEN # selected by interrupt controllers that do not support MSI, # or support it and have a good implementation. See commit diff --git a/hw/s390x/Kconfig b/hw/s390x/Kconfig index 5e7d8a2bae8..e8d4d68ece0 100644 --- a/hw/s390x/Kconfig +++ b/hw/s390x/Kconfig @@ -5,7 +5,8 @@ config S390_CCW_VIRTIO imply VFIO_AP imply VFIO_CCW imply WDT_DIAG288 - select PCI + imply PCIE_DEVICES + select PCI_EXPRESS select S390_FLIC select SCLPCONSOLE select VIRTIO_CCW diff --git a/hw/usb/Kconfig b/hw/usb/Kconfig index 0ec6def4b8b..0f486764ed6 100644 --- a/hw/usb/Kconfig +++ b/hw/usb/Kconfig @@ -36,7 +36,7 @@ config USB_XHCI config USB_XHCI_PCI bool - default y if PCI_DEVICES + default y if PCI_DEVICES || PCIE_DEVICES depends on PCI select USB_XHCI From patchwork Fri Jul 14 10:59:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1807732 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HYyJgPt2; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R2T6s5tSHz20bY for ; Fri, 14 Jul 2023 21:01:09 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qKGX5-0006xq-Bt; Fri, 14 Jul 2023 07:00:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKGWw-0006wI-Ce for qemu-devel@nongnu.org; Fri, 14 Jul 2023 07:00:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKGWs-0005Jl-7Z for qemu-devel@nongnu.org; Fri, 14 Jul 2023 07:00:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689332404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=62/T52h0VNBTSRACyMK7y1qz0HsHsDe8s3F7BViE+Lo=; b=HYyJgPt2aLZKKrFEJSlVNrRef8TyVGQIO5BnSOYLAKDgvdKvtTbjzaxqpr429kNDXpFQLn h7v7AQPxIgR4Wf3MewlwaED6QFSkg/lBKXvoMrlAowsbKYvUVz7dVmQUqDoY69yyNvSzzj FMXULNJ2Rvf/Y9uMgLfcInRrgJDgvzY= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-336--AzEz3lFNf-LYLHrCDwV1w-1; Fri, 14 Jul 2023 07:00:02 -0400 X-MC-Unique: -AzEz3lFNf-LYLHrCDwV1w-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-314275b653eso1053505f8f.1 for ; Fri, 14 Jul 2023 04:00:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689332401; x=1691924401; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=62/T52h0VNBTSRACyMK7y1qz0HsHsDe8s3F7BViE+Lo=; b=ajFe8DluGpQac6Rje8fcc0pKIYG8DqGsLqfy4EM/BvhUtxKyYCIqD4AxZcDhpjFveL MCN7FxqLYipY+36aNWlqBQViLDdnko2PqUtN00sDDjcF97fwm92ELAfZdBK0hufKTj2y +xLXcpjqqEefqaLsAHASXn7ZiWJe/2ENPjNiEsVIUVtFc87/N+jN6MGaWA+fbdOEeSYy glmwXSRVIGG+jumJ4C/rZbkZ+2hnEOpuu4bDPdD3U5j4gOclPUvARn3s/ak5IINDs63Q 6M/CxqpoR8JlU2sB6I3XS5MIM4LXobQa/LSADdROObJ9Wd9rghnC13Sz80aVTkrtxkxy aW/g== X-Gm-Message-State: ABy/qLb5yEYEIWwfeOkNpCO97lX7q0/eaHnWCtIZNAf+T1fJl7T2XfxS TMYTQyDK78LBBt8T9OK1g0cV3+dUUBulvNtrMamDeNma/HaDtBjMMJrwKaZQztYlYo5nkrnX2pM N0oUpSSMfNPp0neqfkZt+yS14ygQG4w3u/MRvwLTiUBYYKZhjHTBLphoy+Xy554ITNsWNy2Q0NR s= X-Received: by 2002:a5d:66c5:0:b0:315:a34f:b520 with SMTP id k5-20020a5d66c5000000b00315a34fb520mr3359065wrw.71.1689332400906; Fri, 14 Jul 2023 04:00:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlFgs1Ofxo0aMu/qYN9JZtp4wevvNbWovcU7v70J/UD6td8NecV2T6IJOj7VXYgj3cSPsgyzXA== X-Received: by 2002:a5d:66c5:0:b0:315:a34f:b520 with SMTP id k5-20020a5d66c5000000b00315a34fb520mr3359053wrw.71.1689332400531; Fri, 14 Jul 2023 04:00:00 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id p5-20020a5d4e05000000b003143d80d11dsm10460377wrt.112.2023.07.14.03.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 03:59:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Stefano Garzarella , Thomas Huth Subject: [PULL 3/5] scsi: fetch unit attention when creating the request Date: Fri, 14 Jul 2023 12:59:51 +0200 Message-ID: <20230714105953.223485-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230714105953.223485-1-pbonzini@redhat.com> References: <20230714105953.223485-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stefano Garzarella Commit 1880ad4f4e ("virtio-scsi: Batched prepare for cmd reqs") split calls to scsi_req_new() and scsi_req_enqueue() in the virtio-scsi device. No ill effects were observed until commit 8cc5583abe ("virtio-scsi: Send "REPORTED LUNS CHANGED" sense data upon disk hotplug events") added a unit attention that was easy to trigger with device hotplug and hot-unplug. Because the two calls were separated, all requests in the batch were prepared calling scsi_req_new() to report a sense. The first one submitted would report the right sense and reset it to NO_SENSE, while the others reported CHECK_CONDITION with no sense data. This caused SCSI errors in Linux. To solve this issue, let's fetch the unit attention as early as possible when we prepare the request, so that only the first request in the batch will use the unit attention SCSIReqOps and the others will not report CHECK CONDITION. Fixes: 1880ad4f4e ("virtio-scsi: Batched prepare for cmd reqs") Fixes: 8cc5583abe ("virtio-scsi: Send "REPORTED LUNS CHANGED" sense data upon disk hotplug events") Reported-by: Thomas Huth Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2176702 Co-developed-by: Paolo Bonzini Signed-off-by: Stefano Garzarella Message-ID: <20230712134352.118655-2-sgarzare@redhat.com> Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-bus.c | 40 +++++++++++++++++++++++++++++++++++----- include/hw/scsi/scsi.h | 1 + 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index f80f4cb4fcf..f083373021c 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -412,19 +412,35 @@ static const struct SCSIReqOps reqops_invalid_opcode = { /* SCSIReqOps implementation for unit attention conditions. */ +static void scsi_fetch_unit_attention_sense(SCSIRequest *req) +{ + SCSISense *ua = NULL; + + if (req->dev->unit_attention.key == UNIT_ATTENTION) { + ua = &req->dev->unit_attention; + } else if (req->bus->unit_attention.key == UNIT_ATTENTION) { + ua = &req->bus->unit_attention; + } + + /* + * Fetch the unit attention sense immediately so that another + * scsi_req_new does not use reqops_unit_attention. + */ + if (ua) { + scsi_req_build_sense(req, *ua); + *ua = SENSE_CODE(NO_SENSE); + } +} + static int32_t scsi_unit_attention(SCSIRequest *req, uint8_t *buf) { - if (req->dev->unit_attention.key == UNIT_ATTENTION) { - scsi_req_build_sense(req, req->dev->unit_attention); - } else if (req->bus->unit_attention.key == UNIT_ATTENTION) { - scsi_req_build_sense(req, req->bus->unit_attention); - } scsi_req_complete(req, CHECK_CONDITION); return 0; } static const struct SCSIReqOps reqops_unit_attention = { .size = sizeof(SCSIRequest), + .init_req = scsi_fetch_unit_attention_sense, .send_command = scsi_unit_attention }; @@ -699,6 +715,11 @@ SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, SCSIDevice *d, object_ref(OBJECT(d)); object_ref(OBJECT(qbus->parent)); notifier_list_init(&req->cancel_notifiers); + + if (reqops->init_req) { + reqops->init_req(req); + } + trace_scsi_req_alloc(req->dev->id, req->lun, req->tag); return req; } @@ -798,6 +819,15 @@ uint8_t *scsi_req_get_buf(SCSIRequest *req) static void scsi_clear_unit_attention(SCSIRequest *req) { SCSISense *ua; + + /* + * scsi_fetch_unit_attention_sense() already cleaned the unit attention + * in this case. + */ + if (req->ops == &reqops_unit_attention) { + return; + } + if (req->dev->unit_attention.key != UNIT_ATTENTION && req->bus->unit_attention.key != UNIT_ATTENTION) { return; diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index e2bb1a2fbfd..3692ca82f31 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -108,6 +108,7 @@ int cdrom_read_toc_raw(int nb_sectors, uint8_t *buf, int msf, int session_num); /* scsi-bus.c */ struct SCSIReqOps { size_t size; + void (*init_req)(SCSIRequest *req); void (*free_req)(SCSIRequest *req); int32_t (*send_command)(SCSIRequest *req, uint8_t *buf); void (*read_data)(SCSIRequest *req); From patchwork Fri Jul 14 10:59:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1807735 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VQ9P1jkd; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R2T7n6md5z20bY for ; Fri, 14 Jul 2023 21:01:57 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qKGXK-0006y7-29; Fri, 14 Jul 2023 07:00:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKGWy-0006wP-9f for qemu-devel@nongnu.org; Fri, 14 Jul 2023 07:00:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKGWu-0005Po-49 for qemu-devel@nongnu.org; Fri, 14 Jul 2023 07:00:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689332405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aUUpVyvem0h6bs6GgVnJulj4BabiP67yC5AwU1dWwBk=; b=VQ9P1jkdYX+wPlXcxppRjGfUeySnr7xQYVmIoDEGyigGzoXSkpvrfcKixNmmZfA7FDg6c6 Khy4OSAwfLZ+zfNDZO/jbS2oXPwMMXRHQukChXjlLpyo7SJV5qajOYmxtrDewBGsXEUyIO FFmo8vB6KSw87ak8W/NvNStElxjIZ8g= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-564-CJIvXzR8MNyj5MLyca2BQQ-1; Fri, 14 Jul 2023 07:00:04 -0400 X-MC-Unique: CJIvXzR8MNyj5MLyca2BQQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3fbcae05906so8810265e9.3 for ; Fri, 14 Jul 2023 04:00:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689332402; x=1691924402; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aUUpVyvem0h6bs6GgVnJulj4BabiP67yC5AwU1dWwBk=; b=IzPaCHPvzFZIhZf+ySZFxQTLpqT0a2X9LFEKOjWM7Te0FH3CHpVpgYwgqO8Alfxogq 1PXaVikHkUT1pveYIblZJxaOdSBChfX+ZOhJTOsH1DHHT9w9LqBWqwrsJkityfrCM5LT JiCO9rFr+NCtyoI07Z9cO7mt6XDdNHProhZkRtP6IigGwX2k+8PxelvT0fWzMxBt3j/5 tDMOPkVUWItc8zi2MfPMxrUPWRb6wSWQRdM30sx5Q70uWBQPbcrJbdfQSBnBrlCgiK7i 1UdKr1m7oKn1Srp6dXjKvWir0aXAjLEWhCg2gb0mpBngr8U38sshgCA5be4/4PgmcKZY n4ew== X-Gm-Message-State: ABy/qLbymbcQ53ryfRw+WFE4rrR4Av+Dj6NJtE8tyPSOcliBqoHq9rxF WOEBR0PBkApz81gtnanBAoY8aLogMCLntT/ENtxhMIAfn3eEi0lfTsSA4/zGrCtZR2BzYdwpYe/ fyznEDzzXEgqk+Nyisab2NgnCPclp7AH3pVYhUvdqHPPEc/d/K2etArqYydcGLYZbrS+kGdofxY w= X-Received: by 2002:a5d:5223:0:b0:314:3856:8d99 with SMTP id i3-20020a5d5223000000b0031438568d99mr4672558wra.44.1689332402566; Fri, 14 Jul 2023 04:00:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlEYRraS/O1lcOdK6/p/xdZdTisLPYRZcJ3L8o8BSPAmcIJOClInQM51DO/08TffQLB1Idvq8g== X-Received: by 2002:a5d:5223:0:b0:314:3856:8d99 with SMTP id i3-20020a5d5223000000b0031438568d99mr4672547wra.44.1689332402285; Fri, 14 Jul 2023 04:00:02 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id p5-20020a5d4e05000000b003143d80d11dsm10460462wrt.112.2023.07.14.04.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 04:00:01 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Stefano Garzarella Subject: [PULL 4/5] scsi: cleanup scsi_clear_unit_attention() Date: Fri, 14 Jul 2023 12:59:52 +0200 Message-ID: <20230714105953.223485-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230714105953.223485-1-pbonzini@redhat.com> References: <20230714105953.223485-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stefano Garzarella The previous commit moved the unit attention clearing when we create the request. So now we can clean scsi_clear_unit_attention() to handle only the case of the REPORT LUNS command: this is the only case in which a UNIT ATTENTION is cleared without having been reported. Suggested-by: Paolo Bonzini Signed-off-by: Stefano Garzarella Message-ID: <20230712134352.118655-3-sgarzare@redhat.com> Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-bus.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index f083373021c..f9c95dfb50d 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -828,26 +828,12 @@ static void scsi_clear_unit_attention(SCSIRequest *req) return; } - if (req->dev->unit_attention.key != UNIT_ATTENTION && - req->bus->unit_attention.key != UNIT_ATTENTION) { - return; - } - - /* - * If an INQUIRY command enters the enabled command state, - * the device server shall [not] clear any unit attention condition; - * See also MMC-6, paragraphs 6.5 and 6.6.2. - */ - if (req->cmd.buf[0] == INQUIRY || - req->cmd.buf[0] == GET_CONFIGURATION || - req->cmd.buf[0] == GET_EVENT_STATUS_NOTIFICATION) { - return; - } - if (req->dev->unit_attention.key == UNIT_ATTENTION) { ua = &req->dev->unit_attention; - } else { + } else if (req->bus->unit_attention.key == UNIT_ATTENTION) { ua = &req->bus->unit_attention; + } else { + return; } /* @@ -856,12 +842,10 @@ static void scsi_clear_unit_attention(SCSIRequest *req) * with an additional sense code of REPORTED LUNS DATA HAS CHANGED. */ if (req->cmd.buf[0] == REPORT_LUNS && - !(ua->asc == SENSE_CODE(REPORTED_LUNS_CHANGED).asc && - ua->ascq == SENSE_CODE(REPORTED_LUNS_CHANGED).ascq)) { - return; + ua->asc == SENSE_CODE(REPORTED_LUNS_CHANGED).asc && + ua->ascq == SENSE_CODE(REPORTED_LUNS_CHANGED).ascq) { + *ua = SENSE_CODE(NO_SENSE); } - - *ua = SENSE_CODE(NO_SENSE); } int scsi_req_get_sense(SCSIRequest *req, uint8_t *buf, int len) From patchwork Fri Jul 14 10:59:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1807736 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eIcNjMSS; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R2T890K4Rz20bY for ; Fri, 14 Jul 2023 21:02:17 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qKGXM-00071V-0j; Fri, 14 Jul 2023 07:00:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKGWy-0006wQ-A4 for qemu-devel@nongnu.org; Fri, 14 Jul 2023 07:00:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKGWv-0005Qa-Mv for qemu-devel@nongnu.org; Fri, 14 Jul 2023 07:00:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689332407; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QkRJ+F4DieJLRrlQngYFaFKy3DvilqMM9x+FgLX6gcw=; b=eIcNjMSSD92pIZoTo89zFveJhArv8E/NB+LpR/W3WIf1KgeuKI0nINYmahEt2wT5B8a+jF /NLwoVeYLXRl67aZMHBkA/PzOONJX0/dniBOsKGLLSnv2VJoyU0e3jbJJBmvp37Txsrrhu j+DZvnDDCtxls8C2gK2EPG1ZAQdjyak= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-644-LAWNQQ__ORi84JpxqP53gw-1; Fri, 14 Jul 2023 07:00:06 -0400 X-MC-Unique: LAWNQQ__ORi84JpxqP53gw-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3fbe590234aso10281555e9.1 for ; Fri, 14 Jul 2023 04:00:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689332404; x=1691924404; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QkRJ+F4DieJLRrlQngYFaFKy3DvilqMM9x+FgLX6gcw=; b=BKyopbnQWkmpF5pmoL7bYuBae/DM9DWUrUuKsJueo/pwqZ022uS0LoHd5AD3pOYRBU udKkGRR4CvyQuaPxQnIEPLGI7mKL4sFmIDPovQ6I5F+pV+Asr2mpZe/ymigIMQtxBCe8 U4Tvs/HtDIq6/URe8kaQtZi9yf7f29VS13ie5eb/hzWE2m1APTzWDfbU6eQoYHkOL+pw 85eZOiFBEC0jUxvdLpWiGzXhURmiD2g6lLBPXNQdUueyRsmBeZcv6wvx85nNzNUTsPzS AeNrnEawJGrdpkJJH5IQjvaR3aZXLeocmcYbQgiBqynn2mkyCvidhFy/6/ak8HBy/8mn llrA== X-Gm-Message-State: ABy/qLaWWMeFemdUTlx6lSWebuUAmEgqxWJLbUT74LdIz26WnQuXWAx0 ZeTn/LRZTJ//uzKUCmxFqheKIXRb7P9Xx4r4feSegac1/lBKXw94//SWwVSqKTEneq31nU9LIty PCJmW6EAE4BpZjUaO7EJtPmQrKpPNFn790ZWTQMdGNsNe4GC3D/xXfHa9gE39EDLK0qStikLRwt E= X-Received: by 2002:a7b:ce08:0:b0:3f6:1474:905 with SMTP id m8-20020a7bce08000000b003f614740905mr4693773wmc.29.1689332404429; Fri, 14 Jul 2023 04:00:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlGWj0VGm3JepyZWhzlX+wPMh6dUs12IOgarpv+QC8YdCIm6R5DLXOje4Ljajs5gXh9i52RvXA== X-Received: by 2002:a7b:ce08:0:b0:3f6:1474:905 with SMTP id m8-20020a7bce08000000b003f614740905mr4693747wmc.29.1689332404099; Fri, 14 Jul 2023 04:00:04 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id n2-20020a05600c294200b003fbd9e390e1sm1120880wmd.47.2023.07.14.04.00.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 04:00:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Stefano Garzarella Subject: [PULL 5/5] scsi: clear unit attention only for REPORT LUNS commands Date: Fri, 14 Jul 2023 12:59:53 +0200 Message-ID: <20230714105953.223485-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230714105953.223485-1-pbonzini@redhat.com> References: <20230714105953.223485-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Stefano Garzarella scsi_clear_unit_attention() now only handles REPORTED LUNS DATA HAS CHANGED. This only happens when we handle REPORT LUNS commands, so let's rename the function in scsi_clear_reported_luns_changed() and call it only in scsi_target_emulate_report_luns(). Suggested-by: Paolo Bonzini Signed-off-by: Stefano Garzarella Message-ID: <20230712134352.118655-4-sgarzare@redhat.com> Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-bus.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index f9c95dfb50d..fc4b77fdb02 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -22,6 +22,7 @@ static char *scsibus_get_fw_dev_path(DeviceState *dev); static void scsi_req_dequeue(SCSIRequest *req); static uint8_t *scsi_target_alloc_buf(SCSIRequest *req, size_t len); static void scsi_target_free_buf(SCSIRequest *req); +static void scsi_clear_reported_luns_changed(SCSIRequest *req); static int next_scsi_bus; @@ -518,6 +519,14 @@ static bool scsi_target_emulate_report_luns(SCSITargetReq *r) /* store the LUN list length */ stl_be_p(&r->buf[0], len - 8); + + /* + * If a REPORT LUNS command enters the enabled command state, [...] + * the device server shall clear any pending unit attention condition + * with an additional sense code of REPORTED LUNS DATA HAS CHANGED. + */ + scsi_clear_reported_luns_changed(&r->req); + return true; } @@ -816,18 +825,10 @@ uint8_t *scsi_req_get_buf(SCSIRequest *req) return req->ops->get_buf(req); } -static void scsi_clear_unit_attention(SCSIRequest *req) +static void scsi_clear_reported_luns_changed(SCSIRequest *req) { SCSISense *ua; - /* - * scsi_fetch_unit_attention_sense() already cleaned the unit attention - * in this case. - */ - if (req->ops == &reqops_unit_attention) { - return; - } - if (req->dev->unit_attention.key == UNIT_ATTENTION) { ua = &req->dev->unit_attention; } else if (req->bus->unit_attention.key == UNIT_ATTENTION) { @@ -836,13 +837,7 @@ static void scsi_clear_unit_attention(SCSIRequest *req) return; } - /* - * If a REPORT LUNS command enters the enabled command state, [...] - * the device server shall clear any pending unit attention condition - * with an additional sense code of REPORTED LUNS DATA HAS CHANGED. - */ - if (req->cmd.buf[0] == REPORT_LUNS && - ua->asc == SENSE_CODE(REPORTED_LUNS_CHANGED).asc && + if (ua->asc == SENSE_CODE(REPORTED_LUNS_CHANGED).asc && ua->ascq == SENSE_CODE(REPORTED_LUNS_CHANGED).ascq) { *ua = SENSE_CODE(NO_SENSE); } @@ -1528,13 +1523,6 @@ void scsi_req_complete(SCSIRequest *req, int status) req->dev->sense_is_ua = false; } - /* - * Unit attention state is now stored in the device's sense buffer - * if the HBA didn't do autosense. Clear the pending unit attention - * flags. - */ - scsi_clear_unit_attention(req); - scsi_req_ref(req); scsi_req_dequeue(req); req->bus->info->complete(req, req->residual);