From patchwork Wed Jun 5 08:47:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10976485 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5FBFF14E5 for ; Wed, 5 Jun 2019 08:47:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 505E928834 for ; Wed, 5 Jun 2019 08:47:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4444F28847; Wed, 5 Jun 2019 08:47:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DD09528834 for ; Wed, 5 Jun 2019 08:47:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D76788969E; Wed, 5 Jun 2019 08:47:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by gabe.freedesktop.org (Postfix) with ESMTPS id B00BA8969E for ; Wed, 5 Jun 2019 08:47:19 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id g135so1368295wme.4 for ; Wed, 05 Jun 2019 01:47:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Rot6iK92B6TEwBliOivir2gNRQvaPz5fEeAyYY+Fv5U=; b=uiasSvstXe2r1LJgFoJc3L4052oCtiKVO26oeTnyOeR1DGWxlHtMpjkLLs7BgG8FFK Yt7Fjdd/RaT0B+Ep4KmH3VirrWTifR65q7YRJ8v6YsVs9O8Ub+69uGZGmWCXAlrpbPyY UJ/0+0Kv4NX5vg2UTL6OyfjNJ6UHvfClquIfva093OPNxfPIj6+CjIjDZXwSv9G1t7hd e2G4IrCoZzvfzxN47/t757T9fzA9drCdsZ3GPuldStNITxGNOxCJhSOm+qJzfbTsMRab /W/rro4YQsg/Qavs60YbScejX5iEGTq0QEiDOUoAl1YjFDTmLuHugbQeX9j4XzspT86e p93g== X-Gm-Message-State: APjAAAVuYENQZzTjB60+O3cXiw/gVMuIwikyXIybDuw75Gfn920Z/kbI nsZO57h5XZvuplqdWaefsIw= X-Google-Smtp-Source: APXvYqxHuBz8WlxFDs/6ggHdHm3eReJjTdN+uN/413q5Rx2HKmix6KmFDMnx6dSgorOpRMKI2dMouQ== X-Received: by 2002:a1c:c74a:: with SMTP id x71mr21458623wmf.121.1559724438307; Wed, 05 Jun 2019 01:47:18 -0700 (PDT) Received: from localhost (p2E5BEF36.dip0.t-ipconnect.de. [46.91.239.54]) by smtp.gmail.com with ESMTPSA id u13sm5569575wrq.62.2019.06.05.01.47.17 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 05 Jun 2019 01:47:17 -0700 (PDT) From: Thierry Reding To: Thierry Reding Subject: [PATCH] gpu: host1x: Do not link logical devices to DT nodes Date: Wed, 5 Jun 2019 10:47:16 +0200 Message-Id: <20190605084716.12461-1-thierry.reding@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Rot6iK92B6TEwBliOivir2gNRQvaPz5fEeAyYY+Fv5U=; b=H6lYu/gqA4bVS+BSuV3Ewu/CQgV1E1fOiZZ7ZNviFIWlHbtG9Z/e11mAFVxaxB8hqv 5OMPyTex2Tk4QqMJpnNf4NO5rykhHCDgVLBG5SpYrOI98R29Gmer3I0oCu0qBxB/XI1f nCFXwCD8FnAvWy3BeJkBWpWg4Cziw2Rn5UBMfP6+dn8tulS8Vw5nXBBIVivimHumqRBG wdLYtmzPvQQQCRX+pr1bF7VZmlGomMypPzQ9WxgJZMCN00z+ls2WX6PR1YJ2dHIuhLNo CWMwVNflughjadeT8FA5ZfG3eqUUFESzCGZf97Tu25z9aU3MBtdEEwEYi5qnLTOq+Y4s hQZA== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding 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 --- drivers/gpu/host1x/bus.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index 6387302c1245..742aa9ff21b8 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c @@ -305,6 +305,36 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv) return strcmp(dev_name(dev), drv->name) == 0; } +static int host1x_device_uevent(struct device *dev, + struct kobj_uevent_env *env) +{ + struct device_node *np = dev->parent->of_node; + unsigned int count = 0; + struct property *p; + const char *compat; + + /* + * This duplicates most of of_device_uevent(), but the latter cannot + * be called from modules and operates on dev->of_node, which is not + * available in this case. + * + * Note that this is really only needed for backwards compatibility + * with libdrm, which parses this information from sysfs and will + * fail if it can't find the OF_FULLNAME, specifically. + */ + add_uevent_var(env, "OF_NAME=%pOFn", np); + add_uevent_var(env, "OF_FULLNAME=%pOF", np); + + of_property_for_each_string(np, "compatible", p, compat) { + add_uevent_var(env, "OF_COMPATIBLE_%u=%s", count, compat); + count++; + } + + add_uevent_var(env, "OF_COMPATIBLE_N=%u", count); + + return 0; +} + static int host1x_dma_configure(struct device *dev) { return of_dma_configure(dev, dev->of_node, true); @@ -322,6 +352,7 @@ static const struct dev_pm_ops host1x_device_pm_ops = { struct bus_type host1x_bus_type = { .name = "host1x", .match = host1x_device_match, + .uevent = host1x_device_uevent, .dma_configure = host1x_dma_configure, .pm = &host1x_device_pm_ops, }; @@ -408,7 +439,6 @@ static int host1x_device_add(struct host1x *host1x, device->dev.dma_mask = &device->dev.coherent_dma_mask; dev_set_name(&device->dev, "%s", driver->driver.name); device->dev.release = host1x_device_release; - device->dev.of_node = host1x->dev->of_node; device->dev.bus = &host1x_bus_type; device->dev.parent = host1x->dev;