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: Auger Eric X-Patchwork-Id: 55424 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id 18D822304B for ; Thu, 22 Oct 2015 09:42:24 +0000 (UTC) Received: by wiclg3 with SMTP id lg3sf31199078wic.3 for ; Thu, 22 Oct 2015 02:42:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=h/9YcW6HhWtgf6zOiVqsz6OAqkipb8XuiNdm7NgMoP8=; b=jc/irik3fPvCJcJH4yjG0OgNFrYQpqHXwJWjzWPSt7V1IpDl5O3XcdZIpVD901dIvp gAYKEHHoYeIqgxBxmVPiRUAq9MH7wcUvpuU0eezvz1ZFcp3BoftdaknMyWfiT7Cw302A BZDDPsQpohFJAPDxbPDU35HfRcPdZ/0sFkZRD2+lnpyYDJj1RNJQ91YwAqMQffIY3U+z U5I5qNEoLxXkZRnoOxBw/Hq7wPqJwYgnet0EzuMIm2sPQptuoSMdFrmSWpubecs8GqmV TKaDFP2aCrLTpxUdgSOkXXif8lAzzFdHxIG5Di0ovNdDjDPLWY9Au7bxbbp7wmLjPqy7 6Eeg== X-Gm-Message-State: ALoCoQny3K6vohG8vHjDOkhwQfwCOKzZ5duMw4fsVnHv2DWgBQEK0zq3Z5VKh62KwYO3qXP88hQO X-Received: by 10.112.132.10 with SMTP id oq10mr3373395lbb.1.1445506943399; Thu, 22 Oct 2015 02:42:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.38.201 with SMTP id m192ls280915lfm.55.gmail; Thu, 22 Oct 2015 02:42:23 -0700 (PDT) X-Received: by 10.112.200.202 with SMTP id ju10mr7725708lbc.97.1445506943171; Thu, 22 Oct 2015 02:42:23 -0700 (PDT) Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id j2si9058427lbt.41.2015.10.22.02.42.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Oct 2015 02:42:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by lffz202 with SMTP id z202so41304393lff.3 for ; Thu, 22 Oct 2015 02:42:23 -0700 (PDT) X-Received: by 10.112.64.72 with SMTP id m8mr7587075lbs.41.1445506943073; Thu, 22 Oct 2015 02:42:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.59.35 with SMTP id w3csp485443lbq; Thu, 22 Oct 2015 02:42:22 -0700 (PDT) X-Received: by 10.180.108.148 with SMTP id hk20mr1621482wib.83.1445506938105; Thu, 22 Oct 2015 02:42:18 -0700 (PDT) Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com. [209.85.212.180]) by mx.google.com with ESMTPS id gu2si17972855wib.4.2015.10.22.02.42.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Oct 2015 02:42:18 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.180 as permitted sender) client-ip=209.85.212.180; Received: by wijp11 with SMTP id p11so23072302wij.0 for ; Thu, 22 Oct 2015 02:42:18 -0700 (PDT) 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> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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); }