All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@public.gmane.org>
To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Reparenting a platform device
Date: Thu, 5 Apr 2012 10:42:58 +0200	[thread overview]
Message-ID: <20120405084258.GA19798@avionic-0098.adnet.avionic-design.de> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 2880 bytes --]

Hi,

I have a device tree where I have a GART device and a DRM device which uses
the GART. The GART is implemented by an IOMMU driver (tegra-gart) and
requires the user device to be a child of the GART device (it explicitly
checks for this when the user device is attached).

I've tried two alternatives to achieve this: create the GART device in the
user driver's .probe() function and explicitly set the DRM device's parent
to the resulting platform device like so:

	gart = platform_device_alloc(...);
	...
	pdev->dev.parent = &gart->dev;

The alternative is to use the device tree to look up the GART device node and
resolve it to the corresponding struct device:

	gart_node = of_parse_phandle(drm->dev->of_node, "gart-parent", 0);
	gart = bus_find_device(drm->dev->bus, NULL, gart_node, match_of_node);

Where match_of_node matches each struct device's .of_node field to the
gart_node.

Both of these variants seem to work, and the DRM device can be properly
attached to the GART device. However, after the DRM driver's .probe() exits,
I get the following error:

	[   25.579261] ------------[ cut here ]------------
	[   25.583895] WARNING: at /home/thierry.reding/src/kernel/linux-ipmp.git/kernel/mutex-debug.c:78 debug_mutex_unlock+0x114/0x128()
	[   25.595352] Modules linked in: tegra_drm(+) cfbfillrect cfbimgblt cfbcopyarea drm_kms_helper drm fb pwm_tegra pwm_bl backlight
	[   25.606821] [<c0013c54>] (unwind_backtrace+0x0/0xf8) from [<c0027bcc>] (warn_slowpath_common+0x4c/0x64)
	[   25.616207] [<c0027bcc>] (warn_slowpath_common+0x4c/0x64) from [<c0027c00>] (warn_slowpath_null+0x1c/0x24)
	[   25.625853] [<c0027c00>] (warn_slowpath_null+0x1c/0x24) from [<c00667fc>] (debug_mutex_unlock+0x114/0x128)
	[   25.635508] [<c00667fc>] (debug_mutex_unlock+0x114/0x128) from [<c03bee2c>] (__mutex_unlock_slowpath+0x84/0x140)
	[   25.645680] [<c03bee2c>] (__mutex_unlock_slowpath+0x84/0x140) from [<c02149b4>] (__driver_attach+0x78/0x90)
	[   25.655412] [<c02149b4>] (__driver_attach+0x78/0x90) from [<c0213128>] (bus_for_each_dev+0x50/0x7c)
	[   25.664449] [<c0213128>] (bus_for_each_dev+0x50/0x7c) from [<c0214038>] (bus_add_driver+0x174/0x234)
	[   25.673572] [<c0214038>] (bus_add_driver+0x174/0x234) from [<c0214e7c>] (driver_register+0x78/0x12c)
	[   25.682696] [<c0214e7c>] (driver_register+0x78/0x12c) from [<c0008620>] (do_one_initcall+0x34/0x174)
	[   25.691826] [<c0008620>] (do_one_initcall+0x34/0x174) from [<c006dab0>] (sys_init_module+0xc20/0x18e0)
	[   25.701131] [<c006dab0>] (sys_init_module+0xc20/0x18e0) from [<c000df00>] (ret_fast_syscall+0x0/0x30)
	[   25.710336] ---[ end trace f64968a4a9d9fe8b ]---

I may be misinterpreting things, but this looks to be caused by the
reparenting. So the question is whether what I'm trying to do is valid or
if there is some other way to properly make the GART device the parent of
the DRM device.

Thanks,
Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 192 bytes --]

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

             reply	other threads:[~2012-04-05  8:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-05  8:42 Thierry Reding [this message]
     [not found] ` <20120405084258.GA19798-RM9K5IK7kjIyiCvfTdI0JKcOhU4Rzj621B7CTYaBSLdn68oJJulU0Q@public.gmane.org>
2012-04-05 15:40   ` Reparenting a platform device Stephen Warren
     [not found]     ` <4F7DBCEE.9080400-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-04-05 16:23       ` Thierry Reding
     [not found]         ` <20120405162318.GA10628-RM9K5IK7kjIyiCvfTdI0JKcOhU4Rzj621B7CTYaBSLdn68oJJulU0Q@public.gmane.org>
2012-04-05 18:08           ` Thierry Reding
     [not found]             ` <20120405180805.GB11601-RM9K5IK7kjIyiCvfTdI0JKcOhU4Rzj621B7CTYaBSLdn68oJJulU0Q@public.gmane.org>
2012-04-05 19:21               ` Stephen Warren
     [not found]                 ` <4F7DF0B3.4050500-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-04-06  7:20                   ` Thierry Reding
     [not found]                     ` <20120406072014.GA14250-RM9K5IK7kjIQXX3q8xo1gnVAuStQJXxyR5q1nwbD4aMs9pC9oP6+/A@public.gmane.org>
2012-04-06 16:37                       ` Stephen Warren
     [not found]                         ` <4F7F1BCB.7070608-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-04-08 14:21                           ` Thierry Reding
     [not found]                             ` <20120408142141.GA25303-RM9K5IK7kjIyiCvfTdI0JKcOhU4Rzj621B7CTYaBSLdn68oJJulU0Q@public.gmane.org>
2012-04-10  8:25                               ` Hiroshi Doyu
2012-04-05 18:36           ` Stephen Warren
2012-04-07  2:24   ` Grant Likely
2012-04-07 11:35     ` Thierry Reding
     [not found]       ` <20120407113510.GA22116-RM9K5IK7kjIQXX3q8xo1gnVAuStQJXxyR5q1nwbD4aMs9pC9oP6+/A@public.gmane.org>
2012-04-20  2:26         ` Grant Likely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120405084258.GA19798@avionic-0098.adnet.avionic-design.de \
    --to=thierry.reding-rm9k5ik7kjkj5m59nbduvrnah6klmebb@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.