From nobody Fri Oct 3 20:29:11 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 A5A3323026B for ; Tue, 26 Aug 2025 13:09:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756213753; cv=none; b=A+n34X8paPxU2h76ssCU5JBmqTFL0LVqrLxoue/AbhnkfuhHQ+J8fHi7WSyl/PIAHbSYG5f79KNUAiqXhzYWPVTDT+zEPtiwpRgHlU6h9d808X7naiWhGwfTb8+QdZZFWGlBA0C8EIF2BfZ7PyesLRazoTLk2zce7Jwot0yML1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756213753; c=relaxed/simple; bh=H6Rm4dZwNZFYbrteVaC20uOH3TpT6NFVNFCQyyq8ZDo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=anj1PrQGf44xPsXM7wpSmKRUAG3bdUgnDyDM5qSZTdDSlEPSvGhqi4Wh30o6Iufm4enC8GBWKlX+iZNGw1+N+uamtNQKmBMEAHwRDHnEGGy3zowzgv8183uWUVpiR3paY7V6hKavQtdWNXwTF+UFHslJRRdKXm8lLFQnG03sQ+E= 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=gqUjgZAw; arc=none smtp.client-ip=198.175.65.16 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="gqUjgZAw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1756213749; x=1787749749; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=H6Rm4dZwNZFYbrteVaC20uOH3TpT6NFVNFCQyyq8ZDo=; b=gqUjgZAwF2Es853Ir0FB6muWppU3noOzSC/l2MDSTvrx+umQDHYt8JsI ohhU+J2F0pJQy2KqKRx0GWque7d9j0gZhGv+Tt39yf7s8rFfXBPdjlK/K MP320HDoe65LhuO58EKGu9rEjF6bViTh+WUWlNUfIQXYWp9Q1YGKoQsBC HSVMwq+bLXHHC4B5xuGJnQgHrtVOMRCyyRsKtJlQJZQ+T81NnsPRBOAik EHmkr21uCuTrfamZxas4XPyYSX1/9szORGmGmwdy4lOH+xI5iwwW09tya wbjd1QeCh+Uv3wNmbB50htFfHQsvdPrKcoBCHLwOUBxpp2aVD0otOSuTS w==; X-CSE-ConnectionGUID: 6Q/Iikv8RbC5HCBnesqt0A== X-CSE-MsgGUID: vcN641AERtmCk3oCKUZyOQ== X-IronPort-AV: E=McAfee;i="6800,10657,11534"; a="58591867" X-IronPort-AV: E=Sophos;i="6.18,214,1751266800"; d="scan'208";a="58591867" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2025 06:09:07 -0700 X-CSE-ConnectionGUID: DNGcHEvNSZei96ObF/Ts0g== X-CSE-MsgGUID: 0vhhh4PuRKS7LGumjDUnmg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.18,214,1751266800"; d="scan'208";a="200519023" Received: from sannilnx-dsk.jer.intel.com ([10.12.231.107]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2025 06:09:05 -0700 From: Alexander Usyskin To: Greg Kroah-Hartman Cc: Reuven Abliyev , Alexander Usyskin , linux-kernel@vger.kernel.org Subject: [char-misc-next] mei: hook mei_device on class device Date: Tue, 26 Aug 2025 15:56:17 +0300 Message-ID: <20250826125617.1166546-1-alexander.usyskin@intel.com> X-Mailer: git-send-email 2.43.0 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 was 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. Connect mei_device structure lifteme to mei class device lifetime by adding mei_device free to class device remove callback. Move exising parent device pointer to separate field in mei_device to avoid misuse. 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. Leave power management on parent device as we overwrite pci runtime pm procedure and user-space is expecting it there. Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14201 Signed-off-by: Alexander Usyskin --- This is a rebase and resend of last patch of "[char-misc-next v4 0/3] mei: fix mei_device lifetime" series https://lore.kernel.org/lkml/20250717141112.1696482-4-alexander.usyskin@int= el.com/ over the latest char-misc-next as it can't be applied cleanly anymore. As the first two patches of the series are merged I can't do v5, I suppose. 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 | 16 ++--- drivers/misc/mei/hbm.c | 121 +++++++++++++++----------------- drivers/misc/mei/hw-me.c | 100 +++++++++++++------------- drivers/misc/mei/hw-txe.c | 60 ++++++++-------- drivers/misc/mei/init.c | 47 ++++++------- drivers/misc/mei/interrupt.c | 45 ++++++------ drivers/misc/mei/main.c | 80 ++++++++++++++------- drivers/misc/mei/mei_dev.h | 12 ++-- drivers/misc/mei/pci-me.c | 20 +++--- drivers/misc/mei/pci-txe.c | 4 +- drivers/misc/mei/platform-vsc.c | 26 +++---- 16 files changed, 342 insertions(+), 315 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 5cc3ad07d5be..6c8ec5c0d359 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 /** @@ -1285,16 +1285,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) @@ -1328,7 +1332,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 @@ -1357,7 +1361,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); @@ -1492,7 +1496,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; @@ -1543,7 +1547,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..f147258e7c28 100644 --- a/drivers/misc/mei/gsc-me.c +++ b/drivers/misc/mei/gsc-me.c @@ -106,11 +106,15 @@ static int mei_gsc_probe(struct auxiliary_device *aux= _dev, } } =20 + ret =3D mei_register(dev, device); + if (ret) + goto deinterrupt; + pm_runtime_get_noresume(device); pm_runtime_set_active(device); pm_runtime_enable(device); =20 - /* Continue to char device setup in spite of firmware handshake failure. + /* Continue in spite of firmware handshake failure. * In order to provide access to the firmware status registers to the user * space via sysfs. */ @@ -120,18 +124,12 @@ static int mei_gsc_probe(struct auxiliary_device *aux= _dev, pm_runtime_set_autosuspend_delay(device, MEI_GSC_RPM_TIMEOUT); pm_runtime_use_autosuspend(device); =20 - ret =3D mei_register(dev, device); - if (ret) - goto register_err; - pm_runtime_put_noidle(device); return 0; =20 -register_err: - mei_stop(dev); +deinterrupt: if (!mei_me_hw_use_polling(hw)) devm_free_irq(device, hw->irq, dev); - err: dev_err(device, "probe failed: %d\n", ret); dev_set_drvdata(device, NULL); @@ -252,7 +250,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..346633ebc6e6 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 kzalloc(sizeof(*dev) + sizeof(*hw), GFP_KERNEL); if (!dev) return NULL; =20 diff --git a/drivers/misc/mei/hw-txe.c b/drivers/misc/mei/hw-txe.c index e9476f9ae25d..e4688c391027 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,7 +1197,7 @@ struct mei_device *mei_txe_dev_init(struct pci_dev *p= dev) struct mei_device *dev; struct mei_txe_hw *hw; =20 - dev =3D devm_kzalloc(&pdev->dev, sizeof(*dev) + sizeof(*hw), GFP_KERNEL); + dev =3D kzalloc(sizeof(*dev) + sizeof(*hw), GFP_KERNEL); if (!dev) return NULL; =20 diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c index 8ef2b1df8ac7..4d1d5423b612 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), @@ -380,12 +380,12 @@ EXPORT_SYMBOL_GPL(mei_write_is_idle); * mei_device_init - initialize mei_device structure * * @dev: the mei device - * @device: the device structure + * @parent: the parent device * @slow_fw: configure longer timeouts as FW is slow * @hw_ops: hw operations */ void mei_device_init(struct mei_device *dev, - struct device *device, + struct device *parent, bool slow_fw, const struct mei_hw_ops *hw_ops) { @@ -426,7 +426,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; @@ -444,4 +444,3 @@ void mei_device_init(struct mei_device *dev, } } EXPORT_SYMBOL_GPL(mei_device_init); - 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 8a149a15b861..f37f9b8b1f51 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c @@ -51,12 +51,15 @@ static int mei_open(struct inode *inode, struct file *f= ile) =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; + 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; @@ -77,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 @@ -152,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 @@ -477,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; } @@ -1115,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); @@ -1191,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; @@ -1209,9 +1217,13 @@ static void mei_minor_free(struct mei_device *dev) mutex_unlock(&mei_minor_lock); } =20 +static void mei_device_release(struct device *dev) +{ + kfree(dev_get_drvdata(dev)); +} + int mei_register(struct mei_device *dev, struct device *parent) { - struct device *clsdev; /* class device */ int ret, devno; =20 ret =3D mei_minor_get(dev); @@ -1220,35 +1232,53 @@ 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; + + device_initialize(&dev->dev); + dev->dev.devt =3D devno; + dev->dev.class =3D &mei_class; + dev->dev.parent =3D parent; + dev->dev.groups =3D mei_groups; + dev->dev.release =3D mei_device_release; + dev_set_drvdata(&dev->dev, dev); + + 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, &dev->dev.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", + dev_err(parent, "unable to add cdev for 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, - dev, mei_groups, - "mei%d", dev->minor); + ret =3D dev_set_name(&dev->dev, "mei%d", dev->minor); + if (ret) { + dev_err(parent, "unable to set name to device %d:%d ret =3D %d\n", + MAJOR(mei_devt), dev->minor, ret); + goto err_del_cdev; + } =20 - if (IS_ERR(clsdev)) { - dev_err(parent, "unable to create device %d:%d\n", - MAJOR(mei_devt), dev->minor); - ret =3D PTR_ERR(clsdev); - goto err_dev_create; + ret =3D device_add(&dev->dev); + if (ret) { + dev_err(parent, "unable to add device %d:%d ret =3D %d\n", + MAJOR(mei_devt), dev->minor, ret); + goto err_del_cdev; } =20 - mei_dbgfs_register(dev, dev_name(clsdev)); + mei_dbgfs_register(dev, dev_name(&dev->dev)); =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; } @@ -1258,8 +1288,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..4ab2b9100fd4 100644 --- a/drivers/misc/mei/mei_dev.h +++ b/drivers/misc/mei/mei_dev.h @@ -470,8 +470,9 @@ struct mei_dev_timeouts { /** * struct mei_device - MEI private device struct * - * @dev : device on a bus - * @cdev : character device + * @parent : device on a bus + * @dev : device object + * @cdev : character device pointer * @minor : minor number allocated for device * * @write_list : write pending list @@ -556,8 +557,9 @@ struct mei_dev_timeouts { * @hw : hw specific data */ struct mei_device { - struct device *dev; - struct cdev cdev; + struct device *parent; + struct device dev; + struct cdev *cdev; int minor; =20 struct list_head write_list; @@ -703,7 +705,7 @@ static inline u32 mei_slots2data(int slots) * mei init function prototypes */ void mei_device_init(struct mei_device *dev, - struct device *device, + struct device *parent, bool slow_fw, const struct mei_hw_ops *hw_ops); int mei_reset(struct mei_device *dev); diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c index 3f9c60b579ae..b108a7c22388 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); } @@ -238,19 +238,19 @@ static int mei_me_probe(struct pci_dev *pdev, const s= truct pci_device_id *ent) goto end; } =20 + err =3D mei_register(dev, &pdev->dev); + if (err) + goto release_irq; + if (mei_start(dev)) { dev_err(&pdev->dev, "init hw failure.\n"); err =3D -ENODEV; - goto release_irq; + goto deregister; } =20 pm_runtime_set_autosuspend_delay(&pdev->dev, MEI_ME_RPM_TIMEOUT); pm_runtime_use_autosuspend(&pdev->dev); =20 - err =3D mei_register(dev, &pdev->dev); - if (err) - goto stop; - pci_set_drvdata(pdev, dev); =20 /* @@ -280,8 +280,8 @@ static int mei_me_probe(struct pci_dev *pdev, const str= uct pci_device_id *ent) =20 return 0; =20 -stop: - mei_stop(dev); +deregister: + mei_deregister(dev); release_irq: mei_cancel_work(dev); mei_disable_interrupts(dev); @@ -475,7 +475,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 +496,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..c9eb5c5393e4 100644 --- a/drivers/misc/mei/pci-txe.c +++ b/drivers/misc/mei/pci-txe.c @@ -321,7 +321,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 +342,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 b2b5a20ae3fa..288e7b72e942 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 @@ -259,7 +259,7 @@ static int mei_vsc_hw_reset(struct mei_device *mei_dev,= bool intr_enable) if (!intr_enable) return 0; =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 { @@ -325,7 +325,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); @@ -343,12 +343,12 @@ 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 kzalloc(size_add(sizeof(*mei_dev), sizeof(*hw)), GFP_KERNEL); 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 @@ -360,22 +360,22 @@ static int mei_vsc_probe(struct platform_device *pdev) =20 vsc_tp_register_event_cb(tp, mei_vsc_event_cb, mei_dev); =20 + ret =3D mei_register(mei_dev, dev); + if (ret) + goto err_dereg; + ret =3D mei_start(mei_dev); if (ret) { dev_err_probe(dev, ret, "init hw failed\n"); goto err_cancel; } =20 - ret =3D mei_register(mei_dev, dev); - if (ret) - goto err_stop; - - pm_runtime_enable(mei_dev->dev); + pm_runtime_enable(mei_dev->parent); =20 return 0; =20 -err_stop: - mei_stop(mei_dev); +err_dereg: + mei_deregister(mei_dev); =20 err_cancel: mei_cancel_work(mei_dev); @@ -392,7 +392,7 @@ static void mei_vsc_remove(struct platform_device *pdev) struct mei_device *mei_dev =3D platform_get_drvdata(pdev); struct mei_vsc_hw *hw =3D mei_dev_to_vsc_hw(mei_dev); =20 - pm_runtime_disable(mei_dev->dev); + pm_runtime_disable(mei_dev->parent); =20 mei_stop(mei_dev); =20 --=20 2.43.0