Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2243678ybi; Mon, 1 Jul 2019 08:37:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1Joa4WgIfWhUjvBTZnaO20ST9L+Xn7qfdn/fxHXVnwMWojCllh+9Z/d3qCPE/5Y4Hmf8Q X-Received: by 2002:a17:90a:9a8d:: with SMTP id e13mr32251899pjp.77.1561995467580; Mon, 01 Jul 2019 08:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561995467; cv=none; d=google.com; s=arc-20160816; b=QacW78R04O+4YoQucihjFFEWiGBWpgi7xMLX6HvNMFL4zIZkboW14w3PiX3V7/L/4X UESSeeaPANPCuD+xuZ0IPGDFo3IQR0Nc1d4Yh6IyBlukYrYaYdL7zS41aloqMncP91cf ndJAl5UKpTHLwxbIbBd6g8QGHrNeThJSqgnNx+59pDVVWrhHkCiv0P6+FMMcij+xWAQP B09yG4IRWeGvu71MtbrnfGpj7esuTZE7NMsmSG5SLgN1XG2q6abEl8AXG1H9pUerfnT1 gg4WXck1GluN+ROyVx0Hl0ibq9MFuA2H85Gt/jbzdViyIpT2HhztFdwIc/CBf8pzGxxP Jrfw== 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:mime-version :user-agent:message-id:date:cc:to:from:subject; bh=B9oFvF33KnQGtIYAr8S+xmGYJ7ec6pkT2K4+sFmkRh0=; b=uoPpmUtVY7x5TeswxSvfMq2xt0eaFeTkTMiXYeko23Pj7FFlhlNkDq+e+DcEA/9tE7 BTjMLNRuyHFPqJ3vr4Ia32lqUNtsLySKgKRxeYrQtcqVWRqVxwbChNNxyPgPx3J/lhTj e2xb94TNOKK/iMmPnJgrz6fHTYFoBhvUpw8QJvtvKrRm/WimmsQfy2u1sEmzPWsepKnU BmT2piAI+89DZPEYsYKoFkqoWuQN1HJ3TfY898kf/EknpOVgSU/FA2x5/63WFiqNd1nq vQj+WEl/vEJ3h/jlEzA+JU3DZzbAEkZasRJTNk2W7i6FPCZwr1r5MJleXCeliZ8p7+WL utXQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 188si10518721pgd.404.2019.07.01.08.37.31; Mon, 01 Jul 2019 08:37:47 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729946AbfGAOyt (ORCPT + 99 others); Mon, 1 Jul 2019 10:54:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27119 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728453AbfGAOyt (ORCPT ); Mon, 1 Jul 2019 10:54:49 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2062A3082A27; Mon, 1 Jul 2019 14:54:49 +0000 (UTC) Received: from gimli.home (ovpn-116-83.phx2.redhat.com [10.3.116.83]) by smtp.corp.redhat.com (Postfix) with ESMTP id 735897E8F7; Mon, 1 Jul 2019 14:54:44 +0000 (UTC) Subject: [PATCH v2] mdev: Send uevents around parent device registration From: Alex Williamson To: kwankhede@nvidia.com, alex.williamson@redhat.com, cohuck@redhat.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 01 Jul 2019 08:54:44 -0600 Message-ID: <156199271955.1646.13321360197612813634.stgit@gimli.home> User-Agent: StGit/0.19-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 01 Jul 2019 14:54:49 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This allows udev to trigger rules when a parent device is registered or unregistered from mdev. Signed-off-by: Alex Williamson --- v2: Don't remove the dev_info(), Kirti requested they stay and removing them is only tangential to the goal of this change. drivers/vfio/mdev/mdev_core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c index ae23151442cb..7fb268136c62 100644 --- a/drivers/vfio/mdev/mdev_core.c +++ b/drivers/vfio/mdev/mdev_core.c @@ -146,6 +146,8 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops) { int ret; struct mdev_parent *parent; + char *env_string = "MDEV_STATE=registered"; + char *envp[] = { env_string, NULL }; /* check for mandatory ops */ if (!ops || !ops->create || !ops->remove || !ops->supported_type_groups) @@ -197,6 +199,8 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops) mutex_unlock(&parent_list_lock); dev_info(dev, "MDEV: Registered\n"); + kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp); + return 0; add_dev_err: @@ -220,6 +224,8 @@ EXPORT_SYMBOL(mdev_register_device); void mdev_unregister_device(struct device *dev) { struct mdev_parent *parent; + char *env_string = "MDEV_STATE=unregistered"; + char *envp[] = { env_string, NULL }; mutex_lock(&parent_list_lock); parent = __find_parent_device(dev); @@ -243,6 +249,8 @@ void mdev_unregister_device(struct device *dev) up_write(&parent->unreg_sem); mdev_put_parent(parent); + + kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp); } EXPORT_SYMBOL(mdev_unregister_device);