Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpu: host1x: Do not link logical devices to DT nodes

Logical devices created by the host1x bus infrastructure don't need to
be associated with a device tree node. Doing so will cause the driver
core to attempt to hook up IOMMU operations and fail because it is not
a real device.

However, for backwards-compatibility, we need to provide various OF_*
uevent variables that were previously provided by of_device_uevent() and
which are parsed by libdrm in userspace when querying the available
devices. Do this by implementing a uevent callback for the host1x bus.

Signed-off-by: Thierry Reding <treding@nvidia.com>

+31 -1
+31 -1
drivers/gpu/host1x/bus.c
··· 316 316 return strcmp(dev_name(dev), drv->name) == 0; 317 317 } 318 318 319 + static int host1x_device_uevent(struct device *dev, 320 + struct kobj_uevent_env *env) 321 + { 322 + struct device_node *np = dev->parent->of_node; 323 + unsigned int count = 0; 324 + struct property *p; 325 + const char *compat; 326 + 327 + /* 328 + * This duplicates most of of_device_uevent(), but the latter cannot 329 + * be called from modules and operates on dev->of_node, which is not 330 + * available in this case. 331 + * 332 + * Note that this is really only needed for backwards compatibility 333 + * with libdrm, which parses this information from sysfs and will 334 + * fail if it can't find the OF_FULLNAME, specifically. 335 + */ 336 + add_uevent_var(env, "OF_NAME=%pOFn", np); 337 + add_uevent_var(env, "OF_FULLNAME=%pOF", np); 338 + 339 + of_property_for_each_string(np, "compatible", p, compat) { 340 + add_uevent_var(env, "OF_COMPATIBLE_%u=%s", count, compat); 341 + count++; 342 + } 343 + 344 + add_uevent_var(env, "OF_COMPATIBLE_N=%u", count); 345 + 346 + return 0; 347 + } 348 + 319 349 static int host1x_dma_configure(struct device *dev) 320 350 { 321 351 return of_dma_configure(dev, dev->of_node, true); ··· 363 333 struct bus_type host1x_bus_type = { 364 334 .name = "host1x", 365 335 .match = host1x_device_match, 336 + .uevent = host1x_device_uevent, 366 337 .dma_configure = host1x_dma_configure, 367 338 .pm = &host1x_device_pm_ops, 368 339 }; ··· 450 419 device->dev.dma_mask = &device->dev.coherent_dma_mask; 451 420 dev_set_name(&device->dev, "%s", driver->driver.name); 452 421 device->dev.release = host1x_device_release; 453 - device->dev.of_node = host1x->dev->of_node; 454 422 device->dev.bus = &host1x_bus_type; 455 423 device->dev.parent = host1x->dev; 456 424