Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp61582ima; Thu, 31 Jan 2019 23:01:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN6+zQkC0EL7Z/I7aFPWw0klbc1EPul4l4pktLqBWCzMOhFW26CRbX1bsYbCgpE0TUjT5Qj9 X-Received: by 2002:a62:c101:: with SMTP id i1mr38027238pfg.80.1549004481475; Thu, 31 Jan 2019 23:01:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549004481; cv=none; d=google.com; s=arc-20160816; b=qyzO6YHbAvVhXfJugAS/mHs3IhSt7ZP2WTRalqt4jY91F24a6F+BVykCHj5X0bvp1+ 4SoklaOw64mj3F0tJ5W1USDyNcXXZfYSqJ7sLHja9aURpW2y01PvlnAHe/L0DBpEW5fg Qx6YZ9VZIsiK8RYmhTNYhfGrbJ52LWTOJv/qC1KGs15R1t5qHtSpc6bCopPdwJMaqlxN IEwP0DSkOEvJhcKnaU1CBtbQSV3TdSYWO8d4L0MrNp0kh6G6PR9QI2ZOMRxQk1WTcXnz nyW46tFg4b2Uiox4cLzkMGCJzGITef/1+7DSnw8XI9Vq+ERMoa+Il/3FOCfEgEzBlQKy GEvw== 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=HYQIvUf052MGRw8GeIJe2VxpLhmTjMPjmdzCglPqWz4=; b=N4LID6KbefryJLQYr6MppbIvK4wZAiMOvnJw94l6BpZyg65Grup2MZ1jM45fe/nobk ubPEOccG0VHg52LPwnjyTQ9gfrwshF5tQfKayYQctsStvmiaCPsG/5Q7WKtKfefyPtMe OBver2PmpkSo0PFl2zGDpsg0caz89+azM+k5DuYJTk5iJZXnr2qlSW3WxEBGpG7K6PRE WXWu6Yi1Iv6Oy167Qphou3yK39o11Oz0FET/kalUw9K2WczhAGC86752n/sooU6FEWMn aIn1ojkndsXQz6pCva8EpQA0aMUkCgU5Qz3dLaHbwPgKrYj0ULmJ1KsaKTUX0jbfGBdr 7NbQ== 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 b6si6487982pgg.2.2019.01.31.23.01.06; Thu, 31 Jan 2019 23:01:21 -0800 (PST) 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 S1726574AbfBAGmn (ORCPT + 99 others); Fri, 1 Feb 2019 01:42:43 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:3261 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725763AbfBAGmn (ORCPT ); Fri, 1 Feb 2019 01:42:43 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D7F94D4379DAB6228892; Fri, 1 Feb 2019 14:42:40 +0800 (CST) Received: from [127.0.0.1] (10.177.29.32) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.408.0; Fri, 1 Feb 2019 14:42:34 +0800 Subject: Re: [PATCH] irqchip/gic-v3-its: Lock its device list during find and create its device To: Marc Zyngier CC: , , , References: <20190126061624.5260-1-zhengxiang9@huawei.com> <86bm438x8n.wl-marc.zyngier@arm.com> <27e0b952-111f-f221-bcd7-1a7ceb2840b5@huawei.com> <0dc03914-4c8a-4fa1-fb67-f51936c54836@arm.com> <505e3257-3ef6-69d4-b996-5a1e200e1246@huawei.com> <32354a2a-b1b3-e03b-c486-c17aee1bed8d@huawei.com> <6c44c2d4-d507-e01a-eef5-894ae71209ef@arm.com> From: Zheng Xiang Message-ID: Date: Fri, 1 Feb 2019 14:41:32 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Thunderbird/64.0 MIME-Version: 1.0 In-Reply-To: <6c44c2d4-d507-e01a-eef5-894ae71209ef@arm.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.32] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/1/31 23:12, Marc Zyngier wrote: > Hi Zeng, > > On 31/01/2019 14:47, Zheng Xiang wrote: >> Hi Marc, >> >> On 2019/1/29 13:42, Zheng Xiang wrote: >>> On 2019/1/28 21:51, Marc Zyngier wrote: >>>> On 28/01/2019 07:13, Zheng Xiang wrote: >>>>> Hi Marc, >>>>> >>>>> Thanks for your review. >>>>> >>>>> On 2019/1/26 19:38, Marc Zyngier wrote: >>>>>> Hi Zheng, >>>>>> >>>>>> On Sat, 26 Jan 2019 06:16:24 +0000, >>>>>> Zheng Xiang wrote: >>>>>>> >>>>>>> Currently each PCI device under a PCI Bridge shares the same device id >>>>>>> and ITS device. Assume there are two PCI devices call its_msi_prepare >>>>>>> concurrently and they are both going to find and create their ITS >>>>>>> device. There is a chance that the later one couldn't find ITS device >>>>>>> before the other one creating the ITS device. It will cause the later >>>>>>> one to create a different ITS device even if they have the same >>>>>>> device_id. >>>>>> >>>>>> Interesting finding. Is this something you've actually seen in practice >>>>>> with two devices being probed in parallel? Or something that you found >>>>>> by inspection? >>>>> >>>>> Yes, I find this problem after analyzing the reason of VM hung. At last, I >>>>> find that the virtio-gpu cannot receive the MSI interrupts due to sharing >>>>> a same event_id as virtio-serial. >>>>> >>>>> See https://lkml.org/lkml/2019/1/10/299 for the bug report. >>>>> >>>>> This problem can be reproducted with high probability by booting a Qemu/KVM >>>>> VM with a virtio-serial controller and a virtio-gpu adding to a PCI Bridge >>>>> and also adding some delay before creating ITS device. >>>> >>>> Fair enough. Do you mind sharing your QEMU command line? It'd be useful >>>> if I could reproduce it here (and would give me a way to check that it >>>> doesn't regress). >>> >> >> Have you reproduced it with my QEMU command line? >> >> If so, should I send a V2 patch with your suggestion? > > I've queued the following, much more complete patch: > > https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/commit/?h=irq/irqchip-next&id=9791ec7df0e7b4d80706ccea8f24b6542f6059e9 > > Can you check that it works for you? I didn't manage to get the right > timing conditions, but I also had issues getting virtio-gpu running on > my TX2, so one might explain the other. > It works for my case, but I worried about the below lines which may cause memory leak. @@ -2627,8 +2640,14 @@ static void its_irq_domain_free(struct irq_domain *domain, unsigned int virq, irq_domain_reset_irq_data(data); } - /* If all interrupts have been freed, start mopping the floor */ - if (bitmap_empty(its_dev->event_map.lpi_map, + mutex_lock(&its->dev_alloc_lock); + + /* + * If all interrupts have been freed, start mopping the + * floor. This is conditionned on the device not being shared. + */ + if (!its_dev->shared && + bitmap_empty(its_dev->event_map.lpi_map, its_dev->event_map.nr_lpis)) { its_lpi_free(its_dev->event_map.lpi_map, its_dev->event_map.lpi_base, It seems that the shared its_dev would never be freed since the value of its_dev->shared is always *true*. > Thanks, > > M. > -- Thanks, Xiang