From patchwork Thu Oct 22 09:42:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 7464131 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 442FD9F1C3 for ; Thu, 22 Oct 2015 09:44:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6120020894 for ; Thu, 22 Oct 2015 09:44:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7988E2085C for ; Thu, 22 Oct 2015 09:44:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756982AbbJVJnm (ORCPT ); Thu, 22 Oct 2015 05:43:42 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:36223 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757167AbbJVJmT (ORCPT ); Thu, 22 Oct 2015 05:42:19 -0400 Received: by wicfx6 with SMTP id fx6so127284046wic.1 for ; Thu, 22 Oct 2015 02:42:18 -0700 (PDT) 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:in-reply-to :references; bh=h/9YcW6HhWtgf6zOiVqsz6OAqkipb8XuiNdm7NgMoP8=; b=SmX9qiHpFW2yoipuwYBMRa+9G+i/mQtboDHTLbyx5t278E8fMUDzCb1oPMJEeCuasw xWi3el3mSdr0eT0pXLItwESYAXsVTmx6DlETw4tK0hRHydVa18Q4ufoQkQUI4utI1Bh1 HJ8XVHCOT/zUfJVp1SEUGPkC2Sq+zEB3C96+38CNtA2GmU5X7AQkYzvSDkWXs1pnPPgH t4kakBrrWejO4Tp5zFGi62a9dJa939GwVL/VyFCz5NnUuBN5jZE6vytk+f0s4vxz8m22 daCCVKEH9MufGuc7EcsSo7L9vyOcoO1gThOjLMjc7+nb29wfjpaC56/NM4L05ipaawxb 3KUA== X-Gm-Message-State: ALoCoQl3y5OnSpx/s4jYggVmlHdH52BRFh4IXOuEzBXhqAmBLecudWo2YiPnmcKUll28R9V3Gkuc X-Received: by 10.180.99.41 with SMTP id en9mr41182130wib.67.1445506937924; Thu, 22 Oct 2015 02:42:17 -0700 (PDT) Received: from gnx2579.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id lr6sm9376859wic.3.2015.10.22.02.42.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Oct 2015 02:42:16 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, alex.williamson@redhat.com, b.reynal@virtualopensystems.com, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Cc: christoffer.dall@linaro.org, linux-kernel@vger.kernel.org, patches@linaro.org Subject: [PATCH v2 6/6] vfio: platform: move get/put reset at open/release Date: Thu, 22 Oct 2015 11:42:02 +0200 Message-Id: <1445506922-6005-7-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445506922-6005-1-git-send-email-eric.auger@linaro.org> References: <1445506922-6005-1-git-send-email-eric.auger@linaro.org> 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=ham 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 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 --- drivers/vfio/platform/vfio_platform_common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index 95b8294..5ebae8c 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -155,6 +155,7 @@ static void vfio_platform_release(void *device_data) vdev->reset(vdev); vfio_platform_regions_cleanup(vdev); vfio_platform_irq_cleanup(vdev); + vfio_platform_put_reset(vdev); } mutex_unlock(&driver_lock); @@ -181,6 +182,8 @@ static int vfio_platform_open(void *device_data) if (ret) goto err_irq; + vfio_platform_get_reset(vdev); + if (vdev->reset) vdev->reset(vdev); } @@ -570,8 +573,6 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev, return ret; } - vfio_platform_get_reset(vdev); - mutex_init(&vdev->igate); return 0; @@ -585,7 +586,6 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev) vdev = vfio_del_group_dev(dev); if (vdev) { - vfio_platform_put_reset(vdev); iommu_group_put(dev->iommu_group); }