Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2241219ybi; Sat, 13 Jul 2019 09:50:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDA0hOpqZf9D2hOshtevWMjjQYYeTxw8ijfipK/6LXdH0WvTsKYeIbhikAMOKmqyNDv+u6 X-Received: by 2002:a63:c342:: with SMTP id e2mr17472520pgd.79.1563036614897; Sat, 13 Jul 2019 09:50:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563036614; cv=none; d=google.com; s=arc-20160816; b=lsoGHW/ecHm57gQYjfF5DHSDV0xzI8POR9eIJmfbzrR3WhSNUITQwc6n5+YupjSsvE k84IbYWpp09eRPn+aENKj1wwYm+Cd3bDguWgPxg93pw7CWJ3ZcRYaqbeuHawebF5o5OK 5stFzPqNJWpUtN0uI6E13Mc+cW9GKdrFmdQj0bJTdNvFOYNe+E5ZjtpQjqY/uM7FBVUK fVADD4FJlMTZQA24K+d3PomJgCbLxd1C5XZgoZVKlZzjcpmPbFwTaGLRUqe1AxBXHKd7 8Q6gep9TSGGxM1Bf/lnuI1ImxWbGf4QvoGE1gJqjVwAo9eGNmnsl8wuOu+V49SyXag61 KNMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=sArqflmNJL+RuIvVxOB3J3vY2wGnGuNw/7ZgLpl13so=; b=zIumsPvS8cZYxfcH6ZWSp+VYnKjvPGzMx/SlyoV0usArPHfbumWjbrkfXd0NpfNf0P PBV0gfadn+z4QytOUlVO1uTUlrlv8uDZIUbtalwhn4UHosbEjQUQFMxyBWqDc+wdU9lg 4en+YzuD8vVtndrANKf+bI9Jbsm90pn2Ake0e6ZoU6V8utyo7ylkOoo4igQ0Q2Xk7ABV A5YFx9gQtlQNdi1PkXkYX5OdxIvfaPRhpHtQRyr/aSrLJhqdmDEP73Y3mDOL9dxpFHUl ae9wPqh8N4nWCuzLRTlqLt7JmThRz7kK1ky/Go7OmSJ9xNvR/9sCgyn5T0I8L6l1dkv1 iUbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=devoeaMs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z7si11331044pgj.223.2019.07.13.09.49.07; Sat, 13 Jul 2019 09:50:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=devoeaMs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727920AbfGMQld (ORCPT + 99 others); Sat, 13 Jul 2019 12:41:33 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:45571 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727656AbfGMQld (ORCPT ); Sat, 13 Jul 2019 12:41:33 -0400 Received: by mail-lj1-f194.google.com with SMTP id m23so12166049lje.12; Sat, 13 Jul 2019 09:41:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=sArqflmNJL+RuIvVxOB3J3vY2wGnGuNw/7ZgLpl13so=; b=devoeaMsOdiMqtIGKbsamYRcofxr5w6ek26oEfoD77/0Bc1QktLVOhmIRyH/FU4lL0 UmSTKR3FhWr+piAfw7c8FVf4kL10PnB6GMdc6I3Ih4AvZR3i70OKX/I6HGAI7LSOv4kN vFqZVQ7fJD4v/Hfwh2gy9dRjN1Y2xcrb6UjsTmunOmPsGmqtZxIpLMZVakc6ogGIpWjq q13pGG5YpXYDSxHi7gBAvZ6u266k4VDU/S8B2X/fg/X5lCe4XNNP1GrsyYyAbwKKA+lr hOd9FGBJv9YCzyYgHQoklmc8/d5pbZcxSif22u5rAKXGp9gugenwmFm0uXQPjv+jQ7yI XHWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=sArqflmNJL+RuIvVxOB3J3vY2wGnGuNw/7ZgLpl13so=; b=ZIdi0EYIZvE2uZ6a4BLcRk8pTdYT9T72LzY0WkdEQssAlo3JNSBDrpFB/uiNrpvyH3 9BC1BCLYhxbrF/De+GkGZBd2Ru9LZpE/tsUOaGHVg8Y3s0UqVxXFDwKEeTEzTGtpexWC jkWqydrw37AVkNlQn4CWbpoFRIzthYDghwCrCJkqkiKPhjw+DYVgB/yPqgzfcfOT+11d NmJiRqeT3dBYRr/AdjpZDYW6cdrZ3HkVN9CyCjo3WL6GTzX/tRapdDlZpAkLD4Mm/jCK 4q9EoSsxt/sH638W+zGr9mjN6n28Ng1u58uRRiQdeTw0CMQVO3bCavv62gQsZzHC++5d XkvQ== X-Gm-Message-State: APjAAAUeLTqWGJXpVGPco60ArbE9TVEp6BdxscGlbaJKfX1OCjlMiJT6 C4u/yLDQl4YiGIr8GTSlmQr+GM3t X-Received: by 2002:a2e:6348:: with SMTP id x69mr9311816ljb.186.1563036090359; Sat, 13 Jul 2019 09:41:30 -0700 (PDT) Received: from [192.168.2.145] (ppp79-139-233-208.pppoe.spdop.ru. [79.139.233.208]) by smtp.googlemail.com with ESMTPSA id b17sm2061980ljf.34.2019.07.13.09.41.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Jul 2019 09:41:29 -0700 (PDT) Subject: Re: [PATCH v1] drm/modes: Skip invalid cmdline mode To: Maxime Ripard Cc: Thierry Reding , Jonathan Hunter , Maarten Lankhorst , Sean Paul , Daniel Vetter , David Airlie , dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190710130615.gvi2jwgr2cds66xr@flea> <75719cad-c65c-7ebc-3ea8-98134f86ddc3@gmail.com> <4a13f12f-05a7-473e-4e4e-7a7e32d09720@gmail.com> <20190710140504.t5lsk36gnn5cdn6b@flea> <20190711090327.keuxt2ztfqecdbef@flea> <20190712081027.arybdoxr6nzrmkxt@flea> <686a20ce-e09a-037c-a5db-bd1309790c3e@gmail.com> <20190712195336.zgn5mseyfba2lfu7@flea> From: Dmitry Osipenko Message-ID: <523f1d21-333d-dd0f-c5fa-9a2a950d8bed@gmail.com> Date: Sat, 13 Jul 2019 19:41:28 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190712195336.zgn5mseyfba2lfu7@flea> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 12.07.2019 22:53, Maxime Ripard пишет: > On Fri, Jul 12, 2019 at 11:30:01AM +0300, Dmitry Osipenko wrote: >> 12.07.2019 11:10, Maxime Ripard пишет: >>> On Thu, Jul 11, 2019 at 06:55:03PM +0300, Dmitry Osipenko wrote: >>>> 11.07.2019 12:03, Maxime Ripard пишет: >>>>> On Wed, Jul 10, 2019 at 06:05:18PM +0300, Dmitry Osipenko wrote: >>>>>> 10.07.2019 17:05, Maxime Ripard пишет: >>>>>>> On Wed, Jul 10, 2019 at 04:29:19PM +0300, Dmitry Osipenko wrote: >>>>>>>> This works: >>>>>>>> >>>>>>>> diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c >>>>>>>> index 56d36779d213..e5a2f9c8f404 100644 >>>>>>>> --- a/drivers/gpu/drm/drm_client_modeset.c >>>>>>>> +++ b/drivers/gpu/drm/drm_client_modeset.c >>>>>>>> @@ -182,6 +182,8 @@ drm_connector_pick_cmdline_mode(struct drm_connector *connector) >>>>>>>> mode = drm_mode_create_from_cmdline_mode(connector->dev, cmdline_mode); >>>>>>>> if (mode) >>>>>>>> list_add(&mode->head, &connector->modes); >>>>>>>> + else >>>>>>>> + cmdline_mode->specified = false; >>>>>>> >>>>>>> Hmmm, it's not clear to me why that wouldn't be the case. >>>>>>> >>>>>>> If we come back to the beginning of that function, we retrieve the >>>>>>> cmdline_mode buffer from the connector pointer, that will probably >>>>>>> have been parsed a first time using drm_mode_create_from_cmdline_mode >>>>>>> in drm_helper_probe_add_cmdline_mode. >>>>>>> >>>>>>> Now, I'm guessing that the issue is that in >>>>>>> drm_mode_parse_command_line_for_connector, if we have a named mode, we >>>>>>> just copy the mode over and set mode->specified. >>>>>>> >>>>>>> And we then move over to do other checks, and that's probably what >>>>>>> fails and returns, but our drm_cmdline_mode will have been modified. >>>>>>> >>>>>>> I'm not entirely sure how to deal with that though. >>>>>>> >>>>>>> I guess we could allocate a drm_cmdline_mode structure on the stack, >>>>>>> fill that, and if successful copy over its content to the one in >>>>>>> drm_connector. That would allow us to only change the content on >>>>>>> success, which is what I would expect from such a function? >>>>>>> >>>>>>> How does that sound? >>>>>> >>>>>> I now see that there is DRM_MODE_TYPE_USERDEF flag that is assigned only >>>>>> for the "cmdline" mode and drm_client_rotation() is the only place in >>>>>> DRM code that cares about whether mode is from cmdline, hence looks like >>>>>> it will be more correct to do the following: >>>>> >>>>> I'm still under the impression that we're dealing with workarounds of >>>>> a more central issue, which is that we shouldn't return a partially >>>>> modified drm_cmdline_mode. >>>>> >>>>> You said it yourself, the breakage is in the commit changing the >>>>> command line parsing logic, while you're fixing here some code that >>>>> was introduced later on. >>>> >>>> The problem stems from assumption that *any* named mode is valid. It >>>> looks to me that the ultimate solution would be to move the mode's name >>>> comparison into the [1], if that's possible. >>>> >>>> [1] drm_mode_parse_command_line_for_connector() >>> >>> Well, one could argue that video=tegrafb is invalid and should be >>> rejected as well, but we haven't cleared that up. >> >> The video=tegrafb is invalid mode, there is nothing to argue here. And >> the problem is that invalid modes and not rejected for the very beginning. > > Yeah, I guess fb_get_options should also return an error in such a > case, but I'm a bit worried about the side effects here. At least the showstopper regression is fixed now. Everything else could be worked out later on. >>>>> Can you try the followintg patch? >>>>> http://code.bulix.org/8cwk4c-794565?raw >>>> >>>> This doesn't help because the problem with the rotation_reflection is >>>> that it's 0 if "rotation" not present in the cmdline and then ilog2(0) >>>> returns -1. So the patch "drm/modes: Don't apply cmdline's rotation if >>>> it wasn't specified" should be correct in any case. >>> >>> So we would have the same issue with rotate=0 then? >> >> No, we won't. Rotation mode is parsed into the DRM_MODE bitmask and >> rotate=0 corresponds to DRM_MODE_ROTATE_0, which is BIT(0) as you may >> notice. Hence rotation_reflection=0 is always an invalid value, meaning >> that "rotate" option does not present in the cmdline. Please consult the >> code, in particular see drm_mode_parse_cmdline_options() which was >> written by yourself ;) > > Sigh... You're right :) > > Sorry for that, I'll reply to the other patch Thank you very much.