From patchwork Mon Nov 30 02:17:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A. Shutemov" X-Patchwork-Id: 7729961 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D09339F1C0 for ; Mon, 30 Nov 2015 21:36:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ED98B204A7 for ; Mon, 30 Nov 2015 21:36:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A7FE420592 for ; Mon, 30 Nov 2015 21:36:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 53FF36E692; Mon, 30 Nov 2015 13:36:33 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6495E6E4BD for ; Sun, 29 Nov 2015 18:17:41 -0800 (PST) Received: by wmec201 with SMTP id c201so134887360wme.0 for ; Sun, 29 Nov 2015 18:17:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=fL/yLZpcxs7wPMkKPF/EOTaWh2O69ZLsUImULo8EuC0=; b=12Q7B8CmLcgUmRvDIqOShBd0NC6Jm/4vmETx49rMvh0NJ/d3ClbmhZx5rfgbJTd6QA nC+O/cK9eYHNvMczSRM3/DVe8sEjHtOw/2ZDLDu/VKv8VghA21RdXPmbUFBI94ZaGVY2 5WusR6YMsNN1Q4mVpvmwU2IRsDyqbZjHJohpjossQquRaSnzoR7L3ltdxUKJkPaqzeb8 RscexGDfqk69CFIArt+c+lZKFKtYO5JH+NFxy3syl+CVX8JbcIALR4TcRE+2ykHsNTRV rSYdlgG27CdRUMlATUsTSUHwoEs5Cvkm1c95rvXW3ikzusjhd9DXRfmlpH0Qot/Kvd+K z7TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fL/yLZpcxs7wPMkKPF/EOTaWh2O69ZLsUImULo8EuC0=; b=NVV1CzcvvJF/qeFaJo4O7BMQN7Wy+2HD28vhFYLiR9gC8rs4cVtIJVhHbcNdx7pDhe B4dz0BWa4X7Ec+a3W3L3D5ag56UbYj/9m+NwtB+O+Z3wTLMJOrZjAEvVZoVVr8qTPnv7 fWfK59QSOuAXMO+AW6F5R32SMLzSoSf73N1/2FP6WNCQvurdCn7aRCuzdEETDpRIp34n GNAdhrtnKI9VgB8xUz4fUTfi0IoBHK/sWlV6TcKFnr/jG99lpUSqGAvMBnrmPl5X7EMS befUmdHA+zE/2I2yRdV3J/SzNFjUyb2w2l57L+b3XqwxmCJZEx7o5k9EFlZD2xKc/VpA xMvw== X-Gm-Message-State: ALoCoQmtj3XRXOH0F/Df3DHJuCLff52Nk/0TaQkeEL6qzUM6YXt9Sw7aE9ejpNkiYdxWipnaauq2 X-Received: by 10.28.24.199 with SMTP id 190mr26103954wmy.101.1448849859505; Sun, 29 Nov 2015 18:17:39 -0800 (PST) Received: from node.shutemov.name ([93.85.177.161]) by smtp.gmail.com with ESMTPSA id uz5sm44474887wjc.8.2015.11.29.18.17.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Nov 2015 18:17:38 -0800 (PST) Received: by node.shutemov.name (Postfix, from userid 1000) id CF1926485B09; Mon, 30 Nov 2015 04:17:37 +0200 (EET) From: "Kirill A. Shutemov" To: Alex Williamson , David Airlie Subject: [PATCH] vgaarb: fix signal handling in vga_get() Date: Mon, 30 Nov 2015 04:17:31 +0200 Message-Id: <1448849851-26061-1-git-send-email-kirill@shutemov.name> X-Mailer: git-send-email 2.4.10 X-Mailman-Approved-At: Mon, 30 Nov 2015 13:36:31 -0800 Cc: "Kirill A. Shutemov" , vfio-users@redhat.com, dri-devel@lists.freedesktop.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are few defects in vga_get() related to signal hadning: - we shouldn't check for pending signals for TASK_UNINTERRUPTIBLE case; - if we found pending signal we must remove ourself from wait queue and change task state back to running; - -ERESTARTSYS is more appropriate, I guess. Signed-off-by: Kirill A. Shutemov --- Alex, I try to get KVM with VGA passthrough working properly. I have i915 (HD 4600) on the host and GTX 580 for the guest. The guest GPU is not capabale of EFI, so I have to use x-vga=on. It's kinda work with your patch for i915.enable_hd_vgaarb=1. But guest refuse to initialize the GPU after KVM was not shut down correctly, resulting in host crash like this: BUG: unable to handle kernel paging request at ffff880870187ed8 IP: [] 0xffff880870187ed8 PGD 2129067 PUD 80000008400001e3 Oops: 0011 [#1] PREEMPT SMP Modules linked in: iwlmvm iwlwifi CPU: 6 PID: 3983 Comm: qemu-system-x86 Not tainted 4.3.0-gentoo #6 Hardware name: Gigabyte Technology Co., Ltd. Z87X-UD7 TH/Z87X-UD7 TH-CF, BIOS F5a 06/12/2014 task: ffff88087a910000 ti: ffff8808632c0000 task.ti: ffff8808632c0000 RIP: 0010:[] [] 0xffff880870187ed8 RSP: 0018:ffff8808632c3d08 EFLAGS: 00010006 RAX: ffff880870187db0 RBX: 0000000070187f58 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 0000000000000003 RDI: ffff880870187db0 RBP: ffff8808632c3d48 R08: 0000000000000000 R09: 0000000000000000 R10: 00000000000103c0 R11: 0000000000000293 R12: ffffffff81ea03c8 R13: ffffffff8104c7cb R14: 0000000000000000 R15: 0000000000000003 FS: 00007f984f9b2700(0000) GS:ffff88089f380000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffff880870187ed8 CR3: 00000008645f8000 CR4: 00000000001426e0 Stack: ffffffff810cc83d 00000000632c3d28 0000000000000000 ffffffff81ea03c0 0000000000000046 0000000000000003 0000000000000000 0000000000000000 ffff8808632c3d80 ffffffff810cca44 ffff88087af63800 0000000000000286 Call Trace: [] ? __wake_up_common+0x4d/0x80 [] __wake_up+0x34/0x50 [] __vga_put+0x73/0xd0 [] vga_put+0x54/0x80 [] vfio_pci_vga_rw+0x1d2/0x220 [] vfio_pci_rw+0x33/0x60 [] vfio_pci_write+0x17/0x20 [] vfio_device_fops_write+0x26/0x30 [] __vfs_write+0x23/0xe0 [] ? __vfs_read+0x23/0xd0 [] ? do_vfs_ioctl+0x2b5/0x490 [] vfs_write+0xa4/0x190 [] SyS_pwrite64+0x66/0xa0 [] entry_SYSCALL_64_fastpath+0x12/0x6a Code: 88 ff ff e0 7e 18 70 08 88 ff ff 00 8c 57 76 08 88 ff ff 20 7f 18 70 08 88 ff ff 08 7f 18 70 08 88 ff ff 94 51 1a 81 ff ff ff ff <09> 00 00 00 00 00 00 00 01 8c 57 76 08 88 ff ff 00 8c 57 76 08 RIP [] 0xffff880870187ed8 RSP CR2: ffff880870187ed8 The patch fixes the crash, but doesn't help with getting GPU in guest working again. Any ideas? --- drivers/gpu/vga/vgaarb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c index 3166e4bc4eb6..9abcaa53bd25 100644 --- a/drivers/gpu/vga/vgaarb.c +++ b/drivers/gpu/vga/vgaarb.c @@ -395,8 +395,10 @@ int vga_get(struct pci_dev *pdev, unsigned int rsrc, int interruptible) set_current_state(interruptible ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE); - if (signal_pending(current)) { - rc = -EINTR; + if (interruptible && signal_pending(current)) { + __set_current_state(TASK_RUNNING); + remove_wait_queue(&vga_wait_queue, &wait); + rc = -ERESTARTSYS; break; } schedule();