From patchwork Thu Oct 22 12:05:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 7464741 Return-Path: X-Original-To: patchwork-kvm@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 B2DF89F1C3 for ; Thu, 22 Oct 2015 12:05:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9404120937 for ; Thu, 22 Oct 2015 12:05:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 907AE20935 for ; Thu, 22 Oct 2015 12:05:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756803AbbJVMFQ (ORCPT ); Thu, 22 Oct 2015 08:05:16 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:63734 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750978AbbJVMFP (ORCPT ); Thu, 22 Oct 2015 08:05:15 -0400 Received: from wuerfel.localnet ([134.3.118.24]) by mrelayeu.kundenserver.de (mreue103) with ESMTPSA (Nemesis) id 0MC7ge-1ZgTAm0Jqy-008ppt; Thu, 22 Oct 2015 14:05:04 +0200 From: Arnd Bergmann To: Eric Auger Cc: eric.auger@st.com, alex.williamson@redhat.com, b.reynal@virtualopensystems.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, christoffer.dall@linaro.org, linux-kernel@vger.kernel.org, patches@linaro.org Subject: Re: [PATCH v2 6/6] vfio: platform: move get/put reset at open/release Date: Thu, 22 Oct 2015 14:05 +0200 Message-ID: <4122253.nUc0E0jzBg@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <5628CB20.7040301@linaro.org> References: <1445506922-6005-1-git-send-email-eric.auger@linaro.org> <4304536.D7eNHjlsvD@wuerfel> <5628CB20.7040301@linaro.org> MIME-Version: 1.0 X-Provags-ID: V03:K0:HjKTkrMx79VdSdbNiUCQvCAoJXpXC64dlxzH9U0t9GG0G9iyfKh sgGQDJIkEfTn3rPVUU6at5SYwGIAwALeqtovXgv7oPhOUd8SOip0GAMWIvbQvohGbzqYI06 CH9Hyt+3+ffb9XI6Mankkrj2ampgGg6QQICTfoXsJc6XIlMFDaMwDAzmZGaPt6Yp/wWuRoL GUg/iwzjuRwRPiIUhxZWw== X-UI-Out-Filterresults: notjunk:1; V01:K0:0KvFKii60mA=:3hAkYrtJzDn/IUJKPPkaNu d4jsxL2dgult3nsX4Cq7qynr2MgB5RCDc91KPnxLhKwM/+ukuPwpXGhTnHCrO2063bXYHzCNc oVvJzmAqYIWkFR99kDeblljxhpzRWcrOhT5+lqmrWRKN1Ogq3bwzEXBT51/+vlaDjK9Tu8OW7 3rcMgFLcKnOrZn7Lq++Nz86wKGMnZOhFymnZtKIeSKrax2UYv5q5ENlv6ZwitCD4p7sIUlNPH 8PozBdlLxCVMrcvysW8IsFjquPiwRSDg/k03hGtMATBq18qh/aiZEUqq/05dEiRNszE9tC6Yz T7+MnV6eIAMQumPEK4Rmij0MhpWBXWR5IrjUAO6lC1w7PYU+w+stY67DmvnG7gRk9VbQX4A8u 4KR9sc7gYKUD6rkv/HtLxvX4V7JKsED2j2+dP1SxVsQhoNDKtmrnGZQZCOZQxAhlNLFEhJb5F dyHxdyEioDumIwz0s3mHf00B43tElN0vlwLdWKkQdO4it2KN5CQEFVFXJ7i4BF5g9X92e6iIl 7Se20TJP/suSSL8nDwfr10wdkUCK9ImwAyBk2F8Y3QRQgGCZAYrsXpb5k8ZqIKoNVeGP93edS kuUbQwKjQ/gii0QdeZBZyK0NVedqdhRv2oU1HDg3imy2KPD/G5qPbfYt9NEDGrSEqmGS8Ufgb EVnQrijeeV31L4CKiDB/09QvHm5ZG7fHXAO/haho93AgmDjIvidJdtwxXQn8PynJ2K3SOIGDO TLockxBsL87+3HR6 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 On Thursday 22 October 2015 13:40:16 Eric Auger wrote: > On 10/22/2015 12:29 PM, Arnd Bergmann wrote: > > On Thursday 22 October 2015 11:42:02 Eric Auger wrote: > >> Currently reset lookup is done on probe. This introduces a > >> race with new registration mechanism in the case where the > >> vfio-platform driver is bound to the device before its module > >> is loaded: on the load, the probe happens which triggers the > >> reset module load which itself attempts to get the symbol for > >> the registration function (vfio_platform_register_reset). The > >> symbol is not yet available hence the lookup fails. In case we > >> do the lookup in the first open we are sure the vfio-platform > >> module is loaded and vfio_platform_register_reset is available. > >> > >> Signed-off-by: Eric Auger > > > > I don't understand the explanation. I would expect the request_module() > > call to block until the module is actually loaded. Is this not > > what happens? > > Again many thanks for this new review. > > My understanding is the following > 1) vfio-platform is attached to the device through the override mechanism > 2) vfio-platform get loaded through modprobe: > 2-1) the platform driver init function eventually calls the > vfio-platform probe function. > 2-2) request_module of vfio-platform-calxedaxgmac gets called. > 3) The init of vfio-platform-calxedaxgmac looks for > vfio_platform_register_reset. Unfortunately at that stage the init of > vfio-platform is not completed so the symbol is not available > 3-1) in case symbol_get is used in vfio_platform_calxedaxgmac init, as > of today, this latter simply returns -EINVAL. Reset registration failed > but no stall. > 3-2) in case symbol_get is *not* used, I think the module loader > attempts to load vfio-platform, which is already under load and this > causes a stall. > > Let me know if you think this understanding is not correct. I was expecting the vfio_platform_register_reset() function to be available by the time of step 2-2. What I think is going on here is that we are still inside of the module_init() function of the vfio-platform driver at the time that we call the request_module(), and the symbols are not made visible to other modules until the module_init function returns with success. This is a side-effect of the probe function for the platform driver getting called from deep inside of the platform_driver_register() function for all devices that are already present. I think it already works for the AMBA case, which uses separate modules, but we need to restructure the platform_device case slightly to do the same: Arnd --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/vfio/platform/Makefile b/drivers/vfio/platform/Makefile index 9ce8afe28450..a00a44814255 100644 --- a/drivers/vfio/platform/Makefile +++ b/drivers/vfio/platform/Makefile @@ -1,10 +1,12 @@ -vfio-platform-y := vfio_platform.o vfio_platform_common.o vfio_platform_irq.o +vfio-platform-base-y := vfio_platform_common.o vfio_platform_irq.o -obj-$(CONFIG_VFIO_PLATFORM) += vfio-platform.o +obj-$(CONFIG_VFIO_PLATFORM) += vfio_platform.o +obj-$(CONFIG_VFIO_PLATFORM) += vfio-platform-base.o obj-$(CONFIG_VFIO_PLATFORM) += reset/ vfio-amba-y := vfio_amba.o obj-$(CONFIG_VFIO_AMBA) += vfio-amba.o +obj-$(CONFIG_VFIO_AMBA) += vfio-platform-base.o obj-$(CONFIG_VFIO_AMBA) += reset/