From patchwork Wed May 16 10:15:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 10403545 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C0D35601D2 for ; Wed, 16 May 2018 10:23:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AEB872886D for ; Wed, 16 May 2018 10:23:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A31C52886F; Wed, 16 May 2018 10:23:35 +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=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 08E5F2886D for ; Wed, 16 May 2018 10:23:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WkyiQX7Wm+HxoJo9tkrR8sQ1utTQRIxJ0Tnu1/15jTA=; b=pH0uyRzmv16cSD zwFFpHea+saLYBoHzmbgMrOlCyP6Zs4t9TW/o9rc/mEXLENGJBbIQjnHvuvnkHEC7QEGkzverb4Pa QE6Vu+edCHmkoSjnv/yrDdBZSFmE9/7qv4gWnn9xRJGOhB9OWnOdH81/y6WXuJ7xUeaXsg8KZxraD 5o7xwwwbXmOmpKVGe93LhlpVU0SW46gYN6ZfaRVlaYwUEbE4QvbTj7Nsxiaw5DvSWSSb+QirtWlPA MH5BFa7TrHOk1eMK7kU3UdMWEH9/4wDcvSF9Y2wyB1giwyJJOktAIx3grLTY/oghN6iHUIfe5jFZJ TcVTn7eXy9ikqlLg6XsQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fItae-00088S-3i; Wed, 16 May 2018 10:23:24 +0000 Received: from mail-he1eur01on0098.outbound.protection.outlook.com ([104.47.0.98] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fItUR-0003Pu-QX; Wed, 16 May 2018 10:17:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentia.se; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jbFOjMsV/9ur2NDLJrTHsNfqTwqgMcAcGTValWPXCDs=; b=i4uKDBhO6ehs19/4rz9quG6GeXkjy0obhBbFjE+4dUuMF5bbWENEGL0/GxATNB456G2mrfqWQ8ror3Cao9E8DBZWCjqHuU8RezI+eMGNgkg5DcLmXkbbyNxzKEzacKK5hMXFIXWZ8EOL7hzeIcrHS43/TSWWZRTXl2P+TcLFjg4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; Received: from orc.pedanet (85.226.244.23) by AM4PR0202MB2772.eurprd02.prod.outlook.com (2603:10a6:200:8c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.776.11; Wed, 16 May 2018 10:16:51 +0000 From: Peter Rosin To: linux-kernel@vger.kernel.org Subject: [PATCH v3 26/26] drm/bridge: establish a link between the bridge supplier and consumer Date: Wed, 16 May 2018 12:15:10 +0200 Message-Id: <20180516101510.13215-27-peda@axentia.se> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180516101510.13215-1-peda@axentia.se> References: <20180516101510.13215-1-peda@axentia.se> MIME-Version: 1.0 X-Originating-IP: [85.226.244.23] X-ClientProxiedBy: HE1PR0102CA0013.eurprd01.prod.exchangelabs.com (2603:10a6:7:14::26) To AM4PR0202MB2772.eurprd02.prod.outlook.com (2603:10a6:200:8c::22) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(7021125)(5600026)(4534165)(7022125)(4603075)(4627221)(201702281549075)(7048125)(7024125)(7027125)(7028125)(7023125)(2017052603328)(7153060)(7193020); SRVR:AM4PR0202MB2772; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0202MB2772; 3:B6iEsG6Ui9mwILQ+6JThpIc4voHNlUEgm36z+LObdyCAQPgAlk/X5RF2zuvTXRX0Sm8saUi7VK5e9lh1/AKvEQ6DMSFhai4iz4L7O/mm5MsoJzzVXEGQRgAnoVmwEOI8ld7ROdKks9mIMyGQjQ6+1ZDQ3AoWF6TH+6i3PQ2cAfmTFHGwuTeMBixM8dCeA/bO5WpoXh+EsvhKt4d8hrg0uUOFRZGmObsm5Pom4bo9loNxvAuqRSBbhIYfQNRIbGqC; 25:SKkw9spLOmiiPOZLo4uYovrCBG0KuTcQRO8A1u6CMp2LX2FBSr+a5BIP00mU/O9z7RMzHVF/bw1t0wz1qapE0349hq2uzpPcJtd7UMyVNn5TW/LDjpPapwRlm0738expCPzHkcezDUzUMiJd+TjcTDNd/q79vVLHcLFqkYcKD3fjrfUc5w1cGfHy/ImhwD6Ftgnc6pWx0LPF2V2FV5lGNITV4mMFAhW9ysQDFvQ6Mh4FsTjodrCiUJbLUPWjZpoai+b26UuazD67FNlHIER0UsFkcGCvEEHKLaf00hzmYNmavyWMwJJVtbyI0aZFtlRDsp5vwsg7XCiUak8mQLeTZw==; 31:+18sawP+B51kx9z1e1umwFymbQC/i7zIs3Y2kdb0R47T3VTXeB5RvODjdy7Xtx5f56G1g96okS1Sdca2C87hapHWgLpaE0JwTIEd6HLlKSf8yBH226kBWQiMCFeCGBAq5HtNnvCMKYdr0F8eqUdcNPkCKFMEkUqhaezkC2XSGAIjJp/jDPqYUlLE39Lk8hX74QmF/hyW7FxBP5jatQzPJGcJs3Jw7l1rYUz19U0i2co= X-MS-TrafficTypeDiagnostic: AM4PR0202MB2772: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(7411616537696); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3231254)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(149027)(150027)(6041310)(2016111802025)(20161123558120)(20161123562045)(20161123560045)(20161123564045)(6072148)(6043046)(201708071742011); SRVR:AM4PR0202MB2772; BCL:0; PCL:0; RULEID:; SRVR:AM4PR0202MB2772; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0202MB2772; 4:2etWGnmRDOJB1xxjef7EeSP7dg/x0WyQmFX1HmMni0gXCi7tkodf+K60rgzufbxznRNLudr1P1dftqE2JPZBR5nr+Fsm+X6lG8XgCPFLq4Y/VIqULGU/j56u1tAlvi+wmC+CoH8Q+lLmHhY+y0WkSzVVskWy4C9dUA9CtUOuRCyvZmXF3R6s/vnn9K9EQjY96iQRN6jXmKQpcvJ7CcWExWOdWXQx0fOHj93lt1MvEi4YBwf5N5efrIEx0mjFxLfrlXPknh38N6rRkGu1pJrQ30Uaf0lNY8tuFhGw0MszW9P7xOOcsna6sESavcB3whI2 X-Forefront-PRVS: 0674DC6DD3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(39380400002)(396003)(346002)(376002)(39840400004)(366004)(189003)(199004)(86362001)(7416002)(25786009)(48376002)(50466002)(68736007)(36756003)(2906002)(105586002)(97736004)(6666003)(6916009)(74482002)(7406005)(2351001)(3846002)(6116002)(575784001)(1076002)(478600001)(106356001)(316002)(16586007)(2361001)(7736002)(50226002)(53936002)(6512007)(305945005)(51416003)(8936002)(52116002)(8676002)(16526019)(76176011)(446003)(66066001)(5660300001)(39060400002)(5890100001)(54906003)(47776003)(81156014)(476003)(2616005)(956004)(81166006)(186003)(386003)(6506007)(26005)(4326008)(11346002)(486006)(6486002)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:AM4PR0202MB2772; H:orc.pedanet; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: axentia.se does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR0202MB2772; 23:a5S923tRNY39QVWSBKs/1063nOeG7NuI0q2c0Yp?= =?us-ascii?Q?Cdf/trtVPiqeUmIdc50pyX9E2HCK6vhmSZ0AkaNPp0D2J7bE6pDLp/4xECng?= =?us-ascii?Q?/aiZPAll+8DRMo4IiVTDJDWXC+P0OmKb8NOlQfUgHzmY8LZhdUBmF3oCLrt4?= =?us-ascii?Q?xK1UACGkESl0nzo/Iia9qTtcSmcNzh1FN42Hc+65dBXKtJj78mQFcT1i4qVe?= =?us-ascii?Q?VnAYyNqscQa/qLdsBDuSqTgDbYn6Wb3w7QvvA0WxsS0BHnhX68XQCIJCq/Ly?= =?us-ascii?Q?/nBk6XWSQgZ0KgI7xenTlpbqCyz6JuBaB660lf43GTSZFa/CrwMFK6bdVLQM?= =?us-ascii?Q?f2FB9+PAuPSWAVU0SlWnAEVQ71SYRoq6GGNJasM8GOpYcQ0qRZhkWchBj1tM?= =?us-ascii?Q?G5ZF2rv00SjJhs3v2XiF8RcFiQSmhtGozaUuwq0ftLpTNGdzjEajA29XX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GZIWinIhsA32lYHnL0+zQVW5Nj0?= =?us-ascii?Q?3w6NlnqGYNDzQ9+/4w01d3YeEUbVCLFw7Q7Xe27N1ZNVoyXzKZs8uAVko+hf?= =?us-ascii?Q?wGdoFYcTPRg=3D=3D?= X-Microsoft-Antispam-Message-Info: HoZEJeSvWihxEZ4VLdPSys7wJc5tCDn6lcKZRfVodsRqC7iUzFusKU1FHoMlUf6erkTOaZh3QNiMJEmTBO9Cw5bo3vycVUYJi9L9375nLH1LNk9C3Mg/U166EK05vDNt/MXswjYE8GmSPVfXT151xFILgHEMDoUBl2at+QzPDtSTW+Z1bf4NGxdMgVaWsSha X-Microsoft-Exchange-Diagnostics: 1; AM4PR0202MB2772; 6:LlEcwoeIEWxy7ILT4Db6IxaAT/5iFswyYX4ExRCAPOi6ceIhLAgZZgr65iC8XBDY+GREJj0dqifAXtF6KDUGcUueSv+9FVkPoSYGMKojUg0SM7y+Fn6wNgBzUvSlI3PlAWYNoJpO5MPpISv/b8HlN09DTzFZBh7YM/b5oNHRYCHIkElP1R0uhXaKHnkES11itfujPq59mxqsuRZbE6RhR3NNBs7U7ndbfgmU3MY49GRSWIc3WeT9k/84T4NviETuOtmXweazanoJ7Bao4op2GrM8DAfynde1whJoOnpszvnmwnyG5fkgM1AeVK8XUrhn6oE304QtcB1AeDfRmpQuSo/L2JqQIV2q4DY5mmiwSPCKnczhUeH87QuxYALUbCagQkD7CKKJuWhB3V2ptLqtmC9TKjvUgoq7defy5nBP+vcKZUgfLurScfhVgkhpTo6M/dQE0ngAEn3ohjW446UnfA==; 5:+0TZTNXmL0TDOIa9jNHmykp1exRqlhdOMfFUyCCI95yI5Ybe0MoN0Y2TdwCirny3jINCxQDQSFw5FYUbWMk3Hl1R/E8fTrDDvr9nsOD8GACe5/cKqETA6SgQ3J9FP83nALcgAKTyScWuVHecAo0GCm299k/iHFsvWb8t7hLixCA=; 24:+CU5X3Y3IfBFpYWuf+XcQVmm1pdhN/Icphb9mDTu4Er4XCTcO5ZqFhhtQCJ3afiYssbih07DvwURjzVSKrhpqthR2/j+BqZqSOqO5xCi+cU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM4PR0202MB2772; 7:A+oSDJdwjfreFJyWDvlW7qpqa3ozG6Jgx2DMTsfqv0Ix51NXGLaVvr8MrIOCZ/FQTmx1lkSLsZeVbPP7yjxOJdIG3jAX2wpRieJ2gMCj65Kw/RPaDFWW3etpo2bgmHNiaSAMGKw47bPbt59udGc6iUW1ckrsfQJxQPuz0+5GfX/QghuzyCA4cJCPkQzc0f5C378Qs58VK8XOfmhlRcpYzch2o+AqbfL+Qm+hzkFYmUkA1ImVDyUyr3tfLv9gyegk X-MS-Office365-Filtering-Correlation-Id: 2cf72349-95c1-428f-6834-08d5bb1625c8 X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2018 10:16:51.9661 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2cf72349-95c1-428f-6834-08d5bb1625c8 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4ee68585-03e1-4785-942a-df9c1871a234 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0202MB2772 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180516_031700_002736_CEEB3568 X-CRM114-Status: GOOD ( 14.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martyn Welch , David Airlie , Gustavo Padovan , dri-devel@lists.freedesktop.org, Andrzej Hajda , Laurent Pinchart , Benjamin Gaignard , =?UTF-8?q?Heiko=20St=C3=BCbner?= , Archit Taneja , linux-samsung-soc@vger.kernel.org, Joonyoung Shim , Kyungmin Park , Krzysztof Kozlowski , linux-rockchip@lists.infradead.org, Kukjin Kim , CK Hu , Martin Donnelly , Daniel Vetter , linux-arm-msm@vger.kernel.org, Maarten Lankhorst , Jyri Sarha , Inki Dae , Sean Paul , Matthias Brugger , Vincent Abriou , linux-arm-kernel@lists.infradead.org, Seung-Woo Kim , Sandy Huang , linux-renesas-soc@vger.kernel.org, Rob Clark , Philipp Zabel , linux-mediatek@lists.infradead.org, freedreno@lists.freedesktop.org, Peter Rosin Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If the bridge supplier is unbound, this will bring the bridge consumer down along with the bridge. Thus, there will no longer linger any dangling pointers from the bridge consumer (the drm_device) to some non-existent bridge supplier. Reviewed-by: Andrzej Hajda Acked-by: Daniel Vetter Signed-off-by: Peter Rosin --- drivers/gpu/drm/drm_bridge.c | 18 ++++++++++++++++++ include/drm/drm_bridge.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index 78d186b6831b..0259f0a3ff27 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -26,6 +26,7 @@ #include #include +#include #include #include "drm_crtc_internal.h" @@ -127,12 +128,25 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, if (bridge->dev) return -EBUSY; + if (encoder->dev->dev != bridge->odev) { + bridge->link = device_link_add(encoder->dev->dev, + bridge->odev, 0); + if (!bridge->link) { + dev_err(bridge->odev, "failed to link bridge to %s\n", + dev_name(encoder->dev->dev)); + return -EINVAL; + } + } + bridge->dev = encoder->dev; bridge->encoder = encoder; if (bridge->funcs->attach) { ret = bridge->funcs->attach(bridge); if (ret < 0) { + if (bridge->link) + device_link_del(bridge->link); + bridge->link = NULL; bridge->dev = NULL; bridge->encoder = NULL; return ret; @@ -159,6 +173,10 @@ void drm_bridge_detach(struct drm_bridge *bridge) if (bridge->funcs->detach) bridge->funcs->detach(bridge); + if (bridge->link) + device_link_del(bridge->link); + bridge->link = NULL; + bridge->dev = NULL; } diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index b656e505d11e..bd1265c5a0bc 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -261,6 +261,7 @@ struct drm_bridge_timings { * @list: to keep track of all added bridges * @timings: the timing specification for the bridge, if any (may * be NULL) + * @link: device link between the drm consumer and the bridge supplier * @funcs: control functions * @driver_private: pointer to the bridge driver's internal context */ @@ -271,6 +272,7 @@ struct drm_bridge { struct drm_bridge *next; struct list_head list; const struct drm_bridge_timings *timings; + struct device_link *link; const struct drm_bridge_funcs *funcs; void *driver_private;