From patchwork Tue Nov 30 23:09:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12648333 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1258DC433EF for ; Tue, 30 Nov 2021 23:10:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 57ECD6E53C; Tue, 30 Nov 2021 23:10:22 +0000 (UTC) Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4C85B6E226 for ; Tue, 30 Nov 2021 23:10:18 +0000 (UTC) Received: by mail-lj1-x22b.google.com with SMTP id e11so44130382ljo.13 for ; Tue, 30 Nov 2021 15:10:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PcErViLP1DIDDwbIDFXfn/iX9vhUyjqBs/0AKd7oEBs=; b=nhfNyeS2KxZtzLCKXh7Q/mC5AhcCIjlwjki3oBaz5iVnRc1B2PKCa+0/mur1FTkK7R 6BvsXjoeXbAdnfBfSuT6j4qhWZNTUm/YyzLNZCVIGac7LJiUfrpFY4oVh36jJ1MxHqdC FQ6J0MhQudWhBG5wyyewx5eAmO0QD0KFo6nlV9FMHXh21tOmj2u3Lr6DqRvDk0GctoUC gJhAMEfg96EHRzIwKCXy24+jMQv9jFTZ9VifomI+/hnefTsTR6WEO2nJ8J1uSDdDGW1P RU8HxlK9INAPCYcC4r5FlUnJw+nP8tvKoIVYzBY1mgD+G2dEGz5vMcaMs18SQs9yF4v/ p6Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PcErViLP1DIDDwbIDFXfn/iX9vhUyjqBs/0AKd7oEBs=; b=fGSVsspj3SwvAZ5l6lPOH6PFjlPzSnjS3gQgC9AuDQz9ALogbCAPdaxkAeIG4qWwkQ rcprqESl7grypZcTwWzR0vyfSk6GUXMDDFWBsEdijEyhf+uDeLvakVcsGoYOK2K4Z3TR w4ATFGsCJEZeJPZ3PHN/64QOX4lKNyIseA1eZdFYQgLj3QYayT1QGwKJhtLR3tIRmuZl 8M/uE9NrgmRX5Dt2kDtm1rl6vBpeBLCy8iVu7y7/exEaGRgzkfPujNshbvAMHr6LYeyj eO1eABT2MtOfFGYMybg2acOJV0G5gco1KWofRjDzvbt+cQTF1a1CDMCtsa8DmbBqZyXl gFAg== X-Gm-Message-State: AOAM533sRNB6YctqTboQW+dWc5Hk52i7nsco0ZQcNkBvGcntbQMGTbD8 /YLho8+OJjnNVE62fG6rDsoKVopR6+c= X-Google-Smtp-Source: ABdhPJxHJi9jFiUY61AH0tju8mnlgPmv2hvOnwCogGTzZpToN7zk2nX5gUAlriEvo+wsCbYon5Vsxg== X-Received: by 2002:a2e:908b:: with SMTP id l11mr1929554ljg.208.1638313816612; Tue, 30 Nov 2021 15:10:16 -0800 (PST) Received: from localhost.localdomain (94-29-46-111.dynamic.spd-mgts.ru. [94.29.46.111]) by smtp.gmail.com with ESMTPSA id k14sm2099846lfu.210.2021.11.30.15.10.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 15:10:16 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lyude Paul , David Airlie , Daniel Vetter , Thomas Graichen Subject: [PATCH v2 1/4] gpu/host1x: Add init/deinit callbacks to host1x driver framework Date: Wed, 1 Dec 2021 02:09:54 +0300 Message-Id: <20211130230957.30213-2-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211130230957.30213-1-digetx@gmail.com> References: <20211130230957.30213-1-digetx@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add init/deinit callbacks to host1x driver framework which allow to perform early pre-initialization required by Tegra DRM driver. Cc: # 5.13+ Signed-off-by: Dmitry Osipenko --- drivers/gpu/host1x/bus.c | 15 +++++++++++++++ include/linux/host1x.h | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index 0d81eede1217..25d688e5c742 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c @@ -479,8 +479,18 @@ static int host1x_device_add(struct host1x *host1x, device->dev.dma_parms = &device->dma_parms; dma_set_max_seg_size(&device->dev, UINT_MAX); + if (driver->init) { + err = driver->init(device); + if (err < 0) { + kfree(device); + return err; + } + } + err = host1x_device_parse_dt(device, driver); if (err < 0) { + if (driver->deinit) + driver->deinit(device); kfree(device); return err; } @@ -512,11 +522,16 @@ static int host1x_device_add(struct host1x *host1x, static void host1x_device_del(struct host1x *host1x, struct host1x_device *device) { + struct host1x_driver *driver = device->driver; + if (device->registered) { device->registered = false; device_del(&device->dev); } + if (driver->deinit) + driver->deinit(device); + put_device(&device->dev); } diff --git a/include/linux/host1x.h b/include/linux/host1x.h index e8dc5bc41f79..5e5ba33af4ae 100644 --- a/include/linux/host1x.h +++ b/include/linux/host1x.h @@ -346,6 +346,8 @@ struct host1x_device; * @driver: core driver * @subdevs: table of OF device IDs matching subdevices for this driver * @list: list node for the driver + * @init: called when the host1x logical driver is registered + * @deinit: called when the host1x logical driver is unregistered * @probe: called when the host1x logical device is probed * @remove: called when the host1x logical device is removed * @shutdown: called when the host1x logical device is shut down @@ -356,6 +358,8 @@ struct host1x_driver { const struct of_device_id *subdevs; struct list_head list; + int (*init)(struct host1x_device *device); + void (*deinit)(struct host1x_device *device); int (*probe)(struct host1x_device *device); int (*remove)(struct host1x_device *device); void (*shutdown)(struct host1x_device *device); From patchwork Tue Nov 30 23:09:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12648329 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BE0BBC433EF for ; Tue, 30 Nov 2021 23:10:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A49626E226; Tue, 30 Nov 2021 23:10:21 +0000 (UTC) Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by gabe.freedesktop.org (Postfix) with ESMTPS id 08FAB6E2C0 for ; Tue, 30 Nov 2021 23:10:19 +0000 (UTC) Received: by mail-lj1-x230.google.com with SMTP id k23so44305479lje.1 for ; Tue, 30 Nov 2021 15:10:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ERM173rnlxHrezuLhERWO1z/gEqXVXV1BN/+rag/gH0=; b=fT7ZcuoDV9WZYGw/uHvsPnUTdpRNLBvlyuoM8XwVN1CCP+NCv0cA+DMi5jZQ9+ipNx 1S0oCwCpgen+11NSKf2JTa1Gg7pRz62pb2DU1AeLY6buLkpmWHl2hp3g8ItGyz7tEfZ4 b+/iyIRZTqapPQUjrBe8/kr5+3lletoqNdk6YFV+E4a2qXjy3ChVfecrvduYkeOeSk6i heVrII1NQy537z8DpVMrimIjsqFdPRv1UBo1c0cRpUuh/DttCoTHoLMvK+ncfVC4+2F2 WySy03FD82cZwTYLMPL2sNOeO5Dvg3ZrDL0o8DoIJJB6HVwPT+g9m+sRHsJwKcpye/op vf8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ERM173rnlxHrezuLhERWO1z/gEqXVXV1BN/+rag/gH0=; b=w05AutPZAg0nh4YWrUieDe/CK34g693HJ3QHIxK1PH9mPQdxC7T57NTySbYB9PrsDH q+B1ujOCcKrJCYP0rImJy1h7zLhQryYXU1yza6TLwYwU0+jnT0IWSphfFzBlIa52UkFk lmEMF+fTPzTz5IKTYSywKwcOlsLmd5eZJOSbRQVtrtDHsp0JQzwY+kLVDCWmBQ5Odqms hG34GQ1K0m4/BIzM0dm5izJM4qtJqpoav9WurRlpjSQNbnCSG1BFQ11j1ueKqmTC/3hv HCljw8WAfi1dns5hGFnPrleRYIrquer/3SyAkXwCmjixziyV1Kz6hVmfYPGdHtO6wj1+ CnuA== X-Gm-Message-State: AOAM532wXJdczB4J/v/4y1BjNEengaue6uQy8BOsdCkK9XhYaeXe+ZX5 jWn94ERDx+ruPhklEXso2To= X-Google-Smtp-Source: ABdhPJy8OrwAMk/4qysO8j03czL6bhwBqxpZq7ekWf8/+UlGsG4xsttvr4RZlRJiCp7oHHxgfgLsIg== X-Received: by 2002:a2e:9708:: with SMTP id r8mr1957933lji.36.1638313817379; Tue, 30 Nov 2021 15:10:17 -0800 (PST) Received: from localhost.localdomain (94-29-46-111.dynamic.spd-mgts.ru. [94.29.46.111]) by smtp.gmail.com with ESMTPSA id k14sm2099846lfu.210.2021.11.30.15.10.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 15:10:17 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lyude Paul , David Airlie , Daniel Vetter , Thomas Graichen Subject: [PATCH v2 2/4] drm/tegra: Create DRM device early Date: Wed, 1 Dec 2021 02:09:55 +0300 Message-Id: <20211130230957.30213-3-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211130230957.30213-1-digetx@gmail.com> References: <20211130230957.30213-1-digetx@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" DRM sub-drivers need to access DRM device early during first stage of drivers' probing. Use new host1x init/deinit callbacks to create DRM device early and destroy late. Cc: # 5.13+ Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/tegra/drm.c | 46 ++++++++++++++++++++++++++----------- drivers/gpu/drm/tegra/drm.h | 2 ++ 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index e9de91a4e7e8..e9cbcaf6e017 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -1133,21 +1133,42 @@ static bool host1x_drm_wants_iommu(struct host1x_device *dev) return domain != NULL; } -static int host1x_drm_probe(struct host1x_device *dev) +static struct drm_device *terga_drm_dev; + +struct drm_device *tegra_drm_device(void) { - struct tegra_drm *tegra; - struct drm_device *drm; - int err; + return terga_drm_dev; +} - drm = drm_dev_alloc(&tegra_drm_driver, &dev->dev); +static int host1x_drm_dev_init(struct host1x_device *dev) +{ + struct drm_device *drm = drm_dev_alloc(&tegra_drm_driver, &dev->dev); if (IS_ERR(drm)) return PTR_ERR(drm); + dev_set_drvdata(&dev->dev, drm); + terga_drm_dev = drm; + + return 0; +} + +static void host1x_drm_dev_deinit(struct host1x_device *dev) +{ + struct drm_device *drm = dev_get_drvdata(&dev->dev); + + terga_drm_dev = NULL; + drm_dev_put(drm); +} + +static int host1x_drm_probe(struct host1x_device *dev) +{ + struct drm_device *drm = dev_get_drvdata(&dev->dev); + struct tegra_drm *tegra; + int err; + tegra = kzalloc(sizeof(*tegra), GFP_KERNEL); - if (!tegra) { - err = -ENOMEM; - goto put; - } + if (!tegra) + return -ENOMEM; if (host1x_drm_wants_iommu(dev) && iommu_present(&platform_bus_type)) { tegra->domain = iommu_domain_alloc(&platform_bus_type); @@ -1164,7 +1185,6 @@ static int host1x_drm_probe(struct host1x_device *dev) mutex_init(&tegra->clients_lock); INIT_LIST_HEAD(&tegra->clients); - dev_set_drvdata(&dev->dev, drm); drm->dev_private = tegra; tegra->drm = drm; @@ -1285,8 +1305,7 @@ static int host1x_drm_probe(struct host1x_device *dev) iommu_domain_free(tegra->domain); free: kfree(tegra); -put: - drm_dev_put(drm); + return err; } @@ -1319,7 +1338,6 @@ static int host1x_drm_remove(struct host1x_device *dev) } kfree(tegra); - drm_dev_put(drm); return 0; } @@ -1391,6 +1409,8 @@ static struct host1x_driver host1x_drm_driver = { .probe = host1x_drm_probe, .remove = host1x_drm_remove, .subdevs = host1x_drm_subdevs, + .init = host1x_drm_dev_init, + .deinit = host1x_drm_dev_deinit, }; static struct platform_driver * const drivers[] = { diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index fc0a19554eac..8b7c9508070f 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h @@ -121,6 +121,8 @@ int tegra_drm_unregister_client(struct tegra_drm *tegra, int host1x_client_iommu_attach(struct host1x_client *client); void host1x_client_iommu_detach(struct host1x_client *client); +struct drm_device *tegra_drm_device(void); + int tegra_drm_init(struct tegra_drm *tegra, struct drm_device *drm); int tegra_drm_exit(struct tegra_drm *tegra); From patchwork Tue Nov 30 23:09:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12648331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 39E68C433EF for ; Tue, 30 Nov 2021 23:10:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5414B6E2C0; Tue, 30 Nov 2021 23:10:22 +0000 (UTC) Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 96DF16E226 for ; Tue, 30 Nov 2021 23:10:20 +0000 (UTC) Received: by mail-lf1-x136.google.com with SMTP id u3so57882829lfl.2 for ; Tue, 30 Nov 2021 15:10:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vPO+bBApcxdA5y2Q3fy7ZINB3CJ88qaYAenQZvkSVDc=; b=JXF/9H/QlTPQRtSNPlU/aReawD8FLsfHSdZ5gWqyQa8IU4fTxXQ7exyba7eawM26o4 X7z5WN7JY97gds/BQfxNXJS1qZzAPx3rGhOLhM3lFvGE1oWic47rd24iUJOtVdABVhhv 3QSiyb6trhmK2lAwpPvh4VYHpf2g5qqBZfh4h+oFtrtWLFAUc/Ql/ucEUDBydbluy73X YE4tpMcFVC23KFQYhxDrlwS06Ex+ybN58CF6kPPSzGm1/MQGOPa3+XNRKZG+IynkZW+Q yOOE4PnB7ir0crR3J3Vq1YvpySGnsXR04OGFcsZ+cCb0FdwQ5fa3n7i/siyBvUnd4oCZ DoJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vPO+bBApcxdA5y2Q3fy7ZINB3CJ88qaYAenQZvkSVDc=; b=WTybVCW1LR1BOQLj310kgILVeivRse5DnrFEh6KJqbaNCKHpveldErTldH4zI+lc7M 3tQhglfvw9ghDGIVSmhxXseAOOxZM77+KFoIWTOAQomCwfkEUy5CMXU7rTNWH3Ao1pSu 3w2VAJhoHq4ZJ6B/cuHPWFjFbBWoJ8mWXoxyYU8Sf6u/GLeX/luwKwxdss3MQ7c5kAyO 3IZTXATOXxbm82QJvkuniPnp76vqA/uMYh9mfScOg3oEbk4RvEYJ0GszluHH9HLj883b 6F7DA7D37YTzXW5811KyPfEfT92uPmFXbLK3rpO2jPU170h9G9rAjJVo9wl/JV2l5Bzs C39A== X-Gm-Message-State: AOAM5338QlOg3gSkDHeEBHv+VRRnfTRvLlQljnuihcqWI49MUvEpPRjZ 8EItkLglivvisvPecte+b3Y= X-Google-Smtp-Source: ABdhPJzT82nM+GzSJsweT5whwKerGSgmA6VOGQpuf/7AVm3SkHRotqQ4zUKh+EsKIxErrvo3G/boJw== X-Received: by 2002:a05:6512:c17:: with SMTP id z23mr2105714lfu.175.1638313818970; Tue, 30 Nov 2021 15:10:18 -0800 (PST) Received: from localhost.localdomain (94-29-46-111.dynamic.spd-mgts.ru. [94.29.46.111]) by smtp.gmail.com with ESMTPSA id k14sm2099846lfu.210.2021.11.30.15.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 15:10:18 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lyude Paul , David Airlie , Daniel Vetter , Thomas Graichen Subject: [PATCH v2 3/4] drm/tegra: dpaux: Restore DP AUX DDC registration order Date: Wed, 1 Dec 2021 02:09:56 +0300 Message-Id: <20211130230957.30213-4-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211130230957.30213-1-digetx@gmail.com> References: <20211130230957.30213-1-digetx@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Restore DP AUX I2C DDC registration order by moving registration to DP AUX driver probe phase. This fixes broken display panel driver of Acer Chromebook CB5-311 that fails to probe starting with v5.13 kernel when DP AUX registration order was changed to prevent accessing uninitialized aux->drm_dev. Tegra SOR driver is never probed now using the new registration order because tegra-output always fails with -EPROBE_DEFER due to missing display panel that requires DP AUX DDC to be registered first. The offending commit made DDC to be registered after SOR's output, which can't ever happen. Use new tegra_drm_device() helper that allows to set aux->drm_dev during DP AUX probe, restoring the DCC registration order and reviving display panel. Cc: # 5.13+ Fixes: 39c17ae60ea9 ("drm/tegra: Don't register DP AUX channels before connectors") Reported-by: Thomas Graichen # T124 Nyan Big Tested-by: Thomas Graichen # T124 Nyan Big Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/tegra/dpaux.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c index 1f96e416fa08..148d3c00dd8e 100644 --- a/drivers/gpu/drm/tegra/dpaux.c +++ b/drivers/gpu/drm/tegra/dpaux.c @@ -530,9 +530,12 @@ static int tegra_dpaux_probe(struct platform_device *pdev) disable_irq(dpaux->irq); dpaux->aux.transfer = tegra_dpaux_transfer; + dpaux->aux.drm_dev = tegra_drm_device(); dpaux->aux.dev = &pdev->dev; - drm_dp_aux_init(&dpaux->aux); + err = drm_dp_aux_register(&dpaux->aux); + if (err < 0) + goto put_pm; /* * Assume that by default the DPAUX/I2C pads will be used for HDMI, @@ -544,7 +547,7 @@ static int tegra_dpaux_probe(struct platform_device *pdev) */ err = tegra_dpaux_pad_config(dpaux, DPAUX_PADCTL_FUNC_I2C); if (err < 0) - return err; + goto dp_aux_unreg; #ifdef CONFIG_GENERIC_PINCONF dpaux->desc.name = dev_name(&pdev->dev); @@ -557,7 +560,8 @@ static int tegra_dpaux_probe(struct platform_device *pdev) dpaux->pinctrl = devm_pinctrl_register(&pdev->dev, &dpaux->desc, dpaux); if (IS_ERR(dpaux->pinctrl)) { dev_err(&pdev->dev, "failed to register pincontrol\n"); - return PTR_ERR(dpaux->pinctrl); + err = PTR_ERR(dpaux->pinctrl); + goto dp_aux_unreg; } #endif /* enable and clear all interrupts */ @@ -571,6 +575,14 @@ static int tegra_dpaux_probe(struct platform_device *pdev) mutex_unlock(&dpaux_lock); return 0; + +dp_aux_unreg: + drm_dp_aux_unregister(&dpaux->aux); +put_pm: + pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); + + return err; } static int tegra_dpaux_remove(struct platform_device *pdev) @@ -579,6 +591,8 @@ static int tegra_dpaux_remove(struct platform_device *pdev) cancel_work_sync(&dpaux->work); + drm_dp_aux_unregister(&dpaux->aux); + /* make sure pads are powered down when not in use */ tegra_dpaux_pad_power_down(dpaux); @@ -717,11 +731,6 @@ int drm_dp_aux_attach(struct drm_dp_aux *aux, struct tegra_output *output) unsigned long timeout; int err; - aux->drm_dev = output->connector.dev; - err = drm_dp_aux_register(aux); - if (err < 0) - return err; - output->connector.polled = DRM_CONNECTOR_POLL_HPD; dpaux->output = output; @@ -759,7 +768,6 @@ int drm_dp_aux_detach(struct drm_dp_aux *aux) unsigned long timeout; int err; - drm_dp_aux_unregister(aux); disable_irq(dpaux->irq); if (dpaux->output->panel) { From patchwork Tue Nov 30 23:09:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12648335 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 698D8C433F5 for ; Tue, 30 Nov 2021 23:10:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD7A16E544; Tue, 30 Nov 2021 23:10:31 +0000 (UTC) Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6C7816E226 for ; Tue, 30 Nov 2021 23:10:21 +0000 (UTC) Received: by mail-lj1-x234.google.com with SMTP id m12so6077752ljj.6 for ; Tue, 30 Nov 2021 15:10:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jcG5eW0FrkUy1abf1a09oWGeCDTmXxu7iElTZZhQRA0=; b=NzoFGdoxPTaslzF822nf8oyVEuMKLmIi+AcHqT2Mdh2m5Bz6iwT3XMOZP4H7UZ9xhF OonzE15T6vJxXp9Ipe+LX5fSFXqzr1eJENDcenTSz+vki/FV4YGC1Lm+wNqnI4yNuKZn COzxRh2PevDRaxLAIv9z7dNJI1rFX9aEsnyXNvxwhcznkhtDXupYbNSy1Ea3J21IGsUq bXhONaB0uDWU999cZN5IQ/2XGHGBZ9ZSfbk2VzMnz+H9DpcgqqntLa3IoXjCO+nfKvJt xhSbuaaXNXnq1xdF5oFc18y3k9xw/2dPITruLg6CE+OyT1vmRNjmwtu1cMyGhvvOGmb4 YUVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jcG5eW0FrkUy1abf1a09oWGeCDTmXxu7iElTZZhQRA0=; b=1LInhxge67h3JaDJN1oORFe7aFf/CpFqcMbc9GBvvtl9KyabOYMtgLebp+WU4yJxB0 NPd3H5TpehPNRt500+pqFXvGtQUCZaAg4QpGvweZbP1m6BsZbrfz7h1ZrkXnWmLD4O2q a6fkrCBhDEXbT3drH5iRLYJoGnz94YIHyZn0IXrg91Rr9xc4Wn+ErISgSDC16gcb4jFW nIxjMuLMxQao2S/BrSVTalYda0dRny0C156LbQVc43Pblqo0crsO171ml6oIoPKoiRPI Om9yFU02tkFQFtG4/lJwTZW6aA/8R3ilLtShuAgulBERHzRX1Q8uQ48SmQIYBQRXmdwX UJLQ== X-Gm-Message-State: AOAM532hn5epjTtOiwKsD8al+hDtV+WH2gaIyKG+ug39oAFnxc+GI/nv phxtvLemXmioA6ErxwNUfEY= X-Google-Smtp-Source: ABdhPJzIB1kqtQQtgiFwg3vHfHbAzcAzg49NJGrFYgMGqiBoL+OGU+k5JSm9LcGe9snMnLIvuZVjlA== X-Received: by 2002:a2e:2a46:: with SMTP id q67mr1914801ljq.398.1638313819819; Tue, 30 Nov 2021 15:10:19 -0800 (PST) Received: from localhost.localdomain (94-29-46-111.dynamic.spd-mgts.ru. [94.29.46.111]) by smtp.gmail.com with ESMTPSA id k14sm2099846lfu.210.2021.11.30.15.10.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 15:10:19 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lyude Paul , David Airlie , Daniel Vetter , Thomas Graichen Subject: [PATCH v2 4/4] drm/tegra: Use dev_err_probe() Date: Wed, 1 Dec 2021 02:09:57 +0300 Message-Id: <20211130230957.30213-5-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211130230957.30213-1-digetx@gmail.com> References: <20211130230957.30213-1-digetx@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Replace dev_printk() with a generic dev_err_probe() helper which silences noisy error messages about deferred probe and makes easy to debug failing deferred probe by printing notification about the failure to KMSG in the end of kernel booting process and by adding failing device and the reason of deferred probe to devices_deferred of debugfs. This was proven to be useful in the case of eDP driver regression by immediately showing why display driver was failing when user asked for help, otherwise it would've been much more difficult to debug such problems on a third party device that doesn't have developer setup. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/tegra/dc.c | 13 +++---------- drivers/gpu/drm/tegra/hdmi.c | 34 +++++++++------------------------- 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c index 7ea3c045a6f7..f7370d28816f 100644 --- a/drivers/gpu/drm/tegra/dc.c +++ b/drivers/gpu/drm/tegra/dc.c @@ -3236,16 +3236,9 @@ static int tegra_dc_probe(struct platform_device *pdev) return -ENXIO; err = tegra_dc_rgb_probe(dc); - if (err < 0 && err != -ENODEV) { - const char *level = KERN_ERR; - - if (err == -EPROBE_DEFER) - level = KERN_DEBUG; - - dev_printk(level, dc->dev, "failed to probe RGB output: %d\n", - err); - return err; - } + if (err < 0 && err != -ENODEV) + return dev_err_probe(&pdev->dev, err, + "failed to probe RGB output\n"); platform_set_drvdata(pdev, dc); pm_runtime_enable(&pdev->dev); diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c index 9a87d351a828..3242baddc5e7 100644 --- a/drivers/gpu/drm/tegra/hdmi.c +++ b/drivers/gpu/drm/tegra/hdmi.c @@ -1638,7 +1638,6 @@ static irqreturn_t tegra_hdmi_irq(int irq, void *data) static int tegra_hdmi_probe(struct platform_device *pdev) { - const char *level = KERN_ERR; struct tegra_hdmi *hdmi; struct resource *regs; int err; @@ -1678,36 +1677,21 @@ static int tegra_hdmi_probe(struct platform_device *pdev) hdmi->hdmi = devm_regulator_get(&pdev->dev, "hdmi"); err = PTR_ERR_OR_ZERO(hdmi->hdmi); - if (err) { - if (err == -EPROBE_DEFER) - level = KERN_DEBUG; - - dev_printk(level, &pdev->dev, - "failed to get HDMI regulator: %d\n", err); - return err; - } + if (err) + return dev_err_probe(&pdev->dev, err, + "failed to get HDMI regulator\n"); hdmi->pll = devm_regulator_get(&pdev->dev, "pll"); err = PTR_ERR_OR_ZERO(hdmi->pll); - if (err) { - if (err == -EPROBE_DEFER) - level = KERN_DEBUG; - - dev_printk(level, &pdev->dev, - "failed to get PLL regulator: %d\n", err); - return err; - } + if (err) + return dev_err_probe(&pdev->dev, err, + "failed to get PLL regulator\n"); hdmi->vdd = devm_regulator_get(&pdev->dev, "vdd"); err = PTR_ERR_OR_ZERO(hdmi->vdd); - if (err) { - if (err == -EPROBE_DEFER) - level = KERN_DEBUG; - - dev_printk(level, &pdev->dev, - "failed to get VDD regulator: %d\n", err); - return err; - } + if (err) + return dev_err_probe(&pdev->dev, err, + "failed to get VDD regulator\n"); hdmi->output.dev = &pdev->dev;