From nobody Sun Feb 8 05:07:00 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42BA3246BCB for ; Mon, 30 Jun 2025 09:33:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751275986; cv=none; b=U7Uf767zG7k+UJkddhIeIdfCbDqDxzc+wrZf0aSBfFEvjy2oj+d5iE7QOJiVpOTrAw8ewAJfEyTWSh5+yq0b/QsfElf4yBu0azdsS54R3EMzWgP6b71Dauxwo42Pqzeh2whhXZRBO22PB9FrzEaMHMw0I6EydKlzzv7A+O+zCo8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751275986; c=relaxed/simple; bh=c3EE6wrQNXh5lkN5NgK6InlkspugXxkkAh0cxdXykUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SGeadIYWqI8xughrYy4LnVrK3MpgRZiNWqD24xeyGIctDaeGay8dKQgzxPk7roCA9P6p+tO1BcH/wQfG65/tRIO7toofyZ/XYXOnZhzEz0dUBPQQjcCTnysPH2qKKOOlKUXsGvRJ8sbkGScBh7BiRDRQfm34AfHATr0OknLG1YQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=c/2wMMO4; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="c/2wMMO4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751275986; x=1782811986; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=c3EE6wrQNXh5lkN5NgK6InlkspugXxkkAh0cxdXykUE=; b=c/2wMMO4i/y5HuxO1JTCe/2jVSzOTdDg+DW6E+zhsQJ5wUN76WZMjhwn ps+ThKb8RUupY+g36GII1jJ61eSvpTQ0HEb7rPgcRUHRmjfzcOFDKNdal pQxy3HgJsUqzAlXb0cvb14ceSKhrAdcYd3RLXOT17RoKfraRV/1EUQuZs 22fEmrvHGP84M9L64yyJUyH+o+r45BnG1LyhEEi1afGoCcgLWGoOEbNdj 6pVq7T7iRv6DkW+0mdbpUOzITvUIcRxr3R+ukuR+rfYE8k+vty5X56bw4 cEIKba5FI3aQAkcpOS7aSymZUxCx7FiJT8tNbDI1dv4zO1FpzQ7Rxow5V A==; X-CSE-ConnectionGUID: 30SumiyZTgmsnqtSZKdHSQ== X-CSE-MsgGUID: eF3IM5NgTGW8tGKU7qz6fw== X-IronPort-AV: E=McAfee;i="6800,10657,11479"; a="53218591" X-IronPort-AV: E=Sophos;i="6.16,277,1744095600"; d="scan'208";a="53218591" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2025 02:33:05 -0700 X-CSE-ConnectionGUID: Aw41gVAGTZW6CfaaWBvk6w== X-CSE-MsgGUID: hkZK3k/1RHGkBJFxbVYL7A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,277,1744095600"; d="scan'208";a="153039558" Received: from sannilnx-dsk.jer.intel.com ([10.12.231.107]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2025 02:33:04 -0700 From: Alexander Usyskin To: Greg Kroah-Hartman Cc: Reuven Abliyev , Alexander Usyskin , linux-kernel@vger.kernel.org Subject: [char-misc-next v2 1/5] mei: set parent for char device Date: Mon, 30 Jun 2025 12:19:38 +0300 Message-ID: <20250630091942.2116676-2-alexander.usyskin@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250630091942.2116676-1-alexander.usyskin@intel.com> References: <20250630091942.2116676-1-alexander.usyskin@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Connect char device to parent device to avoid parent device unload while char device is still held open by user-space. Signed-off-by: Alexander Usyskin --- drivers/misc/mei/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index 1f5aaf16e300..95d4c1d8e4e6 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c @@ -1225,6 +1225,7 @@ int mei_register(struct mei_device *dev, struct devic= e *parent) devno =3D MKDEV(MAJOR(mei_devt), dev->minor); cdev_init(&dev->cdev, &mei_fops); dev->cdev.owner =3D parent->driver->owner; + cdev_set_parent(&dev->cdev, &parent->kobj); =20 /* Add the device */ ret =3D cdev_add(&dev->cdev, devno, 1); --=20 2.43.0 From nobody Sun Feb 8 05:07:00 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8301C248F5E for ; Mon, 30 Jun 2025 09:33:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751275988; cv=none; b=p8h5wPqLNyWZ4pvJ8inEYOepAOnGNVjUO/AXe6n8/daj3qPI8sYqVNIT3HZS/nPLu2BvlOkk1w4CThjoXpUrd70nCtc8U9GGcj/4tSkEB/gV1o8CBoiftswupatGqThXIiTQ8V45gB9H6Z1/nyaWGYkSJGfezGyDlaLJJlA4O9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751275988; c=relaxed/simple; bh=FIfEkbz8JdHJOviN1RQuQrM8W1xMWoKA43IuApPDbZw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NDq+VLc5oDsCD3/ueboHtV8y75TGPFEbBrZyyLBUS3LQLz4HLtRfFfzZwNufWvkaCLWRfmSQdehkXRhxu9scB3u23nLWI1nmnYRZUYpCfppJhRQ+Zbt+jjLXzNB+ImswNFbrW3lB0KfJx+seV4dJU2LrEKNPBgaVajll+eAqRqQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Wkx3CpU9; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Wkx3CpU9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751275987; x=1782811987; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FIfEkbz8JdHJOviN1RQuQrM8W1xMWoKA43IuApPDbZw=; b=Wkx3CpU9HcjZaNFDF6e73ltUrHPl386L4ZtlTvZUzR0EdAeU47mdakBT FrcOdy9ZtMh+LUWBmdOl+0QQQb+/x9hI1oZjtduObnmpf3C+nzYqtm1MZ P7T8h7j2ZX00aJzbdrCgpIMThBW7fIjoGNYnypwdbmzqZ3EDAUd+y8de8 Lfrx0k6k1/2v1jHgZjxAy1FU2YBfSFAjQXXcdK/jiV7NFRchefbWDbopp ApxUv+Uky/YFTHLB0q4StHobNsrqbexZyhvHwFPjkfGn/3ewPt5Vfm2kA ukLWKEy3mj+O5m2rHwMteJ/q8byucp2cF0HQNmRCdTNv4/JGd+TtFG21H A==; X-CSE-ConnectionGUID: Lhtr0b78TiWmmzsgJc2LIQ== X-CSE-MsgGUID: 2SqzciRdSk2jd7b/1TVmxA== X-IronPort-AV: E=McAfee;i="6800,10657,11479"; a="53218593" X-IronPort-AV: E=Sophos;i="6.16,277,1744095600"; d="scan'208";a="53218593" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2025 02:33:07 -0700 X-CSE-ConnectionGUID: Lf0p4y5bRVubwnspdk+InA== X-CSE-MsgGUID: HS1TOjSoS2i6DkoHe/oZKg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,277,1744095600"; d="scan'208";a="153039561" Received: from sannilnx-dsk.jer.intel.com ([10.12.231.107]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2025 02:33:05 -0700 From: Alexander Usyskin To: Greg Kroah-Hartman Cc: Reuven Abliyev , Alexander Usyskin , linux-kernel@vger.kernel.org Subject: [char-misc-next v2 2/5] mei: make char device control its own lifetime Date: Mon, 30 Jun 2025 12:19:39 +0300 Message-ID: <20250630091942.2116676-3-alexander.usyskin@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250630091942.2116676-1-alexander.usyskin@intel.com> References: <20250630091942.2116676-1-alexander.usyskin@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allocate character device dynamically and allow to control its own lifetime as it may outlive mei_device structure while character device closes after parent device is removed from the system. Signed-off-by: Alexander Usyskin --- drivers/misc/mei/main.c | 36 +++++++++++++++++++++++------------- drivers/misc/mei/mei_dev.h | 4 ++-- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index 95d4c1d8e4e6..5335cf39d663 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c @@ -51,7 +51,9 @@ static int mei_open(struct inode *inode, struct file *fil= e) =20 int err; =20 - dev =3D container_of(inode->i_cdev, struct mei_device, cdev); + dev =3D idr_find(&mei_idr, iminor(inode)); + if (!dev) + return -ENODEV; =20 mutex_lock(&dev->device_lock); =20 @@ -1118,7 +1120,10 @@ void mei_set_devstate(struct mei_device *dev, enum m= ei_dev_state state) =20 dev->dev_state =3D state; =20 - clsdev =3D class_find_device_by_devt(&mei_class, dev->cdev.dev); + if (!dev->cdev) + return; + + clsdev =3D class_find_device_by_devt(&mei_class, dev->cdev->dev); if (clsdev) { sysfs_notify(&clsdev->kobj, NULL, "dev_state"); put_device(clsdev); @@ -1223,16 +1228,21 @@ int mei_register(struct mei_device *dev, struct dev= ice *parent) =20 /* Fill in the data structures */ devno =3D MKDEV(MAJOR(mei_devt), dev->minor); - cdev_init(&dev->cdev, &mei_fops); - dev->cdev.owner =3D parent->driver->owner; - cdev_set_parent(&dev->cdev, &parent->kobj); + dev->cdev =3D cdev_alloc(); + if (!dev->cdev) { + ret =3D -ENOMEM; + goto err; + } + dev->cdev->ops =3D &mei_fops; + dev->cdev->owner =3D parent->driver->owner; + cdev_set_parent(dev->cdev, &parent->kobj); =20 /* Add the device */ - ret =3D cdev_add(&dev->cdev, devno, 1); + ret =3D cdev_add(dev->cdev, devno, 1); if (ret) { dev_err(parent, "unable to add device %d:%d\n", MAJOR(mei_devt), dev->minor); - goto err_dev_add; + goto err_del_cdev; } =20 clsdev =3D device_create_with_groups(&mei_class, parent, devno, @@ -1243,16 +1253,16 @@ int mei_register(struct mei_device *dev, struct dev= ice *parent) dev_err(parent, "unable to create device %d:%d\n", MAJOR(mei_devt), dev->minor); ret =3D PTR_ERR(clsdev); - goto err_dev_create; + goto err_del_cdev; } =20 mei_dbgfs_register(dev, dev_name(clsdev)); =20 return 0; =20 -err_dev_create: - cdev_del(&dev->cdev); -err_dev_add: +err_del_cdev: + cdev_del(dev->cdev); +err: mei_minor_free(dev); return ret; } @@ -1262,8 +1272,8 @@ void mei_deregister(struct mei_device *dev) { int devno; =20 - devno =3D dev->cdev.dev; - cdev_del(&dev->cdev); + devno =3D dev->cdev->dev; + cdev_del(dev->cdev); =20 mei_dbgfs_deregister(dev); =20 diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h index 37d7fb15cad7..0cc943afa80a 100644 --- a/drivers/misc/mei/mei_dev.h +++ b/drivers/misc/mei/mei_dev.h @@ -471,7 +471,7 @@ struct mei_dev_timeouts { * struct mei_device - MEI private device struct * * @dev : device on a bus - * @cdev : character device + * @cdev : character device pointer * @minor : minor number allocated for device * * @write_list : write pending list @@ -557,7 +557,7 @@ struct mei_dev_timeouts { */ struct mei_device { struct device *dev; - struct cdev cdev; + struct cdev *cdev; int minor; =20 struct list_head write_list; --=20 2.43.0 From nobody Sun Feb 8 05:07:00 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F4A624DCF5 for ; Mon, 30 Jun 2025 09:33:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751275989; cv=none; b=Y9lpV3FmAeu+RhWKbYelg/I9XxLVXzQxIAtu+lU4bu7xVoL7IgSCBloRgYrKf7qbzneepT84vgRcsbgFRCSiCEu5TULg44WuSHijzbbdoOxnBPbKDhLPBP5/vGfOxrj2Tkf3a5YQb2Gy7E5/qfsOQEaKMezrCnbDcmSYul92Tz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751275989; c=relaxed/simple; bh=k6CpQI6U2HXDC55vGr6BSJJaxh2hOKhfwA+pkGvRtyM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LoTBBO88P60M5H3G1FiWBYRfq/Wq6qO0iyIeuVCUa35Er4qIXdM5vxcVL5dEjRpVOIz/hVTm8huqO6T3RHIUXDsVisVa1qVyMcqqgQNrEz5ed0a96vMiZb3N8EwpxTsDKqjvYzdUYEjlQ9CRdNm7bMzh0cFe4KrFdD/2CqN1QFA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HQ1tdvYD; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HQ1tdvYD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751275989; x=1782811989; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k6CpQI6U2HXDC55vGr6BSJJaxh2hOKhfwA+pkGvRtyM=; b=HQ1tdvYD1rf8+Ui9zzt6h2nUKf6oThfE9DBsNwyvCkyL0oaCkNbk+oCO LfwX4X1242y3C66pqGe4ma9G77oTCp/R99rUurlcMzT4PWx5BdBKKeAfn B+838aWfKJyI5aW0uvXBEXn2TJ0APOxKwmPmgXhRF2QFqg9tofZYUvyNJ HLHVV+hfSA1wZqskh/xN++jP/7mPEUMFpKs4E74C8TV1unzfDKSNgz8Lf SajKrfFxTK3I/wDMi0g4najzUxD1L0nyShw7UQ0ovpMZPJGb41DzZFVtm R46N5DkUazngm4WABWDnKDx3Z0k3s8jq2J1cWQ8aJaelv2iVljgXAj8d2 g==; X-CSE-ConnectionGUID: LCrFoELqRyOyarJ/2jMIxA== X-CSE-MsgGUID: CxUO9itBSD67KZ6DFm+0xw== X-IronPort-AV: E=McAfee;i="6800,10657,11479"; a="53218596" X-IronPort-AV: E=Sophos;i="6.16,277,1744095600"; d="scan'208";a="53218596" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2025 02:33:08 -0700 X-CSE-ConnectionGUID: U5Xtf1ZAS3CIztt2GkbnHQ== X-CSE-MsgGUID: upvenSqBQliRvM1PqC1TDg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,277,1744095600"; d="scan'208";a="153039564" Received: from sannilnx-dsk.jer.intel.com ([10.12.231.107]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2025 02:33:07 -0700 From: Alexander Usyskin To: Greg Kroah-Hartman Cc: Reuven Abliyev , Alexander Usyskin , linux-kernel@vger.kernel.org Subject: [char-misc-next v2 3/5] mei: bus: use cldev in prints Date: Mon, 30 Jun 2025 12:19:40 +0300 Message-ID: <20250630091942.2116676-4-alexander.usyskin@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250630091942.2116676-1-alexander.usyskin@intel.com> References: <20250630091942.2116676-1-alexander.usyskin@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For unifomity, print using client device on bus where possible. Signed-off-by: Alexander Usyskin --- drivers/misc/mei/bus-fixup.c | 10 +++++----- drivers/misc/mei/bus.c | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c index 9eebeffcd8fd..90dba20b2de7 100644 --- a/drivers/misc/mei/bus-fixup.c +++ b/drivers/misc/mei/bus-fixup.c @@ -463,14 +463,14 @@ static void mei_nfc(struct mei_cl_device *cldev) if (IS_ERR(cl)) { ret =3D PTR_ERR(cl); cl =3D NULL; - dev_err(bus->dev, "nfc hook alloc failed %d\n", ret); + dev_err(&cldev->dev, "nfc hook alloc failed %d\n", ret); goto out; } =20 me_cl =3D mei_me_cl_by_uuid(bus, &mei_nfc_info_guid); if (!me_cl) { ret =3D -ENOTTY; - dev_err(bus->dev, "Cannot find nfc info %d\n", ret); + dev_err(&cldev->dev, "Cannot find nfc info %d\n", ret); goto out; } =20 @@ -496,13 +496,13 @@ static void mei_nfc(struct mei_cl_device *cldev) goto disconnect; } =20 - dev_dbg(bus->dev, "nfc radio %s\n", radio_name); + dev_dbg(&cldev->dev, "nfc radio %s\n", radio_name); strscpy(cldev->name, radio_name, sizeof(cldev->name)); =20 disconnect: mutex_lock(&bus->device_lock); if (mei_cl_disconnect(cl) < 0) - dev_err(bus->dev, "Can't disconnect the NFC INFO ME\n"); + dev_err(&cldev->dev, "Can't disconnect the NFC INFO ME\n"); =20 mei_cl_flush_queues(cl, NULL); =20 @@ -515,7 +515,7 @@ static void mei_nfc(struct mei_cl_device *cldev) if (ret) cldev->do_match =3D 0; =20 - dev_dbg(bus->dev, "end of fixup match =3D %d\n", cldev->do_match); + dev_dbg(&cldev->dev, "end of fixup match =3D %d\n", cldev->do_match); } =20 /** diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index 67176caf5416..d90d830b8261 100644 --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c @@ -875,14 +875,14 @@ int mei_cldev_disable(struct mei_cl_device *cldev) mei_cl_bus_vtag_free(cldev); =20 if (!mei_cl_is_connected(cl)) { - dev_dbg(bus->dev, "Already disconnected\n"); + dev_dbg(&cldev->dev, "Already disconnected\n"); err =3D 0; goto out; } =20 err =3D mei_cl_disconnect(cl); if (err < 0) - dev_err(bus->dev, "Could not disconnect from the ME client\n"); + dev_err(&cldev->dev, "Could not disconnect from the ME client\n"); =20 out: /* Flush queues and remove any pending read unless we have mapped DMA */ @@ -935,7 +935,7 @@ ssize_t mei_cldev_send_gsc_command(struct mei_cl_device= *cldev, cl =3D cldev->cl; bus =3D cldev->bus; =20 - dev_dbg(bus->dev, "client_id %u, fence_id %u\n", client_id, fence_id); + dev_dbg(&cldev->dev, "client_id %u, fence_id %u\n", client_id, fence_id); =20 if (!bus->hbm_f_gsc_supported) return -EOPNOTSUPP; @@ -983,11 +983,11 @@ ssize_t mei_cldev_send_gsc_command(struct mei_cl_devi= ce *cldev, /* send the message to GSC */ ret =3D __mei_cl_send(cl, (u8 *)ext_hdr, buf_sz, 0, MEI_CL_IO_SGL); if (ret < 0) { - dev_err(bus->dev, "__mei_cl_send failed, returned %zd\n", ret); + dev_err(&cldev->dev, "__mei_cl_send failed, returned %zd\n", ret); goto end; } if (ret !=3D buf_sz) { - dev_err(bus->dev, "__mei_cl_send returned %zd instead of expected %zd\n", + dev_err(&cldev->dev, "__mei_cl_send returned %zd instead of expected %zd= \n", ret, buf_sz); ret =3D -EIO; goto end; @@ -997,7 +997,7 @@ ssize_t mei_cldev_send_gsc_command(struct mei_cl_device= *cldev, ret =3D __mei_cl_recv(cl, (u8 *)&rx_msg, sizeof(rx_msg), NULL, MEI_CL_IO_= SGL, 0); =20 if (ret !=3D sizeof(rx_msg)) { - dev_err(bus->dev, "__mei_cl_recv returned %zd instead of expected %zd\n", + dev_err(&cldev->dev, "__mei_cl_recv returned %zd instead of expected %zd= \n", ret, sizeof(rx_msg)); if (ret >=3D 0) ret =3D -EIO; @@ -1006,13 +1006,13 @@ ssize_t mei_cldev_send_gsc_command(struct mei_cl_de= vice *cldev, =20 /* check rx_msg.client_id and rx_msg.fence_id match the ones we send */ if (rx_msg.client_id !=3D client_id || rx_msg.fence_id !=3D fence_id) { - dev_err(bus->dev, "received client_id/fence_id %u/%u instead of %u/%u = sent\n", + dev_err(&cldev->dev, "received client_id/fence_id %u/%u instead of %u/= %u sent\n", rx_msg.client_id, rx_msg.fence_id, client_id, fence_id); ret =3D -EFAULT; goto end; } =20 - dev_dbg(bus->dev, "gsc command: successfully written %u bytes\n", rx_msg= .written); + dev_dbg(&cldev->dev, "gsc command: successfully written %u bytes\n", rx_m= sg.written); ret =3D rx_msg.written; =20 end: @@ -1399,7 +1399,7 @@ static int mei_cl_bus_dev_add(struct mei_cl_device *c= ldev) { int ret; =20 - dev_dbg(cldev->bus->dev, "adding %pUL:%02X\n", + dev_dbg(&cldev->dev, "adding %pUL:%02X\n", mei_me_cl_uuid(cldev->me_cl), mei_me_cl_ver(cldev->me_cl)); ret =3D device_add(&cldev->dev); --=20 2.43.0 From nobody Sun Feb 8 05:07:00 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6159246BCB for ; Mon, 30 Jun 2025 09:33:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751275991; cv=none; b=FgDYQ5i8ZxnuLzTj4l07iu+yatlY0fHnT6b5qttakccO3jVssZsZ6hkJF4lRz9u70jNp1h1hEiNL4Tj5CWUJmM0cBFmkazWGkCPnKMpIDg247MLHWRdOU+ShLoEnahesaNzPSNhH9Ahmv/aPiLLafnTFjHEwmnOA3zZgx81+LKU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751275991; c=relaxed/simple; bh=GsK1OIdfCnDeg2B6vJEkWD/flkOTW/TNAQ+J/NKLwK4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LeUOY20reX4Jz7gcOewpa1u5UcY6AYJeron4ZNIaBjSCVH9clzblzQXoyVrkoXA9ixhU5gIo5EEks5yFkbW+hbQ+TpSYhEDjISsv5pyGojaoYEtHLFFtuMHrnEmWbQ5u/+MvoZofARa16lqO93pUCfMKdpk+GaqpDuDp4NR+0K0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=eY/b5tKP; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eY/b5tKP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751275990; x=1782811990; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GsK1OIdfCnDeg2B6vJEkWD/flkOTW/TNAQ+J/NKLwK4=; b=eY/b5tKPJvzyokD2HXjwp0nHRWDmo0JYITpHumpACDABVFgC8+yOrUhE mHmXO9oAYC6YW1crukc5u5Rofm85LTPTMgkrMWVxypUN2oeau0Pd7DPix XSGzkjaXOvPezVs5GvWmohZ8IGNUf00Sos0WnR/FwcdYZ2g2uj4kFWOoF nMWWXp9n0vSYGuT/fnykYMKn8FG8e4d9HjIaxo8tH6AWsvP+9nVzbzWVv 3/uVrPEjfwCy+LxjIwr1mI1dmyb6rMYDVxAU2FgNWLikGEHmC7UO9hjP5 VRiLcaOPw3Ip3PuW+JXBh3UvrP3JwYrMvMHG5Tt1xMEb85PZ1D11KktpR g==; X-CSE-ConnectionGUID: P+Go5FiDQOO1vtTjoA4l9Q== X-CSE-MsgGUID: cGnqmoSaTKGy2TLo9vQm1Q== X-IronPort-AV: E=McAfee;i="6800,10657,11479"; a="53218601" X-IronPort-AV: E=Sophos;i="6.16,277,1744095600"; d="scan'208";a="53218601" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2025 02:33:10 -0700 X-CSE-ConnectionGUID: JiczxoBXT02WygQLvP2+fQ== X-CSE-MsgGUID: vsiQNsABRvaGyIevDI3Q+A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,277,1744095600"; d="scan'208";a="153039578" Received: from sannilnx-dsk.jer.intel.com ([10.12.231.107]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2025 02:33:08 -0700 From: Alexander Usyskin To: Greg Kroah-Hartman Cc: Reuven Abliyev , Alexander Usyskin , linux-kernel@vger.kernel.org Subject: [char-misc-next v2 4/5] mei: more prints with client prefix Date: Mon, 30 Jun 2025 12:19:41 +0300 Message-ID: <20250630091942.2116676-5-alexander.usyskin@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250630091942.2116676-1-alexander.usyskin@intel.com> References: <20250630091942.2116676-1-alexander.usyskin@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use client-aware print macro instead of usual device print in more places. Signed-off-by: Alexander Usyskin --- drivers/misc/mei/hbm.c | 14 ++++----- drivers/misc/mei/interrupt.c | 2 +- drivers/misc/mei/main.c | 55 +++++++++++++++++------------------- 3 files changed, 34 insertions(+), 37 deletions(-) diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c index 026b1f686c16..4fe9a2752d43 100644 --- a/drivers/misc/mei/hbm.c +++ b/drivers/misc/mei/hbm.c @@ -510,7 +510,7 @@ int mei_hbm_cl_notify_req(struct mei_device *dev, =20 ret =3D mei_hbm_write_message(dev, &mei_hdr, &req); if (ret) - dev_err(dev->dev, "notify request failed: ret =3D %d\n", ret); + cl_err(dev, cl, "notify request failed: ret =3D %d\n", ret); =20 return ret; } @@ -626,7 +626,7 @@ int mei_hbm_cl_dma_map_req(struct mei_device *dev, stru= ct mei_cl *cl) =20 ret =3D mei_hbm_write_message(dev, &mei_hdr, &req); if (ret) - dev_err(dev->dev, "dma map request failed: ret =3D %d\n", ret); + cl_err(dev, cl, "dma map request failed: ret =3D %d\n", ret); =20 return ret; } @@ -654,7 +654,7 @@ int mei_hbm_cl_dma_unmap_req(struct mei_device *dev, st= ruct mei_cl *cl) =20 ret =3D mei_hbm_write_message(dev, &mei_hdr, &req); if (ret) - dev_err(dev->dev, "dma unmap request failed: ret =3D %d\n", ret); + cl_err(dev, cl, "dma unmap request failed: ret =3D %d\n", ret); =20 return ret; } @@ -679,10 +679,10 @@ static void mei_hbm_cl_dma_map_res(struct mei_device = *dev, return; =20 if (res->status) { - dev_err(dev->dev, "cl dma map failed %d\n", res->status); + cl_err(dev, cl, "cl dma map failed %d\n", res->status); cl->status =3D -EFAULT; } else { - dev_dbg(dev->dev, "cl dma map succeeded\n"); + cl_dbg(dev, cl, "cl dma map succeeded\n"); cl->dma_mapped =3D 1; cl->status =3D 0; } @@ -709,10 +709,10 @@ static void mei_hbm_cl_dma_unmap_res(struct mei_devic= e *dev, return; =20 if (res->status) { - dev_err(dev->dev, "cl dma unmap failed %d\n", res->status); + cl_err(dev, cl, "cl dma unmap failed %d\n", res->status); cl->status =3D -EFAULT; } else { - dev_dbg(dev->dev, "cl dma unmap succeeded\n"); + cl_dbg(dev, cl, "cl dma unmap succeeded\n"); cl->dma_mapped =3D 0; cl->status =3D 0; } diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c index c484f416fae4..d472f6bbe767 100644 --- a/drivers/misc/mei/interrupt.c +++ b/drivers/misc/mei/interrupt.c @@ -35,7 +35,7 @@ void mei_irq_compl_handler(struct mei_device *dev, struct= list_head *cmpl_list) cl =3D cb->cl; list_del_init(&cb->list); =20 - dev_dbg(dev->dev, "completing call back.\n"); + cl_dbg(dev, cl, "completing call back.\n"); mei_cl_complete(cl, cb); } } diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index 5335cf39d663..90c9eef0d876 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c @@ -258,7 +258,7 @@ static ssize_t mei_read(struct file *file, char __user = *ubuf, length =3D min_t(size_t, length, cb->buf_idx - *offset); =20 if (copy_to_user(ubuf, cb->buf.data + *offset, length)) { - dev_dbg(dev->dev, "failed to copy data to userland\n"); + cl_dbg(dev, cl, "failed to copy data to userland\n"); rets =3D -EFAULT; goto free; } @@ -381,7 +381,7 @@ static ssize_t mei_write(struct file *file, const char = __user *ubuf, =20 rets =3D copy_from_user(cb->buf.data, ubuf, length); if (rets) { - dev_dbg(dev->dev, "failed to copy data from userland\n"); + cl_dbg(dev, cl, "failed to copy data from userland\n"); rets =3D -EFAULT; mei_io_cb_free(cb); goto out; @@ -423,7 +423,7 @@ static int mei_ioctl_connect_client(struct file *file, /* find ME client we're trying to connect to */ me_cl =3D mei_me_cl_by_uuid(dev, in_client_uuid); if (!me_cl) { - dev_dbg(dev->dev, "Cannot connect to FW Client UUID =3D %pUl\n", + cl_dbg(dev, cl, "Cannot connect to FW Client UUID =3D %pUl\n", in_client_uuid); rets =3D -ENOTTY; goto end; @@ -433,24 +433,21 @@ static int mei_ioctl_connect_client(struct file *file, bool forbidden =3D dev->override_fixed_address ? !dev->allow_fixed_address : !dev->hbm_f_fa_supported; if (forbidden) { - dev_dbg(dev->dev, "Connection forbidden to FW Client UUID =3D %pUl\n", + cl_dbg(dev, cl, "Connection forbidden to FW Client UUID =3D %pUl\n", in_client_uuid); rets =3D -ENOTTY; goto end; } } =20 - dev_dbg(dev->dev, "Connect to FW Client ID =3D %d\n", - me_cl->client_id); - dev_dbg(dev->dev, "FW Client - Protocol Version =3D %d\n", - me_cl->props.protocol_version); - dev_dbg(dev->dev, "FW Client - Max Msg Len =3D %d\n", - me_cl->props.max_msg_length); + cl_dbg(dev, cl, "Connect to FW Client ID =3D %d\n", me_cl->client_id); + cl_dbg(dev, cl, "FW Client - Protocol Version =3D %d\n", me_cl->props.pro= tocol_version); + cl_dbg(dev, cl, "FW Client - Max Msg Len =3D %d\n", me_cl->props.max_msg_= length); =20 /* prepare the output buffer */ client->max_msg_length =3D me_cl->props.max_msg_length; client->protocol_version =3D me_cl->props.protocol_version; - dev_dbg(dev->dev, "Can connect?\n"); + cl_dbg(dev, cl, "Can connect?\n"); =20 rets =3D mei_cl_connect(cl, me_cl, file); =20 @@ -517,19 +514,19 @@ static int mei_ioctl_connect_vtag(struct file *file, cl =3D file->private_data; dev =3D cl->dev; =20 - dev_dbg(dev->dev, "FW Client %pUl vtag %d\n", in_client_uuid, vtag); + cl_dbg(dev, cl, "FW Client %pUl vtag %d\n", in_client_uuid, vtag); =20 switch (cl->state) { case MEI_FILE_DISCONNECTED: if (mei_cl_vtag_by_fp(cl, file) !=3D vtag) { - dev_err(dev->dev, "reconnect with different vtag\n"); + cl_err(dev, cl, "reconnect with different vtag\n"); return -EINVAL; } break; case MEI_FILE_INITIALIZING: /* malicious connect from another thread may push vtag */ if (!IS_ERR(mei_cl_fp_by_vtag(cl, vtag))) { - dev_err(dev->dev, "vtag already filled\n"); + cl_err(dev, cl, "vtag already filled\n"); return -EINVAL; } =20 @@ -548,7 +545,7 @@ static int mei_ioctl_connect_vtag(struct file *file, continue; =20 /* replace cl with acquired one */ - dev_dbg(dev->dev, "replacing with existing cl\n"); + cl_dbg(dev, cl, "replacing with existing cl\n"); mei_cl_unlink(cl); kfree(cl); file->private_data =3D pos; @@ -658,7 +655,7 @@ static long mei_ioctl(struct file *file, unsigned int c= md, unsigned long data) =20 dev =3D cl->dev; =20 - dev_dbg(dev->dev, "IOCTL cmd =3D 0x%x", cmd); + cl_dbg(dev, cl, "IOCTL cmd =3D 0x%x", cmd); =20 mutex_lock(&dev->device_lock); if (dev->dev_state !=3D MEI_DEV_ENABLED) { @@ -668,9 +665,9 @@ static long mei_ioctl(struct file *file, unsigned int c= md, unsigned long data) =20 switch (cmd) { case IOCTL_MEI_CONNECT_CLIENT: - dev_dbg(dev->dev, ": IOCTL_MEI_CONNECT_CLIENT.\n"); + cl_dbg(dev, cl, "IOCTL_MEI_CONNECT_CLIENT\n"); if (copy_from_user(&conn, (char __user *)data, sizeof(conn))) { - dev_dbg(dev->dev, "failed to copy data from userland\n"); + cl_dbg(dev, cl, "failed to copy data from userland\n"); rets =3D -EFAULT; goto out; } @@ -691,7 +688,7 @@ static long mei_ioctl(struct file *file, unsigned int c= md, unsigned long data) =20 /* if all is ok, copying the data back to user. */ if (copy_to_user((char __user *)data, &conn, sizeof(conn))) { - dev_dbg(dev->dev, "failed to copy data to userland\n"); + cl_dbg(dev, cl, "failed to copy data to userland\n"); rets =3D -EFAULT; goto out; } @@ -699,10 +696,10 @@ static long mei_ioctl(struct file *file, unsigned int= cmd, unsigned long data) break; =20 case IOCTL_MEI_CONNECT_CLIENT_VTAG: - dev_dbg(dev->dev, "IOCTL_MEI_CONNECT_CLIENT_VTAG\n"); + cl_dbg(dev, cl, "IOCTL_MEI_CONNECT_CLIENT_VTAG\n"); if (copy_from_user(&conn_vtag, (char __user *)data, sizeof(conn_vtag))) { - dev_dbg(dev->dev, "failed to copy data from userland\n"); + cl_dbg(dev, cl, "failed to copy data from userland\n"); rets =3D -EFAULT; goto out; } @@ -713,13 +710,13 @@ static long mei_ioctl(struct file *file, unsigned int= cmd, unsigned long data) =20 rets =3D mei_vt_support_check(dev, cl_uuid); if (rets =3D=3D -EOPNOTSUPP) - dev_dbg(dev->dev, "FW Client %pUl does not support vtags\n", + cl_dbg(dev, cl, "FW Client %pUl does not support vtags\n", cl_uuid); if (rets) goto out; =20 if (!vtag) { - dev_dbg(dev->dev, "vtag can't be zero\n"); + cl_dbg(dev, cl, "vtag can't be zero\n"); rets =3D -EINVAL; goto out; } @@ -731,7 +728,7 @@ static long mei_ioctl(struct file *file, unsigned int c= md, unsigned long data) /* if all is ok, copying the data back to user. */ if (copy_to_user((char __user *)data, &conn_vtag, sizeof(conn_vtag))) { - dev_dbg(dev->dev, "failed to copy data to userland\n"); + cl_dbg(dev, cl, "failed to copy data to userland\n"); rets =3D -EFAULT; goto out; } @@ -739,10 +736,10 @@ static long mei_ioctl(struct file *file, unsigned int= cmd, unsigned long data) break; =20 case IOCTL_MEI_NOTIFY_SET: - dev_dbg(dev->dev, ": IOCTL_MEI_NOTIFY_SET.\n"); + cl_dbg(dev, cl, "IOCTL_MEI_NOTIFY_SET\n"); if (copy_from_user(¬ify_req, (char __user *)data, sizeof(notify_req))) { - dev_dbg(dev->dev, "failed to copy data from userland\n"); + cl_dbg(dev, cl, "failed to copy data from userland\n"); rets =3D -EFAULT; goto out; } @@ -750,15 +747,15 @@ static long mei_ioctl(struct file *file, unsigned int= cmd, unsigned long data) break; =20 case IOCTL_MEI_NOTIFY_GET: - dev_dbg(dev->dev, ": IOCTL_MEI_NOTIFY_GET.\n"); + cl_dbg(dev, cl, "IOCTL_MEI_NOTIFY_GET\n"); rets =3D mei_ioctl_client_notify_get(file, ¬ify_get); if (rets) goto out; =20 - dev_dbg(dev->dev, "copy connect data to user\n"); + cl_dbg(dev, cl, "copy connect data to user\n"); if (copy_to_user((char __user *)data, ¬ify_get, sizeof(notify_get))) { - dev_dbg(dev->dev, "failed to copy data to userland\n"); + cl_dbg(dev, cl, "failed to copy data to userland\n"); rets =3D -EFAULT; goto out; =20 --=20 2.43.0 From nobody Sun Feb 8 05:07:00 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED1F5253947 for ; Mon, 30 Jun 2025 09:33:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751275996; cv=none; b=eDU2VyKVCQSPDNSG7j4Ihxb9x+M2v5vSpXuil8N5WUNUKlkqWRJCY1U6XkyY1US1ptLklKJM4VjA4pqFdoMhlSVo2YFTzonAMCd8e8uly1FdZ8P8cx667myGDPukvOG1bThc8vo/IkZ2JendoljswWTa/Zpt4akrm/sN51clU6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751275996; c=relaxed/simple; bh=p2sDD/cfWP8kzT83IHHvFFIYGoypI2GrheUL87UTBIY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sjt5aa8qGoxJxlJdCVKOgfsDSnGBgyuTvSZRvTmZ3CcIV0LQ/xWIA7HQIZVw2HAvHWWw/mD6AAqfQjJB/SV+1IcAGUo4DdNT5/EXLJt0hUXjsRIibFES/9tTWigDPyZFyTt+cUwxKQyzotO8uxI/WSDHIJ3ExZt7qsDeUvkf63g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=V9/w6gjG; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="V9/w6gjG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751275992; x=1782811992; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=p2sDD/cfWP8kzT83IHHvFFIYGoypI2GrheUL87UTBIY=; b=V9/w6gjG+HNV1Z8Vq2nXLgn62bPZQ4akUEcCMOWry9m2fccn9lTqRKV/ HR8yA3JIw47EiMsV9wNNAebB6A/8xap73glbLZx0gFeqvAzQl39PrDNHT Q6Bm7wBe/odhvbWJ/cQV4gGkFXyY+brCVXoXi+BmeXCZhDK9+KvCj3S6h K5cqeKTEGerXjnLEb4c0tm5bo/xg5PUw/wrzlAPrhgV7z7oMEdprKJ4iB Jao7CGqQ3ThOWLjC/BC7yA5NwaADOlCo0QibSgN6tUvGV4TVeJp+Xy9lz DZ3stO2/uJocLJpJn53UmGK/cAX0sA5nkJkCqgFv+6Y6NVQSo+hXvAIK5 Q==; X-CSE-ConnectionGUID: 8k7hRVoqRMG1k2ZrbL1UTg== X-CSE-MsgGUID: GdFin+9AS3+y7LInT47pkQ== X-IronPort-AV: E=McAfee;i="6800,10657,11479"; a="53218605" X-IronPort-AV: E=Sophos;i="6.16,277,1744095600"; d="scan'208";a="53218605" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2025 02:33:12 -0700 X-CSE-ConnectionGUID: xtO2xT9pT52k5KGDLWaAYA== X-CSE-MsgGUID: Hwj1DQQ/SyK9H5Kc947GGA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,277,1744095600"; d="scan'208";a="153039608" Received: from sannilnx-dsk.jer.intel.com ([10.12.231.107]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2025 02:33:10 -0700 From: Alexander Usyskin To: Greg Kroah-Hartman Cc: Reuven Abliyev , Alexander Usyskin , linux-kernel@vger.kernel.org Subject: [char-misc-next v2 5/5] mei: create dedicated device object Date: Mon, 30 Jun 2025 12:19:42 +0300 Message-ID: <20250630091942.2116676-6-alexander.usyskin@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250630091942.2116676-1-alexander.usyskin@intel.com> References: <20250630091942.2116676-1-alexander.usyskin@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" mei_device lifetime is managed by devm procedure of parent device. But such memory is freed on device_del. Mei_device object is used by client object that may be alive after parent device is removed. It may lead to use-after-free if discrete graphics driver unloads mei_gsc auxiliary device while user-space holds open handle to mei character device. Add dedicated device object to control driver private data lifetime. Rename exising parent device pointer from dev to parent to avoid misuse. Leave power management on parent device as user-space is expecting it there. Signed-off-by: Alexander Usyskin --- drivers/misc/mei/bus-fixup.c | 6 +- drivers/misc/mei/bus.c | 24 ++++--- drivers/misc/mei/client.c | 82 +++++++++++----------- drivers/misc/mei/client.h | 6 +- drivers/misc/mei/dma-ring.c | 8 +-- drivers/misc/mei/gsc-me.c | 13 ++-- drivers/misc/mei/hbm.c | 121 +++++++++++++++----------------- drivers/misc/mei/hw-me.c | 101 +++++++++++++------------- drivers/misc/mei/hw-txe.c | 62 ++++++++-------- drivers/misc/mei/init.c | 85 +++++++++++++++------- drivers/misc/mei/interrupt.c | 45 ++++++------ drivers/misc/mei/main.c | 9 ++- drivers/misc/mei/mei_dev.h | 11 +-- drivers/misc/mei/pci-me.c | 12 ++-- drivers/misc/mei/pci-txe.c | 10 ++- drivers/misc/mei/platform-vsc.c | 18 ++--- 16 files changed, 331 insertions(+), 282 deletions(-) diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c index 90dba20b2de7..e6a1d3534663 100644 --- a/drivers/misc/mei/bus-fixup.c +++ b/drivers/misc/mei/bus-fixup.c @@ -386,7 +386,7 @@ static int mei_nfc_if_version(struct mei_cl *cl, ret =3D __mei_cl_send(cl, (u8 *)&cmd, sizeof(cmd), 0, MEI_CL_IO_TX_BLOCKING); if (ret < 0) { - dev_err(bus->dev, "Could not send IF version cmd ret =3D %d\n", ret); + dev_err(&bus->dev, "Could not send IF version cmd ret =3D %d\n", ret); return ret; } =20 @@ -401,14 +401,14 @@ static int mei_nfc_if_version(struct mei_cl *cl, bytes_recv =3D __mei_cl_recv(cl, (u8 *)reply, if_version_length, &vtag, 0, 0); if (bytes_recv < 0 || (size_t)bytes_recv < if_version_length) { - dev_err(bus->dev, "Could not read IF version ret =3D %d\n", bytes_recv); + dev_err(&bus->dev, "Could not read IF version ret =3D %d\n", bytes_recv); ret =3D -EIO; goto err; } =20 memcpy(ver, reply->data, sizeof(*ver)); =20 - dev_info(bus->dev, "NFC MEI VERSION: IVN 0x%x Vendor ID 0x%x Type 0x%x\n", + dev_info(&bus->dev, "NFC MEI VERSION: IVN 0x%x Vendor ID 0x%x Type 0x%x\n= ", ver->fw_ivn, ver->vendor_id, ver->radio_type); =20 err: diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index d90d830b8261..00ea20afa15b 100644 --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c @@ -637,7 +637,7 @@ EXPORT_SYMBOL_GPL(mei_cldev_enabled); */ static bool mei_cl_bus_module_get(struct mei_cl_device *cldev) { - return try_module_get(cldev->bus->dev->driver->owner); + return try_module_get(cldev->bus->parent->driver->owner); } =20 /** @@ -647,7 +647,7 @@ static bool mei_cl_bus_module_get(struct mei_cl_device = *cldev) */ static void mei_cl_bus_module_put(struct mei_cl_device *cldev) { - module_put(cldev->bus->dev->driver->owner); + module_put(cldev->bus->parent->driver->owner); } =20 /** @@ -1286,16 +1286,20 @@ static const struct bus_type mei_cl_bus_type =3D { =20 static struct mei_device *mei_dev_bus_get(struct mei_device *bus) { - if (bus) - get_device(bus->dev); + if (bus) { + get_device(&bus->dev); + get_device(bus->parent); + } =20 return bus; } =20 static void mei_dev_bus_put(struct mei_device *bus) { - if (bus) - put_device(bus->dev); + if (bus) { + put_device(bus->parent); + put_device(&bus->dev); + } } =20 static void mei_cl_bus_dev_release(struct device *dev) @@ -1323,7 +1327,7 @@ static const struct device_type mei_cl_device_type = =3D { static inline void mei_cl_bus_set_name(struct mei_cl_device *cldev) { dev_set_name(&cldev->dev, "%s-%pUl", - dev_name(cldev->bus->dev), + dev_name(cldev->bus->parent), mei_me_cl_uuid(cldev->me_cl)); } =20 @@ -1352,7 +1356,7 @@ static struct mei_cl_device *mei_cl_bus_dev_alloc(str= uct mei_device *bus, } =20 device_initialize(&cldev->dev); - cldev->dev.parent =3D bus->dev; + cldev->dev.parent =3D bus->parent; cldev->dev.bus =3D &mei_cl_bus_type; cldev->dev.type =3D &mei_cl_device_type; cldev->bus =3D mei_dev_bus_get(bus); @@ -1487,7 +1491,7 @@ static void mei_cl_bus_dev_init(struct mei_device *bu= s, =20 WARN_ON(!mutex_is_locked(&bus->cl_bus_lock)); =20 - dev_dbg(bus->dev, "initializing %pUl", mei_me_cl_uuid(me_cl)); + dev_dbg(&bus->dev, "initializing %pUl", mei_me_cl_uuid(me_cl)); =20 if (me_cl->bus_added) return; @@ -1538,7 +1542,7 @@ static void mei_cl_bus_rescan(struct mei_device *bus) } mutex_unlock(&bus->cl_bus_lock); =20 - dev_dbg(bus->dev, "rescan end"); + dev_dbg(&bus->dev, "rescan end"); } =20 void mei_cl_bus_rescan_work(struct work_struct *work) diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c index 3db07d2a881f..159e8b841564 100644 --- a/drivers/misc/mei/client.c +++ b/drivers/misc/mei/client.c @@ -262,7 +262,7 @@ void mei_me_cl_rm_by_uuid(struct mei_device *dev, const= uuid_le *uuid) { struct mei_me_client *me_cl; =20 - dev_dbg(dev->dev, "remove %pUl\n", uuid); + dev_dbg(&dev->dev, "remove %pUl\n", uuid); =20 down_write(&dev->me_clients_rwsem); me_cl =3D __mei_me_cl_by_uuid(dev, uuid); @@ -635,12 +635,12 @@ int mei_cl_link(struct mei_cl *cl) =20 id =3D find_first_zero_bit(dev->host_clients_map, MEI_CLIENTS_MAX); if (id >=3D MEI_CLIENTS_MAX) { - dev_err(dev->dev, "id exceeded %d", MEI_CLIENTS_MAX); + dev_err(&dev->dev, "id exceeded %d", MEI_CLIENTS_MAX); return -EMFILE; } =20 if (dev->open_handle_count >=3D MEI_MAX_OPEN_HANDLE_COUNT) { - dev_err(dev->dev, "open_handle_count exceeded %d", + dev_err(&dev->dev, "open_handle_count exceeded %d", MEI_MAX_OPEN_HANDLE_COUNT); return -EMFILE; } @@ -709,9 +709,9 @@ void mei_host_client_init(struct mei_device *dev) =20 schedule_work(&dev->bus_rescan_work); =20 - pm_runtime_mark_last_busy(dev->dev); - dev_dbg(dev->dev, "rpm: autosuspend\n"); - pm_request_autosuspend(dev->dev); + pm_runtime_mark_last_busy(dev->parent); + dev_dbg(&dev->dev, "rpm: autosuspend\n"); + pm_request_autosuspend(dev->parent); } =20 /** @@ -724,12 +724,12 @@ bool mei_hbuf_acquire(struct mei_device *dev) { if (mei_pg_state(dev) =3D=3D MEI_PG_ON || mei_pg_in_transition(dev)) { - dev_dbg(dev->dev, "device is in pg\n"); + dev_dbg(&dev->dev, "device is in pg\n"); return false; } =20 if (!dev->hbuf_is_ready) { - dev_dbg(dev->dev, "hbuf is not ready\n"); + dev_dbg(&dev->dev, "hbuf is not ready\n"); return false; } =20 @@ -981,9 +981,9 @@ int mei_cl_disconnect(struct mei_cl *cl) return 0; } =20 - rets =3D pm_runtime_get(dev->dev); + rets =3D pm_runtime_get(dev->parent); if (rets < 0 && rets !=3D -EINPROGRESS) { - pm_runtime_put_noidle(dev->dev); + pm_runtime_put_noidle(dev->parent); cl_err(dev, cl, "rpm: get failed %d\n", rets); return rets; } @@ -991,8 +991,8 @@ int mei_cl_disconnect(struct mei_cl *cl) rets =3D __mei_cl_disconnect(cl); =20 cl_dbg(dev, cl, "rpm: autosuspend\n"); - pm_runtime_mark_last_busy(dev->dev); - pm_runtime_put_autosuspend(dev->dev); + pm_runtime_mark_last_busy(dev->parent); + pm_runtime_put_autosuspend(dev->parent); =20 return rets; } @@ -1118,9 +1118,9 @@ int mei_cl_connect(struct mei_cl *cl, struct mei_me_c= lient *me_cl, goto nortpm; } =20 - rets =3D pm_runtime_get(dev->dev); + rets =3D pm_runtime_get(dev->parent); if (rets < 0 && rets !=3D -EINPROGRESS) { - pm_runtime_put_noidle(dev->dev); + pm_runtime_put_noidle(dev->parent); cl_err(dev, cl, "rpm: get failed %d\n", rets); goto nortpm; } @@ -1167,8 +1167,8 @@ int mei_cl_connect(struct mei_cl *cl, struct mei_me_c= lient *me_cl, rets =3D cl->status; out: cl_dbg(dev, cl, "rpm: autosuspend\n"); - pm_runtime_mark_last_busy(dev->dev); - pm_runtime_put_autosuspend(dev->dev); + pm_runtime_mark_last_busy(dev->parent); + pm_runtime_put_autosuspend(dev->parent); =20 mei_io_cb_free(cb); =20 @@ -1517,9 +1517,9 @@ int mei_cl_notify_request(struct mei_cl *cl, if (!mei_cl_is_connected(cl)) return -ENODEV; =20 - rets =3D pm_runtime_get(dev->dev); + rets =3D pm_runtime_get(dev->parent); if (rets < 0 && rets !=3D -EINPROGRESS) { - pm_runtime_put_noidle(dev->dev); + pm_runtime_put_noidle(dev->parent); cl_err(dev, cl, "rpm: get failed %d\n", rets); return rets; } @@ -1554,8 +1554,8 @@ int mei_cl_notify_request(struct mei_cl *cl, =20 out: cl_dbg(dev, cl, "rpm: autosuspend\n"); - pm_runtime_mark_last_busy(dev->dev); - pm_runtime_put_autosuspend(dev->dev); + pm_runtime_mark_last_busy(dev->parent); + pm_runtime_put_autosuspend(dev->parent); =20 mei_io_cb_free(cb); return rets; @@ -1683,9 +1683,9 @@ int mei_cl_read_start(struct mei_cl *cl, size_t lengt= h, const struct file *fp) =20 mei_cl_set_read_by_fp(cl, fp); =20 - rets =3D pm_runtime_get(dev->dev); + rets =3D pm_runtime_get(dev->parent); if (rets < 0 && rets !=3D -EINPROGRESS) { - pm_runtime_put_noidle(dev->dev); + pm_runtime_put_noidle(dev->parent); cl_err(dev, cl, "rpm: get failed %d\n", rets); goto nortpm; } @@ -1702,8 +1702,8 @@ int mei_cl_read_start(struct mei_cl *cl, size_t lengt= h, const struct file *fp) =20 out: cl_dbg(dev, cl, "rpm: autosuspend\n"); - pm_runtime_mark_last_busy(dev->dev); - pm_runtime_put_autosuspend(dev->dev); + pm_runtime_mark_last_busy(dev->parent); + pm_runtime_put_autosuspend(dev->parent); nortpm: if (rets) mei_io_cb_free(cb); @@ -1972,9 +1972,9 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl= _cb *cb, unsigned long time blocking =3D cb->blocking; data =3D buf->data; =20 - rets =3D pm_runtime_get(dev->dev); + rets =3D pm_runtime_get(dev->parent); if (rets < 0 && rets !=3D -EINPROGRESS) { - pm_runtime_put_noidle(dev->dev); + pm_runtime_put_noidle(dev->parent); cl_err(dev, cl, "rpm: get failed %zd\n", rets); goto free; } @@ -2092,8 +2092,8 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl= _cb *cb, unsigned long time rets =3D buf_len; err: cl_dbg(dev, cl, "rpm: autosuspend\n"); - pm_runtime_mark_last_busy(dev->dev); - pm_runtime_put_autosuspend(dev->dev); + pm_runtime_mark_last_busy(dev->parent); + pm_runtime_put_autosuspend(dev->parent); free: mei_io_cb_free(cb); =20 @@ -2119,8 +2119,8 @@ void mei_cl_complete(struct mei_cl *cl, struct mei_cl= _cb *cb) if (waitqueue_active(&cl->tx_wait)) { wake_up_interruptible(&cl->tx_wait); } else { - pm_runtime_mark_last_busy(dev->dev); - pm_request_autosuspend(dev->dev); + pm_runtime_mark_last_busy(dev->parent); + pm_request_autosuspend(dev->parent); } break; =20 @@ -2251,7 +2251,7 @@ int mei_cl_irq_dma_unmap(struct mei_cl *cl, struct me= i_cl_cb *cb, =20 static int mei_cl_dma_alloc(struct mei_cl *cl, u8 buf_id, size_t size) { - cl->dma.vaddr =3D dmam_alloc_coherent(cl->dev->dev, size, + cl->dma.vaddr =3D dmam_alloc_coherent(&cl->dev->dev, size, &cl->dma.daddr, GFP_KERNEL); if (!cl->dma.vaddr) return -ENOMEM; @@ -2265,7 +2265,7 @@ static int mei_cl_dma_alloc(struct mei_cl *cl, u8 buf= _id, size_t size) static void mei_cl_dma_free(struct mei_cl *cl) { cl->dma.buffer_id =3D 0; - dmam_free_coherent(cl->dev->dev, + dmam_free_coherent(&cl->dev->dev, cl->dma.size, cl->dma.vaddr, cl->dma.daddr); cl->dma.size =3D 0; cl->dma.vaddr =3D NULL; @@ -2321,16 +2321,16 @@ int mei_cl_dma_alloc_and_map(struct mei_cl *cl, con= st struct file *fp, return -EPROTO; } =20 - rets =3D pm_runtime_get(dev->dev); + rets =3D pm_runtime_get(dev->parent); if (rets < 0 && rets !=3D -EINPROGRESS) { - pm_runtime_put_noidle(dev->dev); + pm_runtime_put_noidle(dev->parent); cl_err(dev, cl, "rpm: get failed %d\n", rets); return rets; } =20 rets =3D mei_cl_dma_alloc(cl, buffer_id, size); if (rets) { - pm_runtime_put_noidle(dev->dev); + pm_runtime_put_noidle(dev->parent); return rets; } =20 @@ -2366,8 +2366,8 @@ int mei_cl_dma_alloc_and_map(struct mei_cl *cl, const= struct file *fp, mei_cl_dma_free(cl); =20 cl_dbg(dev, cl, "rpm: autosuspend\n"); - pm_runtime_mark_last_busy(dev->dev); - pm_runtime_put_autosuspend(dev->dev); + pm_runtime_mark_last_busy(dev->parent); + pm_runtime_put_autosuspend(dev->parent); =20 mei_io_cb_free(cb); return rets; @@ -2406,9 +2406,9 @@ int mei_cl_dma_unmap(struct mei_cl *cl, const struct = file *fp) if (!cl->dma_mapped) return -EPROTO; =20 - rets =3D pm_runtime_get(dev->dev); + rets =3D pm_runtime_get(dev->parent); if (rets < 0 && rets !=3D -EINPROGRESS) { - pm_runtime_put_noidle(dev->dev); + pm_runtime_put_noidle(dev->parent); cl_err(dev, cl, "rpm: get failed %d\n", rets); return rets; } @@ -2444,8 +2444,8 @@ int mei_cl_dma_unmap(struct mei_cl *cl, const struct = file *fp) mei_cl_dma_free(cl); out: cl_dbg(dev, cl, "rpm: autosuspend\n"); - pm_runtime_mark_last_busy(dev->dev); - pm_runtime_put_autosuspend(dev->dev); + pm_runtime_mark_last_busy(dev->parent); + pm_runtime_put_autosuspend(dev->parent); =20 mei_io_cb_free(cb); return rets; diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h index 01ed26a148c4..031114478bcb 100644 --- a/drivers/misc/mei/client.h +++ b/drivers/misc/mei/client.h @@ -275,12 +275,12 @@ int mei_cl_dma_unmap(struct mei_cl *cl, const struct = file *fp); #define MEI_CL_PRM(cl) (cl)->host_client_id, mei_cl_me_id(cl) =20 #define cl_dbg(dev, cl, format, arg...) \ - dev_dbg((dev)->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg) + dev_dbg(&(dev)->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg) =20 #define cl_warn(dev, cl, format, arg...) \ - dev_warn((dev)->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg) + dev_warn(&(dev)->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg) =20 #define cl_err(dev, cl, format, arg...) \ - dev_err((dev)->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg) + dev_err(&(dev)->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg) =20 #endif /* _MEI_CLIENT_H_ */ diff --git a/drivers/misc/mei/dma-ring.c b/drivers/misc/mei/dma-ring.c index 651e77ef82bd..6277c4a5b0fd 100644 --- a/drivers/misc/mei/dma-ring.c +++ b/drivers/misc/mei/dma-ring.c @@ -30,7 +30,7 @@ static int mei_dmam_dscr_alloc(struct mei_device *dev, if (dscr->vaddr) return 0; =20 - dscr->vaddr =3D dmam_alloc_coherent(dev->dev, dscr->size, &dscr->daddr, + dscr->vaddr =3D dmam_alloc_coherent(dev->parent, dscr->size, &dscr->daddr, GFP_KERNEL); if (!dscr->vaddr) return -ENOMEM; @@ -50,7 +50,7 @@ static void mei_dmam_dscr_free(struct mei_device *dev, if (!dscr->vaddr) return; =20 - dmam_free_coherent(dev->dev, dscr->size, dscr->vaddr, dscr->daddr); + dmam_free_coherent(dev->parent, dscr->size, dscr->vaddr, dscr->daddr); dscr->vaddr =3D NULL; } =20 @@ -177,7 +177,7 @@ void mei_dma_ring_read(struct mei_device *dev, unsigned= char *buf, u32 len) if (WARN_ON(!ctrl)) return; =20 - dev_dbg(dev->dev, "reading from dma %u bytes\n", len); + dev_dbg(&dev->dev, "reading from dma %u bytes\n", len); =20 if (!len) return; @@ -254,7 +254,7 @@ void mei_dma_ring_write(struct mei_device *dev, unsigne= d char *buf, u32 len) if (WARN_ON(!ctrl)) return; =20 - dev_dbg(dev->dev, "writing to dma %u bytes\n", len); + dev_dbg(&dev->dev, "writing to dma %u bytes\n", len); hbuf_depth =3D mei_dma_ring_hbuf_depth(dev); wr_idx =3D READ_ONCE(ctrl->hbuf_wr_idx) & (hbuf_depth - 1); slots =3D mei_data2slots(len); diff --git a/drivers/misc/mei/gsc-me.c b/drivers/misc/mei/gsc-me.c index 5a8c26c3df13..887f686b44dc 100644 --- a/drivers/misc/mei/gsc-me.c +++ b/drivers/misc/mei/gsc-me.c @@ -69,7 +69,7 @@ static int mei_gsc_probe(struct auxiliary_device *aux_dev, hw->mem_addr =3D devm_ioremap_resource(device, &adev->bar); if (IS_ERR(hw->mem_addr)) { ret =3D PTR_ERR(hw->mem_addr); - goto err; + goto deinit; } =20 hw->irq =3D adev->irq; @@ -93,7 +93,7 @@ static int mei_gsc_probe(struct auxiliary_device *aux_dev, if (IS_ERR(hw->polling_thread)) { ret =3D PTR_ERR(hw->polling_thread); dev_err(device, "unable to create kernel thread: %d\n", ret); - goto err; + goto deinit; } } else { ret =3D devm_request_threaded_irq(device, hw->irq, @@ -102,7 +102,7 @@ static int mei_gsc_probe(struct auxiliary_device *aux_d= ev, IRQF_ONESHOT, KBUILD_MODNAME, dev); if (ret) { dev_err(device, "irq register failed %d\n", ret); - goto err; + goto deinit; } } =20 @@ -131,7 +131,8 @@ static int mei_gsc_probe(struct auxiliary_device *aux_d= ev, mei_stop(dev); if (!mei_me_hw_use_polling(hw)) devm_free_irq(device, hw->irq, dev); - +deinit: + mei_device_deinit(dev); err: dev_err(device, "probe failed: %d\n", ret); dev_set_drvdata(device, NULL); @@ -159,6 +160,8 @@ static void mei_gsc_remove(struct auxiliary_device *aux= _dev) mei_disable_interrupts(dev); if (!mei_me_hw_use_polling(hw)) devm_free_irq(&aux_dev->dev, hw->irq, dev); + + mei_device_deinit(dev); } =20 static int __maybe_unused mei_gsc_pm_suspend(struct device *device) @@ -252,7 +255,7 @@ static int __maybe_unused mei_gsc_pm_runtime_resume(str= uct device *device) =20 irq_ret =3D mei_me_irq_thread_handler(1, dev); if (irq_ret !=3D IRQ_HANDLED) - dev_err(dev->dev, "thread handler fail %d\n", irq_ret); + dev_err(&dev->dev, "thread handler fail %d\n", irq_ret); =20 return 0; } diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c index 4fe9a2752d43..ccd9df5d1c7d 100644 --- a/drivers/misc/mei/hbm.c +++ b/drivers/misc/mei/hbm.c @@ -239,7 +239,7 @@ int mei_hbm_start_wait(struct mei_device *dev) =20 if (ret =3D=3D 0 && (dev->hbm_state <=3D MEI_HBM_STARTING)) { dev->hbm_state =3D MEI_HBM_IDLE; - dev_err(dev->dev, "waiting for mei start failed\n"); + dev_err(&dev->dev, "waiting for mei start failed\n"); return -ETIME; } return 0; @@ -271,8 +271,7 @@ int mei_hbm_start_req(struct mei_device *dev) dev->hbm_state =3D MEI_HBM_IDLE; ret =3D mei_hbm_write_message(dev, &mei_hdr, &req); if (ret) { - dev_err(dev->dev, "version message write failed: ret =3D %d\n", - ret); + dev_err(&dev->dev, "version message write failed: ret =3D %d\n", ret); return ret; } =20 @@ -312,8 +311,7 @@ static int mei_hbm_dma_setup_req(struct mei_device *dev) =20 ret =3D mei_hbm_write_message(dev, &mei_hdr, &req); if (ret) { - dev_err(dev->dev, "dma setup request write failed: ret =3D %d.\n", - ret); + dev_err(&dev->dev, "dma setup request write failed: ret =3D %d.\n", ret); return ret; } =20 @@ -351,8 +349,7 @@ static int mei_hbm_capabilities_req(struct mei_device *= dev) =20 ret =3D mei_hbm_write_message(dev, &mei_hdr, &req); if (ret) { - dev_err(dev->dev, - "capabilities request write failed: ret =3D %d.\n", ret); + dev_err(&dev->dev, "capabilities request write failed: ret =3D %d.\n", r= et); return ret; } =20 @@ -386,8 +383,7 @@ static int mei_hbm_enum_clients_req(struct mei_device *= dev) =20 ret =3D mei_hbm_write_message(dev, &mei_hdr, &req); if (ret) { - dev_err(dev->dev, "enumeration request write failed: ret =3D %d.\n", - ret); + dev_err(&dev->dev, "enumeration request write failed: ret =3D %d.\n", re= t); return ret; } dev->hbm_state =3D MEI_HBM_ENUM_CLIENTS; @@ -443,7 +439,7 @@ static int mei_hbm_add_cl_resp(struct mei_device *dev, = u8 addr, u8 status) struct hbm_add_client_response resp; int ret; =20 - dev_dbg(dev->dev, "adding client response\n"); + dev_dbg(&dev->dev, "adding client response\n"); =20 mei_hbm_hdr(&mei_hdr, sizeof(resp)); =20 @@ -454,8 +450,7 @@ static int mei_hbm_add_cl_resp(struct mei_device *dev, = u8 addr, u8 status) =20 ret =3D mei_hbm_write_message(dev, &mei_hdr, &resp); if (ret) - dev_err(dev->dev, "add client response write failed: ret =3D %d\n", - ret); + dev_err(&dev->dev, "add client response write failed: ret =3D %d\n", ret= ); return ret; } =20 @@ -752,7 +747,7 @@ static int mei_hbm_prop_req(struct mei_device *dev, uns= igned long start_idx) =20 ret =3D mei_hbm_write_message(dev, &mei_hdr, &req); if (ret) { - dev_err(dev->dev, "properties request write failed: ret =3D %d\n", + dev_err(&dev->dev, "properties request write failed: ret =3D %d\n", ret); return ret; } @@ -788,7 +783,7 @@ int mei_hbm_pg(struct mei_device *dev, u8 pg_cmd) =20 ret =3D mei_hbm_write_message(dev, &mei_hdr, &req); if (ret) - dev_err(dev->dev, "power gate command write failed.\n"); + dev_err(&dev->dev, "power gate command write failed.\n"); return ret; } EXPORT_SYMBOL_GPL(mei_hbm_pg); @@ -847,7 +842,7 @@ static int mei_hbm_add_single_tx_flow_ctrl_creds(struct= mei_device *dev, =20 me_cl =3D mei_me_cl_by_id(dev, fctrl->me_addr); if (!me_cl) { - dev_err(dev->dev, "no such me client %d\n", fctrl->me_addr); + dev_err(&dev->dev, "no such me client %d\n", fctrl->me_addr); return -ENOENT; } =20 @@ -857,7 +852,7 @@ static int mei_hbm_add_single_tx_flow_ctrl_creds(struct= mei_device *dev, } =20 me_cl->tx_flow_ctrl_creds++; - dev_dbg(dev->dev, "recv flow ctrl msg ME %d (single) creds =3D %d.\n", + dev_dbg(&dev->dev, "recv flow ctrl msg ME %d (single) creds =3D %d.\n", fctrl->me_addr, me_cl->tx_flow_ctrl_creds); =20 rets =3D 0; @@ -1085,7 +1080,7 @@ static int mei_hbm_pg_enter_res(struct mei_device *de= v) { if (mei_pg_state(dev) !=3D MEI_PG_OFF || dev->pg_event !=3D MEI_PG_EVENT_WAIT) { - dev_err(dev->dev, "hbm: pg entry response: state mismatch [%s, %d]\n", + dev_err(&dev->dev, "hbm: pg entry response: state mismatch [%s, %d]\n", mei_pg_state_str(mei_pg_state(dev)), dev->pg_event); return -EPROTO; } @@ -1103,7 +1098,7 @@ static int mei_hbm_pg_enter_res(struct mei_device *de= v) */ void mei_hbm_pg_resume(struct mei_device *dev) { - pm_request_resume(dev->dev); + pm_request_resume(dev->parent); } EXPORT_SYMBOL_GPL(mei_hbm_pg_resume); =20 @@ -1119,7 +1114,7 @@ static int mei_hbm_pg_exit_res(struct mei_device *dev) if (mei_pg_state(dev) !=3D MEI_PG_ON || (dev->pg_event !=3D MEI_PG_EVENT_WAIT && dev->pg_event !=3D MEI_PG_EVENT_IDLE)) { - dev_err(dev->dev, "hbm: pg exit response: state mismatch [%s, %d]\n", + dev_err(&dev->dev, "hbm: pg exit response: state mismatch [%s, %d]\n", mei_pg_state_str(mei_pg_state(dev)), dev->pg_event); return -EPROTO; } @@ -1276,19 +1271,19 @@ int mei_hbm_dispatch(struct mei_device *dev, struct= mei_msg_hdr *hdr) * hbm is put to idle during system reset */ if (dev->hbm_state =3D=3D MEI_HBM_IDLE) { - dev_dbg(dev->dev, "hbm: state is idle ignore spurious messages\n"); + dev_dbg(&dev->dev, "hbm: state is idle ignore spurious messages\n"); return 0; } =20 switch (mei_msg->hbm_cmd) { case HOST_START_RES_CMD: - dev_dbg(dev->dev, "hbm: start: response message received.\n"); + dev_dbg(&dev->dev, "hbm: start: response message received.\n"); =20 dev->init_clients_timer =3D 0; =20 version_res =3D (struct hbm_host_version_response *)mei_msg; =20 - dev_dbg(dev->dev, "HBM VERSION: DRIVER=3D%02d:%02d DEVICE=3D%02d:%02d\n", + dev_dbg(&dev->dev, "HBM VERSION: DRIVER=3D%02d:%02d DEVICE=3D%02d:%02d\n= ", HBM_MAJOR_VERSION, HBM_MINOR_VERSION, version_res->me_max_version.major_version, version_res->me_max_version.minor_version); @@ -1304,11 +1299,11 @@ int mei_hbm_dispatch(struct mei_device *dev, struct= mei_msg_hdr *hdr) } =20 if (!mei_hbm_version_is_supported(dev)) { - dev_warn(dev->dev, "hbm: start: version mismatch - stopping the driver.= \n"); + dev_warn(&dev->dev, "hbm: start: version mismatch - stopping the driver= .\n"); =20 dev->hbm_state =3D MEI_HBM_STOPPED; if (mei_hbm_stop_req(dev)) { - dev_err(dev->dev, "hbm: start: failed to send stop request\n"); + dev_err(&dev->dev, "hbm: start: failed to send stop request\n"); return -EIO; } break; @@ -1320,10 +1315,10 @@ int mei_hbm_dispatch(struct mei_device *dev, struct= mei_msg_hdr *hdr) dev->hbm_state !=3D MEI_HBM_STARTING) { if (dev->dev_state =3D=3D MEI_DEV_POWER_DOWN || dev->dev_state =3D=3D MEI_DEV_POWERING_DOWN) { - dev_dbg(dev->dev, "hbm: start: on shutdown, ignoring\n"); + dev_dbg(&dev->dev, "hbm: start: on shutdown, ignoring\n"); return 0; } - dev_err(dev->dev, "hbm: start: state mismatch, [%d, %d]\n", + dev_err(&dev->dev, "hbm: start: state mismatch, [%d, %d]\n", dev->dev_state, dev->hbm_state); return -EPROTO; } @@ -1337,7 +1332,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct m= ei_msg_hdr *hdr) =20 if (dev->hbm_f_dr_supported) { if (mei_dmam_ring_alloc(dev)) - dev_info(dev->dev, "running w/o dma ring\n"); + dev_info(&dev->dev, "running w/o dma ring\n"); if (mei_dma_ring_is_allocated(dev)) { if (mei_hbm_dma_setup_req(dev)) return -EIO; @@ -1357,7 +1352,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct m= ei_msg_hdr *hdr) break; =20 case MEI_HBM_CAPABILITIES_RES_CMD: - dev_dbg(dev->dev, "hbm: capabilities response: message received.\n"); + dev_dbg(&dev->dev, "hbm: capabilities response: message received.\n"); =20 dev->init_clients_timer =3D 0; =20 @@ -1365,10 +1360,10 @@ int mei_hbm_dispatch(struct mei_device *dev, struct= mei_msg_hdr *hdr) dev->hbm_state !=3D MEI_HBM_CAP_SETUP) { if (dev->dev_state =3D=3D MEI_DEV_POWER_DOWN || dev->dev_state =3D=3D MEI_DEV_POWERING_DOWN) { - dev_dbg(dev->dev, "hbm: capabilities response: on shutdown, ignoring\n= "); + dev_dbg(&dev->dev, "hbm: capabilities response: on shutdown, ignoring\= n"); return 0; } - dev_err(dev->dev, "hbm: capabilities response: state mismatch, [%d, %d]= \n", + dev_err(&dev->dev, "hbm: capabilities response: state mismatch, [%d, %d= ]\n", dev->dev_state, dev->hbm_state); return -EPROTO; } @@ -1384,7 +1379,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct m= ei_msg_hdr *hdr) =20 if (dev->hbm_f_dr_supported) { if (mei_dmam_ring_alloc(dev)) - dev_info(dev->dev, "running w/o dma ring\n"); + dev_info(&dev->dev, "running w/o dma ring\n"); if (mei_dma_ring_is_allocated(dev)) { if (mei_hbm_dma_setup_req(dev)) return -EIO; @@ -1400,7 +1395,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct m= ei_msg_hdr *hdr) break; =20 case MEI_HBM_DMA_SETUP_RES_CMD: - dev_dbg(dev->dev, "hbm: dma setup response: message received.\n"); + dev_dbg(&dev->dev, "hbm: dma setup response: message received.\n"); =20 dev->init_clients_timer =3D 0; =20 @@ -1408,10 +1403,10 @@ int mei_hbm_dispatch(struct mei_device *dev, struct= mei_msg_hdr *hdr) dev->hbm_state !=3D MEI_HBM_DR_SETUP) { if (dev->dev_state =3D=3D MEI_DEV_POWER_DOWN || dev->dev_state =3D=3D MEI_DEV_POWERING_DOWN) { - dev_dbg(dev->dev, "hbm: dma setup response: on shutdown, ignoring\n"); + dev_dbg(&dev->dev, "hbm: dma setup response: on shutdown, ignoring\n"); return 0; } - dev_err(dev->dev, "hbm: dma setup response: state mismatch, [%d, %d]\n", + dev_err(&dev->dev, "hbm: dma setup response: state mismatch, [%d, %d]\n= ", dev->dev_state, dev->hbm_state); return -EPROTO; } @@ -1422,9 +1417,9 @@ int mei_hbm_dispatch(struct mei_device *dev, struct m= ei_msg_hdr *hdr) u8 status =3D dma_setup_res->status; =20 if (status =3D=3D MEI_HBMS_NOT_ALLOWED) { - dev_dbg(dev->dev, "hbm: dma setup not allowed\n"); + dev_dbg(&dev->dev, "hbm: dma setup not allowed\n"); } else { - dev_info(dev->dev, "hbm: dma setup response: failure =3D %d %s\n", + dev_info(&dev->dev, "hbm: dma setup response: failure =3D %d %s\n", status, mei_hbm_status_str(status)); } @@ -1437,38 +1432,38 @@ int mei_hbm_dispatch(struct mei_device *dev, struct= mei_msg_hdr *hdr) break; =20 case CLIENT_CONNECT_RES_CMD: - dev_dbg(dev->dev, "hbm: client connect response: message received.\n"); + dev_dbg(&dev->dev, "hbm: client connect response: message received.\n"); mei_hbm_cl_res(dev, cl_cmd, MEI_FOP_CONNECT); break; =20 case CLIENT_DISCONNECT_RES_CMD: - dev_dbg(dev->dev, "hbm: client disconnect response: message received.\n"= ); + dev_dbg(&dev->dev, "hbm: client disconnect response: message received.\n= "); mei_hbm_cl_res(dev, cl_cmd, MEI_FOP_DISCONNECT); break; =20 case MEI_FLOW_CONTROL_CMD: - dev_dbg(dev->dev, "hbm: client flow control response: message received.\= n"); + dev_dbg(&dev->dev, "hbm: client flow control response: message received.= \n"); =20 fctrl =3D (struct hbm_flow_control *)mei_msg; mei_hbm_cl_tx_flow_ctrl_creds_res(dev, fctrl); break; =20 case MEI_PG_ISOLATION_ENTRY_RES_CMD: - dev_dbg(dev->dev, "hbm: power gate isolation entry response received\n"); + dev_dbg(&dev->dev, "hbm: power gate isolation entry response received\n"= ); ret =3D mei_hbm_pg_enter_res(dev); if (ret) return ret; break; =20 case MEI_PG_ISOLATION_EXIT_REQ_CMD: - dev_dbg(dev->dev, "hbm: power gate isolation exit request received\n"); + dev_dbg(&dev->dev, "hbm: power gate isolation exit request received\n"); ret =3D mei_hbm_pg_exit_res(dev); if (ret) return ret; break; =20 case HOST_CLIENT_PROPERTIES_RES_CMD: - dev_dbg(dev->dev, "hbm: properties response: message received.\n"); + dev_dbg(&dev->dev, "hbm: properties response: message received.\n"); =20 dev->init_clients_timer =3D 0; =20 @@ -1476,10 +1471,10 @@ int mei_hbm_dispatch(struct mei_device *dev, struct= mei_msg_hdr *hdr) dev->hbm_state !=3D MEI_HBM_CLIENT_PROPERTIES) { if (dev->dev_state =3D=3D MEI_DEV_POWER_DOWN || dev->dev_state =3D=3D MEI_DEV_POWERING_DOWN) { - dev_dbg(dev->dev, "hbm: properties response: on shutdown, ignoring\n"); + dev_dbg(&dev->dev, "hbm: properties response: on shutdown, ignoring\n"= ); return 0; } - dev_err(dev->dev, "hbm: properties response: state mismatch, [%d, %d]\n= ", + dev_err(&dev->dev, "hbm: properties response: state mismatch, [%d, %d]\= n", dev->dev_state, dev->hbm_state); return -EPROTO; } @@ -1487,10 +1482,10 @@ int mei_hbm_dispatch(struct mei_device *dev, struct= mei_msg_hdr *hdr) props_res =3D (struct hbm_props_response *)mei_msg; =20 if (props_res->status =3D=3D MEI_HBMS_CLIENT_NOT_FOUND) { - dev_dbg(dev->dev, "hbm: properties response: %d CLIENT_NOT_FOUND\n", + dev_dbg(&dev->dev, "hbm: properties response: %d CLIENT_NOT_FOUND\n", props_res->me_addr); } else if (props_res->status) { - dev_err(dev->dev, "hbm: properties response: wrong status =3D %d %s\n", + dev_err(&dev->dev, "hbm: properties response: wrong status =3D %d %s\n", props_res->status, mei_hbm_status_str(props_res->status)); return -EPROTO; @@ -1505,7 +1500,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct m= ei_msg_hdr *hdr) break; =20 case HOST_ENUM_RES_CMD: - dev_dbg(dev->dev, "hbm: enumeration response: message received\n"); + dev_dbg(&dev->dev, "hbm: enumeration response: message received\n"); =20 dev->init_clients_timer =3D 0; =20 @@ -1519,10 +1514,10 @@ int mei_hbm_dispatch(struct mei_device *dev, struct= mei_msg_hdr *hdr) dev->hbm_state !=3D MEI_HBM_ENUM_CLIENTS) { if (dev->dev_state =3D=3D MEI_DEV_POWER_DOWN || dev->dev_state =3D=3D MEI_DEV_POWERING_DOWN) { - dev_dbg(dev->dev, "hbm: enumeration response: on shutdown, ignoring\n"= ); + dev_dbg(&dev->dev, "hbm: enumeration response: on shutdown, ignoring\n= "); return 0; } - dev_err(dev->dev, "hbm: enumeration response: state mismatch, [%d, %d]\= n", + dev_err(&dev->dev, "hbm: enumeration response: state mismatch, [%d, %d]= \n", dev->dev_state, dev->hbm_state); return -EPROTO; } @@ -1536,77 +1531,77 @@ int mei_hbm_dispatch(struct mei_device *dev, struct= mei_msg_hdr *hdr) break; =20 case HOST_STOP_RES_CMD: - dev_dbg(dev->dev, "hbm: stop response: message received\n"); + dev_dbg(&dev->dev, "hbm: stop response: message received\n"); =20 dev->init_clients_timer =3D 0; =20 if (dev->hbm_state !=3D MEI_HBM_STOPPED) { - dev_err(dev->dev, "hbm: stop response: state mismatch, [%d, %d]\n", + dev_err(&dev->dev, "hbm: stop response: state mismatch, [%d, %d]\n", dev->dev_state, dev->hbm_state); return -EPROTO; } =20 mei_set_devstate(dev, MEI_DEV_POWER_DOWN); - dev_info(dev->dev, "hbm: stop response: resetting.\n"); + dev_info(&dev->dev, "hbm: stop response: resetting.\n"); /* force the reset */ return -EPROTO; =20 case CLIENT_DISCONNECT_REQ_CMD: - dev_dbg(dev->dev, "hbm: disconnect request: message received\n"); + dev_dbg(&dev->dev, "hbm: disconnect request: message received\n"); =20 disconnect_req =3D (struct hbm_client_connect_request *)mei_msg; mei_hbm_fw_disconnect_req(dev, disconnect_req); break; =20 case ME_STOP_REQ_CMD: - dev_dbg(dev->dev, "hbm: stop request: message received\n"); + dev_dbg(&dev->dev, "hbm: stop request: message received\n"); dev->hbm_state =3D MEI_HBM_STOPPED; if (mei_hbm_stop_req(dev)) { - dev_err(dev->dev, "hbm: stop request: failed to send stop request\n"); + dev_err(&dev->dev, "hbm: stop request: failed to send stop request\n"); return -EIO; } break; =20 case MEI_HBM_ADD_CLIENT_REQ_CMD: - dev_dbg(dev->dev, "hbm: add client request received\n"); + dev_dbg(&dev->dev, "hbm: add client request received\n"); /* * after the host receives the enum_resp * message clients may be added or removed */ if (dev->hbm_state <=3D MEI_HBM_ENUM_CLIENTS || dev->hbm_state >=3D MEI_HBM_STOPPED) { - dev_err(dev->dev, "hbm: add client: state mismatch, [%d, %d]\n", + dev_err(&dev->dev, "hbm: add client: state mismatch, [%d, %d]\n", dev->dev_state, dev->hbm_state); return -EPROTO; } add_cl_req =3D (struct hbm_add_client_request *)mei_msg; ret =3D mei_hbm_fw_add_cl_req(dev, add_cl_req); if (ret) { - dev_err(dev->dev, "hbm: add client: failed to send response %d\n", + dev_err(&dev->dev, "hbm: add client: failed to send response %d\n", ret); return -EIO; } - dev_dbg(dev->dev, "hbm: add client request processed\n"); + dev_dbg(&dev->dev, "hbm: add client request processed\n"); break; =20 case MEI_HBM_NOTIFY_RES_CMD: - dev_dbg(dev->dev, "hbm: notify response received\n"); + dev_dbg(&dev->dev, "hbm: notify response received\n"); mei_hbm_cl_res(dev, cl_cmd, notify_res_to_fop(cl_cmd)); break; =20 case MEI_HBM_NOTIFICATION_CMD: - dev_dbg(dev->dev, "hbm: notification\n"); + dev_dbg(&dev->dev, "hbm: notification\n"); mei_hbm_cl_notify(dev, cl_cmd); break; =20 case MEI_HBM_CLIENT_DMA_MAP_RES_CMD: - dev_dbg(dev->dev, "hbm: client dma map response: message received.\n"); + dev_dbg(&dev->dev, "hbm: client dma map response: message received.\n"); client_dma_res =3D (struct hbm_client_dma_response *)mei_msg; mei_hbm_cl_dma_map_res(dev, client_dma_res); break; =20 case MEI_HBM_CLIENT_DMA_UNMAP_RES_CMD: - dev_dbg(dev->dev, "hbm: client dma unmap response: message received.\n"); + dev_dbg(&dev->dev, "hbm: client dma unmap response: message received.\n"= ); client_dma_res =3D (struct hbm_client_dma_response *)mei_msg; mei_hbm_cl_dma_unmap_res(dev, client_dma_res); break; diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c index d11a0740b47c..efac906a0679 100644 --- a/drivers/misc/mei/hw-me.c +++ b/drivers/misc/mei/hw-me.c @@ -84,7 +84,7 @@ static inline u32 mei_me_mecsr_read(const struct mei_devi= ce *dev) u32 reg; =20 reg =3D mei_me_reg_read(to_me_hw(dev), ME_CSR_HA); - trace_mei_reg_read(dev->dev, "ME_CSR_HA", ME_CSR_HA, reg); + trace_mei_reg_read(&dev->dev, "ME_CSR_HA", ME_CSR_HA, reg); =20 return reg; } @@ -101,7 +101,7 @@ static inline u32 mei_hcsr_read(const struct mei_device= *dev) u32 reg; =20 reg =3D mei_me_reg_read(to_me_hw(dev), H_CSR); - trace_mei_reg_read(dev->dev, "H_CSR", H_CSR, reg); + trace_mei_reg_read(&dev->dev, "H_CSR", H_CSR, reg); =20 return reg; } @@ -114,7 +114,7 @@ static inline u32 mei_hcsr_read(const struct mei_device= *dev) */ static inline void mei_hcsr_write(struct mei_device *dev, u32 reg) { - trace_mei_reg_write(dev->dev, "H_CSR", H_CSR, reg); + trace_mei_reg_write(&dev->dev, "H_CSR", H_CSR, reg); mei_me_reg_write(to_me_hw(dev), H_CSR, reg); } =20 @@ -156,7 +156,7 @@ static inline u32 mei_me_d0i3c_read(const struct mei_de= vice *dev) u32 reg; =20 reg =3D mei_me_reg_read(to_me_hw(dev), H_D0I3C); - trace_mei_reg_read(dev->dev, "H_D0I3C", H_D0I3C, reg); + trace_mei_reg_read(&dev->dev, "H_D0I3C", H_D0I3C, reg); =20 return reg; } @@ -169,7 +169,7 @@ static inline u32 mei_me_d0i3c_read(const struct mei_de= vice *dev) */ static inline void mei_me_d0i3c_write(struct mei_device *dev, u32 reg) { - trace_mei_reg_write(dev->dev, "H_D0I3C", H_D0I3C, reg); + trace_mei_reg_write(&dev->dev, "H_D0I3C", H_D0I3C, reg); mei_me_reg_write(to_me_hw(dev), H_D0I3C, reg); } =20 @@ -189,7 +189,7 @@ static int mei_me_trc_status(struct mei_device *dev, u3= 2 *trc) return -EOPNOTSUPP; =20 *trc =3D mei_me_reg_read(hw, ME_TRC); - trace_mei_reg_read(dev->dev, "ME_TRC", ME_TRC, *trc); + trace_mei_reg_read(&dev->dev, "ME_TRC", ME_TRC, *trc); =20 return 0; } @@ -217,7 +217,7 @@ static int mei_me_fw_status(struct mei_device *dev, for (i =3D 0; i < fw_src->count && i < MEI_FW_STATUS_MAX; i++) { ret =3D hw->read_fws(dev, fw_src->status[i], &fw_status->status[i]); - trace_mei_pci_cfg_read(dev->dev, "PCI_CFG_HFS_X", + trace_mei_pci_cfg_read(&dev->dev, "PCI_CFG_HFS_X", fw_src->status[i], fw_status->status[i]); if (ret) @@ -251,7 +251,7 @@ static int mei_me_hw_config(struct mei_device *dev) =20 reg =3D 0; hw->read_fws(dev, PCI_CFG_HFS_1, ®); - trace_mei_pci_cfg_read(dev->dev, "PCI_CFG_HFS_1", PCI_CFG_HFS_1, reg); + trace_mei_pci_cfg_read(&dev->dev, "PCI_CFG_HFS_1", PCI_CFG_HFS_1, reg); hw->d0i3_supported =3D ((reg & PCI_CFG_HFS_1_D0I3_MSK) =3D=3D PCI_CFG_HFS_1_D0I3_MSK); =20 @@ -447,7 +447,7 @@ static void mei_gsc_pxp_check(struct mei_device *dev) return; =20 hw->read_fws(dev, PCI_CFG_HFS_5, &fwsts5); - trace_mei_pci_cfg_read(dev->dev, "PCI_CFG_HFS_5", PCI_CFG_HFS_5, fwsts5); + trace_mei_pci_cfg_read(&dev->dev, "PCI_CFG_HFS_5", PCI_CFG_HFS_5, fwsts5); =20 if ((fwsts5 & GSC_CFG_HFS_5_BOOT_TYPE_MSK) =3D=3D GSC_CFG_HFS_5_BOOT_TYPE= _PXP) { if (dev->gsc_reset_to_pxp =3D=3D MEI_DEV_RESET_TO_PXP_DEFAULT) @@ -460,10 +460,10 @@ static void mei_gsc_pxp_check(struct mei_device *dev) return; =20 if ((fwsts5 & GSC_CFG_HFS_5_BOOT_TYPE_MSK) =3D=3D GSC_CFG_HFS_5_BOOT_TYPE= _PXP) { - dev_dbg(dev->dev, "pxp mode is ready 0x%08x\n", fwsts5); + dev_dbg(&dev->dev, "pxp mode is ready 0x%08x\n", fwsts5); dev->pxp_mode =3D MEI_DEV_PXP_READY; } else { - dev_dbg(dev->dev, "pxp mode is not ready 0x%08x\n", fwsts5); + dev_dbg(&dev->dev, "pxp mode is not ready 0x%08x\n", fwsts5); } } =20 @@ -482,7 +482,7 @@ static int mei_me_hw_ready_wait(struct mei_device *dev) dev->timeouts.hw_ready); mutex_lock(&dev->device_lock); if (!dev->recvd_hw_ready) { - dev_err(dev->dev, "wait hw ready failed\n"); + dev_err(&dev->dev, "wait hw ready failed\n"); return -ETIME; } =20 @@ -516,12 +516,12 @@ static void mei_me_check_fw_reset(struct mei_device *= dev) fw_pm_event !=3D PCI_CFG_HFS_2_PM_CM_RESET_ERROR) goto end; } else { - dev_err(dev->dev, "failed to read firmware status: %d\n", ret); + dev_err(&dev->dev, "failed to read firmware status: %d\n", ret); } } =20 mei_fw_status2str(&dev->saved_fw_status, fw_sts_str, sizeof(fw_sts_str)); - dev_warn(dev->dev, "unexpected reset: fw_pm_event =3D 0x%x, dev_state =3D= %u fw status =3D %s\n", + dev_warn(&dev->dev, "unexpected reset: fw_pm_event =3D 0x%x, dev_state = =3D %u fw status =3D %s\n", fw_pm_event, dev->saved_dev_state, fw_sts_str); =20 end: @@ -544,7 +544,7 @@ static int mei_me_hw_start(struct mei_device *dev) mei_me_check_fw_reset(dev); if (ret) return ret; - dev_dbg(dev->dev, "hw is ready\n"); + dev_dbg(&dev->dev, "hw is ready\n"); =20 mei_me_host_set_ready(dev); return ret; @@ -644,14 +644,14 @@ static int mei_me_hbuf_write(struct mei_device *dev, return -EINVAL; =20 if (!data && data_len) { - dev_err(dev->dev, "wrong parameters null data with data_len =3D %zu\n", = data_len); + dev_err(&dev->dev, "wrong parameters null data with data_len =3D %zu\n",= data_len); return -EINVAL; } =20 - dev_dbg(dev->dev, MEI_HDR_FMT, MEI_HDR_PRM((struct mei_msg_hdr *)hdr)); + dev_dbg(&dev->dev, MEI_HDR_FMT, MEI_HDR_PRM((struct mei_msg_hdr *)hdr)); =20 empty_slots =3D mei_hbuf_empty_slots(dev); - dev_dbg(dev->dev, "empty slots =3D %d.\n", empty_slots); + dev_dbg(&dev->dev, "empty slots =3D %d.\n", empty_slots); =20 if (empty_slots < 0) return -EOVERFLOW; @@ -706,7 +706,7 @@ static int mei_me_count_full_read_slots(struct mei_devi= ce *dev) if (filled_slots > buffer_depth) return -EOVERFLOW; =20 - dev_dbg(dev->dev, "filled_slots =3D%08x\n", filled_slots); + dev_dbg(&dev->dev, "filled_slots =3D%08x\n", filled_slots); return (int)filled_slots; } =20 @@ -748,11 +748,11 @@ static void mei_me_pg_set(struct mei_device *dev) u32 reg; =20 reg =3D mei_me_reg_read(hw, H_HPG_CSR); - trace_mei_reg_read(dev->dev, "H_HPG_CSR", H_HPG_CSR, reg); + trace_mei_reg_read(&dev->dev, "H_HPG_CSR", H_HPG_CSR, reg); =20 reg |=3D H_HPG_CSR_PGI; =20 - trace_mei_reg_write(dev->dev, "H_HPG_CSR", H_HPG_CSR, reg); + trace_mei_reg_write(&dev->dev, "H_HPG_CSR", H_HPG_CSR, reg); mei_me_reg_write(hw, H_HPG_CSR, reg); } =20 @@ -767,13 +767,13 @@ static void mei_me_pg_unset(struct mei_device *dev) u32 reg; =20 reg =3D mei_me_reg_read(hw, H_HPG_CSR); - trace_mei_reg_read(dev->dev, "H_HPG_CSR", H_HPG_CSR, reg); + trace_mei_reg_read(&dev->dev, "H_HPG_CSR", H_HPG_CSR, reg); =20 WARN(!(reg & H_HPG_CSR_PGI), "PGI is not set\n"); =20 reg |=3D H_HPG_CSR_PGIHEXR; =20 - trace_mei_reg_write(dev->dev, "H_HPG_CSR", H_HPG_CSR, reg); + trace_mei_reg_write(&dev->dev, "H_HPG_CSR", H_HPG_CSR, reg); mei_me_reg_write(hw, H_HPG_CSR, reg); } =20 @@ -905,7 +905,7 @@ static bool mei_me_pg_is_enabled(struct mei_device *dev) return true; =20 notsupported: - dev_dbg(dev->dev, "pg: not supported: d0i3 =3D %d HGP =3D %d hbm version = %d.%d ?=3D %d.%d\n", + dev_dbg(&dev->dev, "pg: not supported: d0i3 =3D %d HGP =3D %d hbm version= %d.%d ?=3D %d.%d\n", hw->d0i3_supported, !!(reg & ME_PGIC_HRA), dev->version.major_version, @@ -974,7 +974,7 @@ static int mei_me_d0i3_enter_sync(struct mei_device *de= v) reg =3D mei_me_d0i3c_read(dev); if (reg & H_D0I3C_I3) { /* we are in d0i3, nothing to do */ - dev_dbg(dev->dev, "d0i3 set not needed\n"); + dev_dbg(&dev->dev, "d0i3 set not needed\n"); ret =3D 0; goto on; } @@ -1003,7 +1003,7 @@ static int mei_me_d0i3_enter_sync(struct mei_device *= dev) =20 reg =3D mei_me_d0i3_set(dev, true); if (!(reg & H_D0I3C_CIP)) { - dev_dbg(dev->dev, "d0i3 enter wait not needed\n"); + dev_dbg(&dev->dev, "d0i3 enter wait not needed\n"); ret =3D 0; goto on; } @@ -1027,7 +1027,7 @@ static int mei_me_d0i3_enter_sync(struct mei_device *= dev) hw->pg_state =3D MEI_PG_ON; out: dev->pg_event =3D MEI_PG_EVENT_IDLE; - dev_dbg(dev->dev, "d0i3 enter ret =3D %d\n", ret); + dev_dbg(&dev->dev, "d0i3 enter ret =3D %d\n", ret); return ret; } =20 @@ -1049,7 +1049,7 @@ static int mei_me_d0i3_enter(struct mei_device *dev) reg =3D mei_me_d0i3c_read(dev); if (reg & H_D0I3C_I3) { /* we are in d0i3, nothing to do */ - dev_dbg(dev->dev, "already d0i3 : set not needed\n"); + dev_dbg(&dev->dev, "already d0i3 : set not needed\n"); goto on; } =20 @@ -1057,7 +1057,7 @@ static int mei_me_d0i3_enter(struct mei_device *dev) on: hw->pg_state =3D MEI_PG_ON; dev->pg_event =3D MEI_PG_EVENT_IDLE; - dev_dbg(dev->dev, "d0i3 enter\n"); + dev_dbg(&dev->dev, "d0i3 enter\n"); return 0; } =20 @@ -1079,14 +1079,14 @@ static int mei_me_d0i3_exit_sync(struct mei_device = *dev) reg =3D mei_me_d0i3c_read(dev); if (!(reg & H_D0I3C_I3)) { /* we are not in d0i3, nothing to do */ - dev_dbg(dev->dev, "d0i3 exit not needed\n"); + dev_dbg(&dev->dev, "d0i3 exit not needed\n"); ret =3D 0; goto off; } =20 reg =3D mei_me_d0i3_unset(dev); if (!(reg & H_D0I3C_CIP)) { - dev_dbg(dev->dev, "d0i3 exit wait not needed\n"); + dev_dbg(&dev->dev, "d0i3 exit wait not needed\n"); ret =3D 0; goto off; } @@ -1111,7 +1111,7 @@ static int mei_me_d0i3_exit_sync(struct mei_device *d= ev) out: dev->pg_event =3D MEI_PG_EVENT_IDLE; =20 - dev_dbg(dev->dev, "d0i3 exit ret =3D %d\n", ret); + dev_dbg(&dev->dev, "d0i3 exit ret =3D %d\n", ret); return ret; } =20 @@ -1154,7 +1154,7 @@ static void mei_me_d0i3_intr(struct mei_device *dev, = u32 intr_source) * force H_RDY because it could be * wiped off during PG */ - dev_dbg(dev->dev, "d0i3 set host ready\n"); + dev_dbg(&dev->dev, "d0i3 set host ready\n"); mei_me_host_set_ready(dev); } } else { @@ -1170,7 +1170,7 @@ static void mei_me_d0i3_intr(struct mei_device *dev, = u32 intr_source) * we got here because of HW initiated exit from D0i3. * Start runtime pm resume sequence to exit low power state. */ - dev_dbg(dev->dev, "d0i3 want resume\n"); + dev_dbg(&dev->dev, "d0i3 want resume\n"); mei_hbm_pg_resume(dev); } } @@ -1250,7 +1250,7 @@ static int mei_me_hw_reset(struct mei_device *dev, bo= ol intr_enable) } } =20 - pm_runtime_set_active(dev->dev); + pm_runtime_set_active(dev->parent); =20 hcsr =3D mei_hcsr_read(dev); /* H_RST may be found lit before reset is started, @@ -1259,7 +1259,7 @@ static int mei_me_hw_reset(struct mei_device *dev, bo= ol intr_enable) * we need to clean H_RST bit to start a successful reset sequence. */ if ((hcsr & H_RST) =3D=3D H_RST) { - dev_warn(dev->dev, "H_RST is set =3D 0x%08X", hcsr); + dev_warn(&dev->dev, "H_RST is set =3D 0x%08X", hcsr); hcsr &=3D ~H_RST; mei_hcsr_set(dev, hcsr); hcsr =3D mei_hcsr_read(dev); @@ -1280,10 +1280,10 @@ static int mei_me_hw_reset(struct mei_device *dev, = bool intr_enable) hcsr =3D mei_hcsr_read(dev); =20 if ((hcsr & H_RST) =3D=3D 0) - dev_warn(dev->dev, "H_RST is not set =3D 0x%08X", hcsr); + dev_warn(&dev->dev, "H_RST is not set =3D 0x%08X", hcsr); =20 if ((hcsr & H_RDY) =3D=3D H_RDY) - dev_warn(dev->dev, "H_RDY is not cleared 0x%08X", hcsr); + dev_warn(&dev->dev, "H_RDY is not cleared 0x%08X", hcsr); =20 if (!intr_enable) { mei_me_hw_reset_release(dev); @@ -1313,7 +1313,7 @@ irqreturn_t mei_me_irq_quick_handler(int irq, void *d= ev_id) if (!me_intr_src(hcsr)) return IRQ_NONE; =20 - dev_dbg(dev->dev, "interrupt source 0x%08X\n", me_intr_src(hcsr)); + dev_dbg(&dev->dev, "interrupt source 0x%08X\n", me_intr_src(hcsr)); =20 /* disable interrupts on device */ me_intr_disable(dev, hcsr); @@ -1339,7 +1339,7 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *= dev_id) u32 hcsr; int rets =3D 0; =20 - dev_dbg(dev->dev, "function called after ISR to handle the interrupt proc= essing.\n"); + dev_dbg(&dev->dev, "function called after ISR to handle the interrupt pro= cessing.\n"); /* initialize our complete list */ mutex_lock(&dev->device_lock); =20 @@ -1351,10 +1351,10 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void= *dev_id) /* check if ME wants a reset */ if (!mei_hw_is_ready(dev) && dev->dev_state !=3D MEI_DEV_RESETTING) { if (kind_is_gsc(dev) || kind_is_gscfi(dev)) { - dev_dbg(dev->dev, "FW not ready: resetting: dev_state =3D %d\n", + dev_dbg(&dev->dev, "FW not ready: resetting: dev_state =3D %d\n", dev->dev_state); } else { - dev_warn(dev->dev, "FW not ready: resetting: dev_state =3D %d\n", + dev_warn(&dev->dev, "FW not ready: resetting: dev_state =3D %d\n", dev->dev_state); } if (dev->dev_state =3D=3D MEI_DEV_POWERING_DOWN || @@ -1373,18 +1373,18 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void= *dev_id) /* check if we need to start the dev */ if (!mei_host_is_ready(dev)) { if (mei_hw_is_ready(dev)) { - dev_dbg(dev->dev, "we need to start the dev.\n"); + dev_dbg(&dev->dev, "we need to start the dev.\n"); dev->recvd_hw_ready =3D true; wake_up(&dev->wait_hw_ready); } else { - dev_dbg(dev->dev, "Spurious Interrupt\n"); + dev_dbg(&dev->dev, "Spurious Interrupt\n"); } goto end; } /* check slots available for reading */ slots =3D mei_count_full_read_slots(dev); while (slots > 0) { - dev_dbg(dev->dev, "slots to read =3D %08x\n", slots); + dev_dbg(&dev->dev, "slots to read =3D %08x\n", slots); rets =3D mei_irq_read_handler(dev, &cmpl_list, &slots); /* There is a race between ME write and interrupt delivery: * Not all data is always available immediately after the @@ -1394,7 +1394,7 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *= dev_id) break; =20 if (rets) { - dev_err(dev->dev, "mei_irq_read_handler ret =3D %d, state =3D %d.\n", + dev_err(&dev->dev, "mei_irq_read_handler ret =3D %d, state =3D %d.\n", rets, dev->dev_state); if (dev->dev_state !=3D MEI_DEV_RESETTING && dev->dev_state !=3D MEI_DEV_DISABLED && @@ -1421,7 +1421,7 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *= dev_id) mei_irq_compl_handler(dev, &cmpl_list); =20 end: - dev_dbg(dev->dev, "interrupt thread end ret =3D %d\n", rets); + dev_dbg(&dev->dev, "interrupt thread end ret =3D %d\n", rets); mei_me_intr_enable(dev); mutex_unlock(&dev->device_lock); return IRQ_HANDLED; @@ -1453,7 +1453,7 @@ int mei_me_polling_thread(void *_dev) irqreturn_t irq_ret; long polling_timeout =3D MEI_POLLING_TIMEOUT_ACTIVE; =20 - dev_dbg(dev->dev, "kernel thread is running\n"); + dev_dbg(&dev->dev, "kernel thread is running\n"); while (!kthread_should_stop()) { struct mei_me_hw *hw =3D to_me_hw(dev); u32 hcsr; @@ -1470,7 +1470,7 @@ int mei_me_polling_thread(void *_dev) polling_timeout =3D MEI_POLLING_TIMEOUT_ACTIVE; irq_ret =3D mei_me_irq_thread_handler(1, dev); if (irq_ret !=3D IRQ_HANDLED) - dev_err(dev->dev, "irq_ret %d\n", irq_ret); + dev_err(&dev->dev, "irq_ret %d\n", irq_ret); } else { /* * Increase timeout by MEI_POLLING_TIMEOUT_ACTIVE @@ -1804,7 +1804,7 @@ struct mei_device *mei_me_dev_init(struct device *par= ent, struct mei_me_hw *hw; int i; =20 - dev =3D devm_kzalloc(parent, sizeof(*dev) + sizeof(*hw), GFP_KERNEL); + dev =3D mei_device_init(parent, sizeof(*hw), slow_fw, &mei_me_hw_ops); if (!dev) return NULL; =20 @@ -1813,7 +1813,6 @@ struct mei_device *mei_me_dev_init(struct device *par= ent, for (i =3D 0; i < DMA_DSCR_NUM; i++) dev->dr_dscr[i].size =3D cfg->dma_size[i]; =20 - mei_device_init(dev, parent, slow_fw, &mei_me_hw_ops); hw->cfg =3D cfg; =20 dev->fw_f_fw_ver_supported =3D cfg->fw_ver_supported; diff --git a/drivers/misc/mei/hw-txe.c b/drivers/misc/mei/hw-txe.c index e9476f9ae25d..00c473aa936c 100644 --- a/drivers/misc/mei/hw-txe.c +++ b/drivers/misc/mei/hw-txe.c @@ -160,7 +160,7 @@ static bool mei_txe_aliveness_set(struct mei_device *de= v, u32 req) struct mei_txe_hw *hw =3D to_txe_hw(dev); bool do_req =3D hw->aliveness !=3D req; =20 - dev_dbg(dev->dev, "Aliveness current=3D%d request=3D%d\n", + dev_dbg(&dev->dev, "Aliveness current=3D%d request=3D%d\n", hw->aliveness, req); if (do_req) { dev->pg_event =3D MEI_PG_EVENT_WAIT; @@ -227,7 +227,7 @@ static int mei_txe_aliveness_poll(struct mei_device *de= v, u32 expected) hw->aliveness =3D mei_txe_aliveness_get(dev); if (hw->aliveness =3D=3D expected) { dev->pg_event =3D MEI_PG_EVENT_IDLE; - dev_dbg(dev->dev, "aliveness settled after %lld usecs\n", + dev_dbg(&dev->dev, "aliveness settled after %lld usecs\n", ktime_to_us(ktime_sub(ktime_get(), start))); return 0; } @@ -235,7 +235,7 @@ static int mei_txe_aliveness_poll(struct mei_device *de= v, u32 expected) } while (ktime_before(ktime_get(), stop)); =20 dev->pg_event =3D MEI_PG_EVENT_IDLE; - dev_err(dev->dev, "aliveness timed out\n"); + dev_err(&dev->dev, "aliveness timed out\n"); return -ETIME; } =20 @@ -270,10 +270,10 @@ static int mei_txe_aliveness_wait(struct mei_device *= dev, u32 expected) ret =3D hw->aliveness =3D=3D expected ? 0 : -ETIME; =20 if (ret) - dev_warn(dev->dev, "aliveness timed out =3D %ld aliveness =3D %d event = =3D %d\n", + dev_warn(&dev->dev, "aliveness timed out =3D %ld aliveness =3D %d event = =3D %d\n", err, hw->aliveness, dev->pg_event); else - dev_dbg(dev->dev, "aliveness settled after =3D %d msec aliveness =3D %d = event =3D %d\n", + dev_dbg(&dev->dev, "aliveness settled after =3D %d msec aliveness =3D %d= event =3D %d\n", jiffies_to_msecs(timeout - err), hw->aliveness, dev->pg_event); =20 @@ -438,7 +438,7 @@ static void mei_txe_intr_enable(struct mei_device *dev) */ static void mei_txe_synchronize_irq(struct mei_device *dev) { - struct pci_dev *pdev =3D to_pci_dev(dev->dev); + struct pci_dev *pdev =3D to_pci_dev(dev->parent); =20 synchronize_irq(pdev->irq); } @@ -464,7 +464,7 @@ static bool mei_txe_pending_interrupts(struct mei_devic= e *dev) TXE_INTR_OUT_DB)); =20 if (ret) { - dev_dbg(dev->dev, + dev_dbg(&dev->dev, "Pending Interrupts InReady=3D%01d Readiness=3D%01d, Aliveness=3D%01d, = OutDoor=3D%01d\n", !!(hw->intr_cause & TXE_INTR_IN_READY), !!(hw->intr_cause & TXE_INTR_READINESS), @@ -612,7 +612,7 @@ static int mei_txe_readiness_wait(struct mei_device *de= v) msecs_to_jiffies(SEC_RESET_WAIT_TIMEOUT)); mutex_lock(&dev->device_lock); if (!dev->recvd_hw_ready) { - dev_err(dev->dev, "wait for readiness failed\n"); + dev_err(&dev->dev, "wait for readiness failed\n"); return -ETIME; } =20 @@ -638,7 +638,7 @@ static int mei_txe_fw_status(struct mei_device *dev, struct mei_fw_status *fw_status) { const struct mei_fw_status *fw_src =3D &mei_txe_fw_sts; - struct pci_dev *pdev =3D to_pci_dev(dev->dev); + struct pci_dev *pdev =3D to_pci_dev(dev->parent); int ret; int i; =20 @@ -649,7 +649,7 @@ static int mei_txe_fw_status(struct mei_device *dev, for (i =3D 0; i < fw_src->count && i < MEI_FW_STATUS_MAX; i++) { ret =3D pci_read_config_dword(pdev, fw_src->status[i], &fw_status->status[i]); - trace_mei_pci_cfg_read(dev->dev, "PCI_CFG_HSF_X", + trace_mei_pci_cfg_read(&dev->dev, "PCI_CFG_HSF_X", fw_src->status[i], fw_status->status[i]); if (ret) @@ -677,7 +677,7 @@ static int mei_txe_hw_config(struct mei_device *dev) hw->aliveness =3D mei_txe_aliveness_get(dev); hw->readiness =3D mei_txe_readiness_get(dev); =20 - dev_dbg(dev->dev, "aliveness_resp =3D 0x%08x, readiness =3D 0x%08x.\n", + dev_dbg(&dev->dev, "aliveness_resp =3D 0x%08x, readiness =3D 0x%08x.\n", hw->aliveness, hw->readiness); =20 return 0; @@ -708,7 +708,7 @@ static int mei_txe_write(struct mei_device *dev, if (WARN_ON(!hdr || !data || hdr_len & 0x3)) return -EINVAL; =20 - dev_dbg(dev->dev, MEI_HDR_FMT, MEI_HDR_PRM((struct mei_msg_hdr *)hdr)); + dev_dbg(&dev->dev, MEI_HDR_FMT, MEI_HDR_PRM((struct mei_msg_hdr *)hdr)); =20 dw_cnt =3D mei_data2slots(hdr_len + data_len); if (dw_cnt > slots) @@ -724,7 +724,7 @@ static int mei_txe_write(struct mei_device *dev, char fw_sts_str[MEI_FW_STATUS_STR_SZ]; =20 mei_fw_status_str(dev, fw_sts_str, MEI_FW_STATUS_STR_SZ); - dev_err(dev->dev, "Input is not ready %s\n", fw_sts_str); + dev_err(&dev->dev, "Input is not ready %s\n", fw_sts_str); return -EAGAIN; } =20 @@ -828,13 +828,13 @@ static int mei_txe_read(struct mei_device *dev, reg_buf =3D (u32 *)buf; rem =3D len & 0x3; =20 - dev_dbg(dev->dev, "buffer-length =3D %lu buf[0]0x%08X\n", + dev_dbg(&dev->dev, "buffer-length =3D %lu buf[0]0x%08X\n", len, mei_txe_out_data_read(dev, 0)); =20 for (i =3D 0; i < len / MEI_SLOT_SIZE; i++) { /* skip header: index starts from 1 */ reg =3D mei_txe_out_data_read(dev, i + 1); - dev_dbg(dev->dev, "buf[%d] =3D 0x%08X\n", i, reg); + dev_dbg(&dev->dev, "buf[%d] =3D 0x%08X\n", i, reg); *reg_buf++ =3D reg; } =20 @@ -879,7 +879,7 @@ static int mei_txe_hw_reset(struct mei_device *dev, boo= l intr_enable) */ if (aliveness_req !=3D hw->aliveness) if (mei_txe_aliveness_poll(dev, aliveness_req) < 0) { - dev_err(dev->dev, "wait for aliveness settle failed ... bailing out\n"); + dev_err(&dev->dev, "wait for aliveness settle failed ... bailing out\n"= ); return -EIO; } =20 @@ -889,7 +889,7 @@ static int mei_txe_hw_reset(struct mei_device *dev, boo= l intr_enable) if (aliveness_req) { mei_txe_aliveness_set(dev, 0); if (mei_txe_aliveness_poll(dev, 0) < 0) { - dev_err(dev->dev, "wait for aliveness failed ... bailing out\n"); + dev_err(&dev->dev, "wait for aliveness failed ... bailing out\n"); return -EIO; } } @@ -921,7 +921,7 @@ static int mei_txe_hw_start(struct mei_device *dev) =20 ret =3D mei_txe_readiness_wait(dev); if (ret < 0) { - dev_err(dev->dev, "waiting for readiness failed\n"); + dev_err(&dev->dev, "waiting for readiness failed\n"); return ret; } =20 @@ -937,11 +937,11 @@ static int mei_txe_hw_start(struct mei_device *dev) =20 ret =3D mei_txe_aliveness_set_sync(dev, 1); if (ret < 0) { - dev_err(dev->dev, "wait for aliveness failed ... bailing out\n"); + dev_err(&dev->dev, "wait for aliveness failed ... bailing out\n"); return ret; } =20 - pm_runtime_set_active(dev->dev); + pm_runtime_set_active(dev->parent); =20 /* enable input ready interrupts: * SEC_IPC_HOST_INT_MASK.IPC_INPUT_READY_INT_MASK @@ -1049,7 +1049,7 @@ irqreturn_t mei_txe_irq_thread_handler(int irq, void = *dev_id) s32 slots; int rets =3D 0; =20 - dev_dbg(dev->dev, "irq thread: Interrupt Registers HHISR|HISR|SEC=3D%02X|= %04X|%02X\n", + dev_dbg(&dev->dev, "irq thread: Interrupt Registers HHISR|HISR|SEC=3D%02X= |%04X|%02X\n", mei_txe_br_reg_read(hw, HHISR_REG), mei_txe_br_reg_read(hw, HISR_REG), mei_txe_sec_reg_read_silent(hw, SEC_IPC_HOST_INT_STATUS_REG)); @@ -1059,7 +1059,7 @@ irqreturn_t mei_txe_irq_thread_handler(int irq, void = *dev_id) mutex_lock(&dev->device_lock); INIT_LIST_HEAD(&cmpl_list); =20 - if (pci_dev_msi_enabled(to_pci_dev(dev->dev))) + if (pci_dev_msi_enabled(to_pci_dev(dev->parent))) mei_txe_check_and_ack_intrs(dev, true); =20 /* show irq events */ @@ -1073,17 +1073,17 @@ irqreturn_t mei_txe_irq_thread_handler(int irq, voi= d *dev_id) * or TXE driver resetting the HECI interface. */ if (test_and_clear_bit(TXE_INTR_READINESS_BIT, &hw->intr_cause)) { - dev_dbg(dev->dev, "Readiness Interrupt was received...\n"); + dev_dbg(&dev->dev, "Readiness Interrupt was received...\n"); =20 /* Check if SeC is going through reset */ if (mei_txe_readiness_is_sec_rdy(hw->readiness)) { - dev_dbg(dev->dev, "we need to start the dev.\n"); + dev_dbg(&dev->dev, "we need to start the dev.\n"); dev->recvd_hw_ready =3D true; } else { dev->recvd_hw_ready =3D false; if (dev->dev_state !=3D MEI_DEV_RESETTING) { =20 - dev_warn(dev->dev, "FW not ready: resetting.\n"); + dev_warn(&dev->dev, "FW not ready: resetting.\n"); schedule_work(&dev->reset_work); goto end; =20 @@ -1100,7 +1100,7 @@ irqreturn_t mei_txe_irq_thread_handler(int irq, void = *dev_id) =20 if (test_and_clear_bit(TXE_INTR_ALIVENESS_BIT, &hw->intr_cause)) { /* Clear the interrupt cause */ - dev_dbg(dev->dev, + dev_dbg(&dev->dev, "Aliveness Interrupt: Status: %d\n", hw->aliveness); dev->pg_event =3D MEI_PG_EVENT_RECEIVED; if (waitqueue_active(&hw->wait_aliveness_resp)) @@ -1118,7 +1118,7 @@ irqreturn_t mei_txe_irq_thread_handler(int irq, void = *dev_id) if (rets && (dev->dev_state !=3D MEI_DEV_RESETTING && dev->dev_state !=3D MEI_DEV_POWER_DOWN)) { - dev_err(dev->dev, + dev_err(&dev->dev, "mei_irq_read_handler ret =3D %d.\n", rets); =20 schedule_work(&dev->reset_work); @@ -1136,7 +1136,7 @@ irqreturn_t mei_txe_irq_thread_handler(int irq, void = *dev_id) dev->hbuf_is_ready =3D mei_hbuf_is_ready(dev); rets =3D mei_irq_write_handler(dev, &cmpl_list); if (rets && rets !=3D -EMSGSIZE) - dev_err(dev->dev, "mei_irq_write_handler ret =3D %d.\n", + dev_err(&dev->dev, "mei_irq_write_handler ret =3D %d.\n", rets); dev->hbuf_is_ready =3D mei_hbuf_is_ready(dev); } @@ -1144,7 +1144,7 @@ irqreturn_t mei_txe_irq_thread_handler(int irq, void = *dev_id) mei_irq_compl_handler(dev, &cmpl_list); =20 end: - dev_dbg(dev->dev, "interrupt thread end ret =3D %d\n", rets); + dev_dbg(&dev->dev, "interrupt thread end ret =3D %d\n", rets); =20 mutex_unlock(&dev->device_lock); =20 @@ -1197,12 +1197,10 @@ struct mei_device *mei_txe_dev_init(struct pci_dev = *pdev) struct mei_device *dev; struct mei_txe_hw *hw; =20 - dev =3D devm_kzalloc(&pdev->dev, sizeof(*dev) + sizeof(*hw), GFP_KERNEL); + dev =3D mei_device_init(&pdev->dev, sizeof(*hw), false, &mei_txe_hw_ops); if (!dev) return NULL; =20 - mei_device_init(dev, &pdev->dev, false, &mei_txe_hw_ops); - hw =3D to_txe_hw(dev); =20 init_waitqueue_head(&hw->wait_aliveness_resp); diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c index 8ef2b1df8ac7..1b05a25beece 100644 --- a/drivers/misc/mei/init.c +++ b/drivers/misc/mei/init.c @@ -96,7 +96,7 @@ static void mei_save_fw_status(struct mei_device *dev) =20 ret =3D mei_fw_status(dev, &fw_status); if (ret) { - dev_err(dev->dev, "failed to read firmware status: %d\n", ret); + dev_err(&dev->dev, "failed to read firmware status: %d\n", ret); return; } =20 @@ -126,11 +126,11 @@ int mei_reset(struct mei_device *dev) =20 mei_fw_status_str(dev, fw_sts_str, MEI_FW_STATUS_STR_SZ); if (kind_is_gsc(dev) || kind_is_gscfi(dev)) { - dev_dbg(dev->dev, "unexpected reset: dev_state =3D %s fw status =3D %s\= n", + dev_dbg(&dev->dev, "unexpected reset: dev_state =3D %s fw status =3D %s= \n", mei_dev_state_str(state), fw_sts_str); mei_save_fw_status(dev); } else { - dev_warn(dev->dev, "unexpected reset: dev_state =3D %s fw status =3D %s= \n", + dev_warn(&dev->dev, "unexpected reset: dev_state =3D %s fw status =3D %= s\n", mei_dev_state_str(state), fw_sts_str); } } @@ -150,7 +150,7 @@ int mei_reset(struct mei_device *dev) =20 dev->reset_count++; if (dev->reset_count > MEI_MAX_CONSEC_RESET) { - dev_err(dev->dev, "reset: reached maximal consecutive resets: disabling = the device\n"); + dev_err(&dev->dev, "reset: reached maximal consecutive resets: disabling= the device\n"); mei_set_devstate(dev, MEI_DEV_DISABLED); return -ENODEV; } @@ -170,12 +170,12 @@ int mei_reset(struct mei_device *dev) memset(dev->rd_msg_hdr, 0, sizeof(dev->rd_msg_hdr)); =20 if (ret) { - dev_err(dev->dev, "hw_reset failed ret =3D %d\n", ret); + dev_err(&dev->dev, "hw_reset failed ret =3D %d\n", ret); return ret; } =20 if (state =3D=3D MEI_DEV_POWER_DOWN) { - dev_dbg(dev->dev, "powering down: end of reset\n"); + dev_dbg(&dev->dev, "powering down: end of reset\n"); mei_set_devstate(dev, MEI_DEV_DISABLED); return 0; } @@ -185,21 +185,21 @@ int mei_reset(struct mei_device *dev) char fw_sts_str[MEI_FW_STATUS_STR_SZ]; =20 mei_fw_status_str(dev, fw_sts_str, MEI_FW_STATUS_STR_SZ); - dev_err(dev->dev, "hw_start failed ret =3D %d fw status =3D %s\n", ret, = fw_sts_str); + dev_err(&dev->dev, "hw_start failed ret =3D %d fw status =3D %s\n", ret,= fw_sts_str); return ret; } =20 if (dev->dev_state !=3D MEI_DEV_RESETTING) { - dev_dbg(dev->dev, "wrong state =3D %d on link start\n", dev->dev_state); + dev_dbg(&dev->dev, "wrong state =3D %d on link start\n", dev->dev_state); return 0; } =20 - dev_dbg(dev->dev, "link is established start sending messages.\n"); + dev_dbg(&dev->dev, "link is established start sending messages.\n"); =20 mei_set_devstate(dev, MEI_DEV_INIT_CLIENTS); ret =3D mei_hbm_start_req(dev); if (ret) { - dev_err(dev->dev, "hbm_start failed ret =3D %d\n", ret); + dev_err(&dev->dev, "hbm_start failed ret =3D %d\n", ret); mei_set_devstate(dev, MEI_DEV_RESETTING); return ret; } @@ -228,7 +228,7 @@ int mei_start(struct mei_device *dev) if (ret) goto err; =20 - dev_dbg(dev->dev, "reset in start the mei device.\n"); + dev_dbg(&dev->dev, "reset in start the mei device.\n"); =20 dev->reset_count =3D 0; do { @@ -236,27 +236,27 @@ int mei_start(struct mei_device *dev) ret =3D mei_reset(dev); =20 if (ret =3D=3D -ENODEV || dev->dev_state =3D=3D MEI_DEV_DISABLED) { - dev_err(dev->dev, "reset failed ret =3D %d", ret); + dev_err(&dev->dev, "reset failed ret =3D %d", ret); goto err; } } while (ret); =20 if (mei_hbm_start_wait(dev)) { - dev_err(dev->dev, "HBM haven't started"); + dev_err(&dev->dev, "HBM haven't started"); goto err; } =20 if (!mei_hbm_version_is_supported(dev)) { - dev_dbg(dev->dev, "MEI start failed.\n"); + dev_dbg(&dev->dev, "MEI start failed.\n"); goto err; } =20 - dev_dbg(dev->dev, "link layer has been established.\n"); + dev_dbg(&dev->dev, "link layer has been established.\n"); =20 mutex_unlock(&dev->device_lock); return 0; err: - dev_err(dev->dev, "link layer initialization failed.\n"); + dev_err(&dev->dev, "link layer initialization failed.\n"); mei_set_devstate(dev, MEI_DEV_DISABLED); mutex_unlock(&dev->device_lock); return -ENODEV; @@ -284,7 +284,7 @@ int mei_restart(struct mei_device *dev) mutex_unlock(&dev->device_lock); =20 if (err =3D=3D -ENODEV || dev->dev_state =3D=3D MEI_DEV_DISABLED) { - dev_err(dev->dev, "device disabled =3D %d\n", err); + dev_err(&dev->dev, "device disabled =3D %d\n", err); return -ENODEV; } =20 @@ -313,7 +313,7 @@ static void mei_reset_work(struct work_struct *work) mutex_unlock(&dev->device_lock); =20 if (dev->dev_state =3D=3D MEI_DEV_DISABLED) { - dev_err(dev->dev, "device disabled =3D %d\n", ret); + dev_err(&dev->dev, "device disabled =3D %d\n", ret); return; } =20 @@ -324,7 +324,7 @@ static void mei_reset_work(struct work_struct *work) =20 void mei_stop(struct mei_device *dev) { - dev_dbg(dev->dev, "stopping the device.\n"); + dev_dbg(&dev->dev, "stopping the device.\n"); =20 mutex_lock(&dev->device_lock); mei_set_devstate(dev, MEI_DEV_POWERING_DOWN); @@ -365,7 +365,7 @@ bool mei_write_is_idle(struct mei_device *dev) list_empty(&dev->write_list) && list_empty(&dev->write_waiting_list)); =20 - dev_dbg(dev->dev, "write pg: is idle[%d] state=3D%s ctrl=3D%01d write=3D%= 01d wwait=3D%01d\n", + dev_dbg(&dev->dev, "write pg: is idle[%d] state=3D%s ctrl=3D%01d write=3D= %01d wwait=3D%01d\n", idle, mei_dev_state_str(dev->dev_state), list_empty(&dev->ctrl_wr_list), @@ -376,19 +376,47 @@ bool mei_write_is_idle(struct mei_device *dev) } EXPORT_SYMBOL_GPL(mei_write_is_idle); =20 +static void mei_device_release(struct device *dev) +{ + struct mei_device *mdev =3D container_of(dev, struct mei_device, dev); + + kfree(mdev); +} + /** * mei_device_init - initialize mei_device structure * - * @dev: the mei device - * @device: the device structure + * @parent: the parent device + * @hw_size: size of hardware structure * @slow_fw: configure longer timeouts as FW is slow * @hw_ops: hw operations + * + * Return: allocated mei device, NULL on failure */ -void mei_device_init(struct mei_device *dev, - struct device *device, +struct mei_device *mei_device_init( + struct device *parent, + size_t hw_size, bool slow_fw, const struct mei_hw_ops *hw_ops) { + struct mei_device *dev; + int ret; + + dev =3D kzalloc(sizeof(*dev) + hw_size, GFP_KERNEL); + if (!dev) + return NULL; + + dev->dev.parent =3D parent; + dev->dev.release =3D mei_device_release; + dev_set_name(&dev->dev, "meid.%s", dev_name(parent)); + + ret =3D device_register(&dev->dev); + if (ret) { + kfree(dev); + dev_err(parent, "failed to register mei_device %d", ret); + return NULL; + } + /* setup our list array */ INIT_LIST_HEAD(&dev->file_list); INIT_LIST_HEAD(&dev->device_list); @@ -426,7 +454,7 @@ void mei_device_init(struct mei_device *dev, =20 dev->pg_event =3D MEI_PG_EVENT_IDLE; dev->ops =3D hw_ops; - dev->dev =3D device; + dev->parent =3D parent; =20 dev->timeouts.hw_ready =3D mei_secs_to_jiffies(MEI_HW_READY_TIMEOUT); dev->timeouts.connect =3D MEI_CONNECT_TIMEOUT; @@ -442,6 +470,13 @@ void mei_device_init(struct mei_device *dev, dev->timeouts.hbm =3D mei_secs_to_jiffies(MEI_HBM_TIMEOUT); dev->timeouts.mkhi_recv =3D msecs_to_jiffies(MKHI_RCV_TIMEOUT); } + + return dev; } EXPORT_SYMBOL_GPL(mei_device_init); =20 +void mei_device_deinit(struct mei_device *dev) +{ + device_unregister(&dev->dev); +} +EXPORT_SYMBOL_GPL(mei_device_deinit); diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c index d472f6bbe767..3aa66b6b0d36 100644 --- a/drivers/misc/mei/interrupt.c +++ b/drivers/misc/mei/interrupt.c @@ -76,7 +76,7 @@ static void mei_irq_discard_msg(struct mei_device *dev, s= truct mei_msg_hdr *hdr, * that length fits into rd_msg_buf */ mei_read_slots(dev, dev->rd_msg_buf, discard_len); - dev_dbg(dev->dev, "discarding message " MEI_HDR_FMT "\n", + dev_dbg(&dev->dev, "discarding message " MEI_HDR_FMT "\n", MEI_HDR_PRM(hdr)); } =20 @@ -229,8 +229,8 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl, cl_dbg(dev, cl, "completed read length =3D %zu\n", cb->buf_idx); list_move_tail(&cb->list, cmpl_list); } else { - pm_runtime_mark_last_busy(dev->dev); - pm_request_autosuspend(dev->dev); + pm_runtime_mark_last_busy(dev->parent); + pm_request_autosuspend(dev->parent); } =20 return 0; @@ -310,8 +310,8 @@ static int mei_cl_irq_read(struct mei_cl *cl, struct me= i_cl_cb *cb, return ret; } =20 - pm_runtime_mark_last_busy(dev->dev); - pm_request_autosuspend(dev->dev); + pm_runtime_mark_last_busy(dev->parent); + pm_request_autosuspend(dev->parent); =20 list_move_tail(&cb->list, &cl->rd_pending); =20 @@ -373,21 +373,21 @@ int mei_irq_read_handler(struct mei_device *dev, dev->rd_msg_hdr[0] =3D mei_read_hdr(dev); dev->rd_msg_hdr_count =3D 1; (*slots)--; - dev_dbg(dev->dev, "slots =3D%08x.\n", *slots); + dev_dbg(&dev->dev, "slots =3D%08x.\n", *slots); =20 ret =3D hdr_is_valid(dev->rd_msg_hdr[0]); if (ret) { - dev_err(dev->dev, "corrupted message header 0x%08X\n", + dev_err(&dev->dev, "corrupted message header 0x%08X\n", dev->rd_msg_hdr[0]); goto end; } } =20 mei_hdr =3D (struct mei_msg_hdr *)dev->rd_msg_hdr; - dev_dbg(dev->dev, MEI_HDR_FMT, MEI_HDR_PRM(mei_hdr)); + dev_dbg(&dev->dev, MEI_HDR_FMT, MEI_HDR_PRM(mei_hdr)); =20 if (mei_slots2data(*slots) < mei_hdr->length) { - dev_err(dev->dev, "less data available than length=3D%08x.\n", + dev_err(&dev->dev, "less data available than length=3D%08x.\n", *slots); /* we can't read the message */ ret =3D -ENODATA; @@ -402,18 +402,18 @@ int mei_irq_read_handler(struct mei_device *dev, dev->rd_msg_hdr[1] =3D mei_read_hdr(dev); dev->rd_msg_hdr_count++; (*slots)--; - dev_dbg(dev->dev, "extended header is %08x\n", dev->rd_msg_hdr[1]); + dev_dbg(&dev->dev, "extended header is %08x\n", dev->rd_msg_hdr[1]); } meta_hdr =3D ((struct mei_ext_meta_hdr *)&dev->rd_msg_hdr[1]); if (check_add_overflow((u32)sizeof(*meta_hdr), mei_slots2data(meta_hdr->size), &hdr_size_ext)) { - dev_err(dev->dev, "extended message size too big %d\n", + dev_err(&dev->dev, "extended message size too big %d\n", meta_hdr->size); return -EBADMSG; } if (hdr_size_left < hdr_size_ext) { - dev_err(dev->dev, "corrupted message header len %d\n", + dev_err(&dev->dev, "corrupted message header len %d\n", mei_hdr->length); return -EBADMSG; } @@ -422,7 +422,7 @@ int mei_irq_read_handler(struct mei_device *dev, ext_hdr_end =3D meta_hdr->size + 2; for (i =3D dev->rd_msg_hdr_count; i < ext_hdr_end; i++) { dev->rd_msg_hdr[i] =3D mei_read_hdr(dev); - dev_dbg(dev->dev, "extended header %d is %08x\n", i, + dev_dbg(&dev->dev, "extended header %d is %08x\n", i, dev->rd_msg_hdr[i]); dev->rd_msg_hdr_count++; (*slots)--; @@ -431,7 +431,7 @@ int mei_irq_read_handler(struct mei_device *dev, =20 if (mei_hdr->dma_ring) { if (hdr_size_left !=3D sizeof(dev->rd_msg_hdr[ext_hdr_end])) { - dev_err(dev->dev, "corrupted message header len %d\n", + dev_err(&dev->dev, "corrupted message header len %d\n", mei_hdr->length); return -EBADMSG; } @@ -446,8 +446,7 @@ int mei_irq_read_handler(struct mei_device *dev, if (hdr_is_hbm(mei_hdr)) { ret =3D mei_hbm_dispatch(dev, mei_hdr); if (ret) { - dev_dbg(dev->dev, "mei_hbm_dispatch failed ret =3D %d\n", - ret); + dev_dbg(&dev->dev, "mei_hbm_dispatch failed ret =3D %d\n", ret); goto end; } goto reset_slots; @@ -474,7 +473,7 @@ int mei_irq_read_handler(struct mei_device *dev, ret =3D 0; goto reset_slots; } - dev_err(dev->dev, "no destination client found 0x%08X\n", dev->rd_msg_hdr= [0]); + dev_err(&dev->dev, "no destination client found 0x%08X\n", dev->rd_msg_hd= r[0]); ret =3D -EBADMSG; goto end; =20 @@ -485,7 +484,7 @@ int mei_irq_read_handler(struct mei_device *dev, *slots =3D mei_count_full_read_slots(dev); if (*slots =3D=3D -EOVERFLOW) { /* overflow - reset */ - dev_err(dev->dev, "resetting due to slots overflow.\n"); + dev_err(&dev->dev, "resetting due to slots overflow.\n"); /* set the event since message has been read */ ret =3D -ERANGE; goto end; @@ -525,7 +524,7 @@ int mei_irq_write_handler(struct mei_device *dev, struc= t list_head *cmpl_list) return -EMSGSIZE; =20 /* complete all waiting for write CB */ - dev_dbg(dev->dev, "complete all waiting for write cb.\n"); + dev_dbg(&dev->dev, "complete all waiting for write cb.\n"); =20 list_for_each_entry_safe(cb, next, &dev->write_waiting_list, list) { cl =3D cb->cl; @@ -537,7 +536,7 @@ int mei_irq_write_handler(struct mei_device *dev, struc= t list_head *cmpl_list) } =20 /* complete control write list CB */ - dev_dbg(dev->dev, "complete control write list cb.\n"); + dev_dbg(&dev->dev, "complete control write list cb.\n"); list_for_each_entry_safe(cb, next, &dev->ctrl_wr_list, list) { cl =3D cb->cl; switch (cb->fop_type) { @@ -591,7 +590,7 @@ int mei_irq_write_handler(struct mei_device *dev, struc= t list_head *cmpl_list) =20 } /* complete write list CB */ - dev_dbg(dev->dev, "complete write list cb.\n"); + dev_dbg(&dev->dev, "complete write list cb.\n"); list_for_each_entry_safe(cb, next, &dev->write_list, list) { cl =3D cb->cl; ret =3D mei_cl_irq_write(cl, cb, cmpl_list); @@ -656,7 +655,7 @@ void mei_timer(struct work_struct *work) =20 if (dev->init_clients_timer) { if (--dev->init_clients_timer =3D=3D 0) { - dev_err(dev->dev, "timer: init clients timeout hbm_state =3D %d.\n", + dev_err(&dev->dev, "timer: init clients timeout hbm_state =3D %d.\n", dev->hbm_state); mei_reset(dev); goto out; @@ -672,7 +671,7 @@ void mei_timer(struct work_struct *work) list_for_each_entry(cl, &dev->file_list, link) { if (cl->timer_count) { if (--cl->timer_count =3D=3D 0) { - dev_err(dev->dev, "timer: connect/disconnect timeout.\n"); + dev_err(&dev->dev, "timer: connect/disconnect timeout.\n"); mei_connect_timeout(cl); goto out; } diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index 90c9eef0d876..42a42affb65e 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c @@ -54,11 +54,12 @@ static int mei_open(struct inode *inode, struct file *f= ile) dev =3D idr_find(&mei_idr, iminor(inode)); if (!dev) return -ENODEV; + get_device(&dev->dev); =20 mutex_lock(&dev->device_lock); =20 if (dev->dev_state !=3D MEI_DEV_ENABLED) { - dev_dbg(dev->dev, "dev_state !=3D MEI_ENABLED dev_state =3D %s\n", + dev_dbg(&dev->dev, "dev_state !=3D MEI_ENABLED dev_state =3D %s\n", mei_dev_state_str(dev->dev_state)); err =3D -ENODEV; goto err_unlock; @@ -79,6 +80,7 @@ static int mei_open(struct inode *inode, struct file *fil= e) =20 err_unlock: mutex_unlock(&dev->device_lock); + put_device(&dev->dev); return err; } =20 @@ -154,6 +156,7 @@ static int mei_release(struct inode *inode, struct file= *file) file->private_data =3D NULL; =20 mutex_unlock(&dev->device_lock); + put_device(&dev->dev); return rets; } =20 @@ -479,7 +482,7 @@ static int mei_vt_support_check(struct mei_device *dev,= const uuid_le *uuid) =20 me_cl =3D mei_me_cl_by_uuid(dev, uuid); if (!me_cl) { - dev_dbg(dev->dev, "Cannot connect to FW Client UUID =3D %pUl\n", + dev_dbg(&dev->dev, "Cannot connect to FW Client UUID =3D %pUl\n", uuid); return -ENOTTY; } @@ -1196,7 +1199,7 @@ static int mei_minor_get(struct mei_device *dev) if (ret >=3D 0) dev->minor =3D ret; else if (ret =3D=3D -ENOSPC) - dev_err(dev->dev, "too many mei devices\n"); + dev_err(&dev->dev, "too many mei devices\n"); =20 mutex_unlock(&mei_minor_lock); return ret; diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h index 0cc943afa80a..c643dae952b2 100644 --- a/drivers/misc/mei/mei_dev.h +++ b/drivers/misc/mei/mei_dev.h @@ -470,7 +470,8 @@ struct mei_dev_timeouts { /** * struct mei_device - MEI private device struct * - * @dev : device on a bus + * @parent : device on a bus + * @dev : device object * @cdev : character device pointer * @minor : minor number allocated for device * @@ -556,7 +557,8 @@ struct mei_dev_timeouts { * @hw : hw specific data */ struct mei_device { - struct device *dev; + struct device *parent; + struct device dev; struct cdev *cdev; int minor; =20 @@ -702,10 +704,11 @@ static inline u32 mei_slots2data(int slots) /* * mei init function prototypes */ -void mei_device_init(struct mei_device *dev, - struct device *device, +struct mei_device *mei_device_init(struct device *device, + size_t hw_size, bool slow_fw, const struct mei_hw_ops *hw_ops); +void mei_device_deinit(struct mei_device *dev); int mei_reset(struct mei_device *dev); int mei_start(struct mei_device *dev); int mei_restart(struct mei_device *dev); diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c index 3f9c60b579ae..1a4eb9acd104 100644 --- a/drivers/misc/mei/pci-me.c +++ b/drivers/misc/mei/pci-me.c @@ -143,7 +143,7 @@ static inline void mei_me_unset_pm_domain(struct mei_de= vice *dev) {} =20 static int mei_me_read_fws(const struct mei_device *dev, int where, u32 *v= al) { - struct pci_dev *pdev =3D to_pci_dev(dev->dev); + struct pci_dev *pdev =3D to_pci_dev(dev->parent); =20 return pci_read_config_dword(pdev, where, val); } @@ -235,7 +235,7 @@ static int mei_me_probe(struct pci_dev *pdev, const str= uct pci_device_id *ent) if (err) { dev_err(&pdev->dev, "request_threaded_irq failure. irq =3D %d\n", pdev->irq); - goto end; + goto deinit; } =20 if (mei_start(dev)) { @@ -286,6 +286,8 @@ static int mei_me_probe(struct pci_dev *pdev, const str= uct pci_device_id *ent) mei_cancel_work(dev); mei_disable_interrupts(dev); free_irq(pdev->irq, dev); +deinit: + mei_device_deinit(dev); end: dev_err(&pdev->dev, "initialization failed.\n"); return err; @@ -338,6 +340,8 @@ static void mei_me_remove(struct pci_dev *pdev) free_irq(pdev->irq, dev); =20 mei_deregister(dev); + + mei_device_deinit(dev); } =20 #ifdef CONFIG_PM_SLEEP @@ -475,7 +479,7 @@ static int mei_me_pm_runtime_resume(struct device *devi= ce) */ static inline void mei_me_set_pm_domain(struct mei_device *dev) { - struct pci_dev *pdev =3D to_pci_dev(dev->dev); + struct pci_dev *pdev =3D to_pci_dev(dev->parent); =20 if (pdev->dev.bus && pdev->dev.bus->pm) { dev->pg_domain.ops =3D *pdev->dev.bus->pm; @@ -496,7 +500,7 @@ static inline void mei_me_set_pm_domain(struct mei_devi= ce *dev) static inline void mei_me_unset_pm_domain(struct mei_device *dev) { /* stop using pm callbacks if any */ - dev_pm_domain_set(dev->dev, NULL); + dev_pm_domain_set(dev->parent, NULL); } =20 static const struct dev_pm_ops mei_me_pm_ops =3D { diff --git a/drivers/misc/mei/pci-txe.c b/drivers/misc/mei/pci-txe.c index 2a584104ba38..720748a51524 100644 --- a/drivers/misc/mei/pci-txe.c +++ b/drivers/misc/mei/pci-txe.c @@ -106,7 +106,7 @@ static int mei_txe_probe(struct pci_dev *pdev, const st= ruct pci_device_id *ent) if (err) { dev_err(&pdev->dev, "mei: request_threaded_irq failure. irq =3D %d\n", pdev->irq); - goto end; + goto deinit; } =20 if (mei_start(dev)) { @@ -150,6 +150,8 @@ static int mei_txe_probe(struct pci_dev *pdev, const st= ruct pci_device_id *ent) mei_cancel_work(dev); mei_disable_interrupts(dev); free_irq(pdev->irq, dev); +deinit: + mei_device_deinit(dev); end: dev_err(&pdev->dev, "initialization failed.\n"); return err; @@ -199,6 +201,8 @@ static void mei_txe_remove(struct pci_dev *pdev) free_irq(pdev->irq, dev); =20 mei_deregister(dev); + + mei_device_deinit(dev); } =20 =20 @@ -321,7 +325,7 @@ static int mei_txe_pm_runtime_resume(struct device *dev= ice) */ static inline void mei_txe_set_pm_domain(struct mei_device *dev) { - struct pci_dev *pdev =3D to_pci_dev(dev->dev); + struct pci_dev *pdev =3D to_pci_dev(dev->parent); =20 if (pdev->dev.bus && pdev->dev.bus->pm) { dev->pg_domain.ops =3D *pdev->dev.bus->pm; @@ -342,7 +346,7 @@ static inline void mei_txe_set_pm_domain(struct mei_dev= ice *dev) static inline void mei_txe_unset_pm_domain(struct mei_device *dev) { /* stop using pm callbacks if any */ - dev_pm_domain_set(dev->dev, NULL); + dev_pm_domain_set(dev->parent, NULL); } =20 static const struct dev_pm_ops mei_txe_pm_ops =3D { diff --git a/drivers/misc/mei/platform-vsc.c b/drivers/misc/mei/platform-vs= c.c index 435760b1e86f..f353020701c2 100644 --- a/drivers/misc/mei/platform-vsc.c +++ b/drivers/misc/mei/platform-vsc.c @@ -152,7 +152,7 @@ static int mei_vsc_hw_start(struct mei_device *mei_dev) MEI_VSC_POLL_TIMEOUT_US, true, hw, &buf, sizeof(buf)); if (ret) { - dev_err(mei_dev->dev, "wait fw ready failed: %d\n", ret); + dev_err(&mei_dev->dev, "wait fw ready failed: %d\n", ret); return ret; } =20 @@ -256,7 +256,7 @@ static int mei_vsc_hw_reset(struct mei_device *mei_dev,= bool intr_enable) =20 vsc_tp_reset(hw->tp); =20 - return vsc_tp_init(hw->tp, mei_dev->dev); + return vsc_tp_init(hw->tp, mei_dev->parent); } =20 static const struct mei_hw_ops mei_vsc_hw_ops =3D { @@ -322,7 +322,7 @@ static void mei_vsc_event_cb(void *context) mei_dev->hbuf_is_ready =3D mei_hbuf_is_ready(mei_dev); ret =3D mei_irq_write_handler(mei_dev, &cmpl_list); if (ret) - dev_err(mei_dev->dev, "dispatch write request failed: %d\n", ret); + dev_err(&mei_dev->dev, "dispatch write request failed: %d\n", ret); =20 mei_dev->hbuf_is_ready =3D mei_hbuf_is_ready(mei_dev); mei_irq_compl_handler(mei_dev, &cmpl_list); @@ -340,12 +340,10 @@ static int mei_vsc_probe(struct platform_device *pdev) if (!tp) return dev_err_probe(dev, -ENODEV, "no platform data\n"); =20 - mei_dev =3D devm_kzalloc(dev, size_add(sizeof(*mei_dev), sizeof(*hw)), - GFP_KERNEL); + mei_dev =3D mei_device_init(dev, sizeof(*hw), false, &mei_vsc_hw_ops); if (!mei_dev) return -ENOMEM; =20 - mei_device_init(mei_dev, dev, false, &mei_vsc_hw_ops); mei_dev->fw_f_fw_ver_supported =3D 0; mei_dev->kind =3D "ivsc"; =20 @@ -367,7 +365,7 @@ static int mei_vsc_probe(struct platform_device *pdev) if (ret) goto err_stop; =20 - pm_runtime_enable(mei_dev->dev); + pm_runtime_enable(mei_dev->parent); =20 return 0; =20 @@ -379,6 +377,8 @@ static int mei_vsc_probe(struct platform_device *pdev) =20 mei_disable_interrupts(mei_dev); =20 + mei_device_deinit(mei_dev); + return ret; } =20 @@ -386,13 +386,15 @@ static void mei_vsc_remove(struct platform_device *pd= ev) { struct mei_device *mei_dev =3D platform_get_drvdata(pdev); =20 - pm_runtime_disable(mei_dev->dev); + pm_runtime_disable(mei_dev->parent); =20 mei_stop(mei_dev); =20 mei_disable_interrupts(mei_dev); =20 mei_deregister(mei_dev); + + mei_device_deinit(mei_dev); } =20 static int mei_vsc_suspend(struct device *dev) --=20 2.43.0