From patchwork Wed Oct 23 14:49:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11206973 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D361112B for ; Wed, 23 Oct 2019 14:50:09 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 358A721906 for ; Wed, 23 Oct 2019 14:50:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 358A721906 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F2316EAEF; Wed, 23 Oct 2019 14:50:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by gabe.freedesktop.org (Postfix) with ESMTPS id 04F626EAEF for ; Wed, 23 Oct 2019 14:50:05 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id v6so2962813wmj.0 for ; Wed, 23 Oct 2019 07:50:04 -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=TgNcxEwD/Rw+XsHHUoWKtnyQ7Kd75vAYAE7l7GYdjMw=; b=AGse6qR0JHoz1uyiPLZZ3RPdM+SNGhHIQDRU1HY1j4XNPxzcF+DpbArqENfxZO9jV4 uNyR03cTE/o/XZgujRaSfOylXv6LM+T4J32rHzfF+HublfgPTRK29OAlSChkY+VlCQFO DVWXCdLYKnh0X2iH2WWVqxLsOo7/8dSIv4GLVmVWahzo1v7rs9ZrULnnM5aV4FOi296s AGidh0DmXUUzDaoq9oE82sZ/VMUL62A8HQmJ2asSwFmpdNUz2WFonp5yEYASik7wpf2d yy+lyGLbkG4x/76DT/msroiazC1fI4eEZwdkyA6ZOvUYYeXmtgebUtokIbKkdBBv2wwd l/Vg== X-Gm-Message-State: APjAAAUh87O1yEnxGFjif76QJPw/01j3ZdxzF/U2TMxjaSW45WAmVfm3 sG2I9xZ+bvBudtLgIP5IOH3a75Oic18= X-Google-Smtp-Source: APXvYqxBybYZhBzgCwl8sjJ1UHbUbu9xiERzLdeA22Nqrezpw1E1ihlJAn/cLHEHT8CYvoFqDh8h8Q== X-Received: by 2002:a1c:dd06:: with SMTP id u6mr261130wmg.109.1571842202346; Wed, 23 Oct 2019 07:50:02 -0700 (PDT) Received: from phenom.ffwll.local (212-51-149-96.fiber7.init7.net. [212.51.149.96]) by smtp.gmail.com with ESMTPSA id z125sm29614190wme.37.2019.10.23.07.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 07:49:59 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 1/2] drm/property: Enforce more lifetime rules Date: Wed, 23 Oct 2019 16:49:52 +0200 Message-Id: <20191023144953.28190-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TgNcxEwD/Rw+XsHHUoWKtnyQ7Kd75vAYAE7l7GYdjMw=; b=WGzE7qffBMivLCljiUXSRqpVN97SZOL/56BMB9CMFOMsN0qHEJRDyLLPJpmGZ6OUiW P4Vf/TDutlZKpZLOz8HwOWTfTjkMKWBlnm6xmFq4ZYgPblEV+uWiu2vsQacqkTymj+6U dnVIX/7SAFgNX8tHFNpel1YTG23II2Pb673/k= 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: Daniel Vetter , Intel Graphics Development , Rajat Jain , Daniel Vetter Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Properties can't be attached after registering, userspace would get confused (no one bothers to reprobe really). - Add kerneldoc - Enforce this with some checks. This needs a somewhat ugly check since connectors can be added later on, but we still need to attach all properties before they go public. Note that we already enforce that properties themselves are created before the entire device is registered. Cc: Jani Nikula Cc: Rajat Jain Signed-off-by: Daniel Vetter Reviewed-by: Thierry Reding Reviewed-by: Jani Nikula --- drivers/gpu/drm/drm_mode_object.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c index 6a23e36ed4fe..35c2719407a8 100644 --- a/drivers/gpu/drm/drm_mode_object.c +++ b/drivers/gpu/drm/drm_mode_object.c @@ -224,12 +224,26 @@ EXPORT_SYMBOL(drm_mode_object_get); * This attaches the given property to the modeset object with the given initial * value. Currently this function cannot fail since the properties are stored in * a statically sized array. + * + * Note that all properties must be attached before the object itself is + * registered and accessible from userspace. */ void drm_object_attach_property(struct drm_mode_object *obj, struct drm_property *property, uint64_t init_val) { int count = obj->properties->count; + struct drm_device *dev = property->dev; + + + if (obj->type == DRM_MODE_OBJECT_CONNECTOR) { + struct drm_connector *connector = obj_to_connector(obj); + + WARN_ON(!dev->driver->load && + connector->registration_state == DRM_CONNECTOR_REGISTERED); + } else { + WARN_ON(!dev->driver->load && dev->registered); + } if (count == DRM_OBJECT_MAX_PROPERTY) { WARN(1, "Failed to attach object property (type: 0x%x). Please " From patchwork Wed Oct 23 14:49:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11206977 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8535B13BD for ; Wed, 23 Oct 2019 14:50:12 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6D95E21906 for ; Wed, 23 Oct 2019 14:50:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D95E21906 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 109026EAF6; Wed, 23 Oct 2019 14:50:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by gabe.freedesktop.org (Postfix) with ESMTPS id 86EA76EAF5 for ; Wed, 23 Oct 2019 14:50:08 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id 3so19965661wmi.3 for ; Wed, 23 Oct 2019 07:50:08 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=hI++rq87/vzhhNCoiGKRBhfGgl78W1Dui9zd3x/qQ6w=; b=hcJmMIdfdX7GQlcsYSRON5uKRkNX5xMDZI2QZ8hjPL4UUS8yIC0/jFPcMJuEVBgrP4 wWWRDarP4/kpE0do80sZLvUaGT90MFKBJ8a5De5lj9my0xc9pwS0jFjbNP4mTW25do/x /xhUIZM9rinkiBpi7VUHbNTxWtvvMenaAyqFa/PCzilpjE3wyuMAU4ueZja+tWCLTsbs aDdwyfWwBrBUINC4a6poIDhFNC78fP+EE9EWL3NnPDoczfxTdmmVNcuTXtGH+9j8I69k 63HlFGzXYrWOyIYl5sUO3rMnjLVmD1tdA1kqHWmgZnQfIdUTyI/SXMOLhWLNiOIp93PH zmMQ== X-Gm-Message-State: APjAAAV7rMDs0Y2QmcR0RSjGHzCEwTGvkVkC5RhgKrxPoTasUCWumcsE /qla4+PpudYASyfPyGy4Y75y2pDk1iI= X-Google-Smtp-Source: APXvYqz6SKA1161CLMMgJ+Bb7B3GJ2UJet2eQgt0IepdWzg0DsNtFTJCakql9yy/ZLRrb4nH2k81nA== X-Received: by 2002:a1c:7401:: with SMTP id p1mr267890wmc.144.1571842205591; Wed, 23 Oct 2019 07:50:05 -0700 (PDT) Received: from phenom.ffwll.local (212-51-149-96.fiber7.init7.net. [212.51.149.96]) by smtp.gmail.com with ESMTPSA id z125sm29614190wme.37.2019.10.23.07.50.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 07:50:02 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 2/2] drm/todo: Add entry to remove load/unload hooks Date: Wed, 23 Oct 2019 16:49:53 +0200 Message-Id: <20191023144953.28190-2-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023144953.28190-1-daniel.vetter@ffwll.ch> References: <20191023144953.28190-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hI++rq87/vzhhNCoiGKRBhfGgl78W1Dui9zd3x/qQ6w=; b=T5ZB9xenAjjIIKo5qRh3lmAZbur2qrfnZtFve4tLR8MQANz2jUmcpDG3iSzhQJBkBH aSPzPD+ZjNBnZEFJ6stEhPneyEMQdLFxQ+L8c9q0/KmsgxpwYvY+L5sz8mxo6igX3/47 a80RXwxP5ZraAz1L4j+T9YOG8W6AcHFP9o35Q= 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: Alex Deucher , Daniel Vetter , Intel Graphics Development , Daniel Vetter Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" They're midlayer, broken, and because of the old gunk, we can't fix them. For examples see the various checks in drm_mode_object.c against dev->registered, which cannot be enforced if the driver still uses the load hook. Unfortunately our biggest driver still uses load/unload, so this would be really great to get fixed. Cc: Alex Deucher Cc: Harry Wentland Signed-off-by: Daniel Vetter Reviewed-by: Thierry Reding --- Documentation/gpu/todo.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst index 73c51b5a0997..5a44f46380c2 100644 --- a/Documentation/gpu/todo.rst +++ b/Documentation/gpu/todo.rst @@ -351,6 +351,23 @@ connector register/unregister fixes Level: Intermediate +Remove load/unload callbacks from all non-DRIVER_LEGACY drivers +--------------------------------------------------------------- + +The load/unload callbacks in struct &drm_driver are very much midlayers, plus +for historical reasons they get the ordering wrong (and we can't fix that) +between setting up the &drm_driver structure and calling drm_dev_register(). + +- Rework drivers to no longer use the load/unload callbacks, directly coding the + load/unload sequence into the driver's probe function. + +- Once all non-DRIVER_LEGACY drivers are converted, disallow the load/unload + callbacks for all modern drivers. + +Contact: Daniel Vetter + +Level: Intermediate + Core refactorings =================