From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8BE01CCEE7 for ; Thu, 26 Dec 2024 13:07:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735218456; cv=none; b=h1Q88uJbbaAV+fbTfqlDgr4T2AO9gLTEgXpwKjEebsgZqUCJNpRX5Z7ie89h3/bAqmGqvfa1Npe/pMOOBVK+NP0cVftrMDXtS4zl7jgvcNjXYONcfGf/ZIzshGwJOnPjNcu+pYBd7QMAbiDYvVp1QUn3KXJLC7ACMTM+JpNpWlc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735218456; c=relaxed/simple; bh=MaHDssHaNRMvy91h6r5mdzuZmUVHBeRvIY+1wGSWJAA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=A9gnZrbEZdvxT80l8TGjSX3NaLHrJq/m3/TVgiChEvJl7CuuHkf48tyK6hD3UmH5DFYwdCwwwBSZSk4EWKVZXgRY2RJC/zNUxJ3P3+8u/4WZL3R4naCrZYTEWfZdGiO3RShN2tcfik2Gl1VhS8kT+PPun+iyB39D/16gxZi4diE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=hqqonSAu; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hqqonSAu" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4361fe642ddso68009505e9.2 for ; Thu, 26 Dec 2024 05:07:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735218451; x=1735823251; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2xYN5a7hOoppgoAE3bkR8Zunji5zT+kUi/AFcDG3CeI=; b=hqqonSAuQGlNGIfoBKb+UNNhD0cEzOx0fu1BsB6lacANDx5E6tRfN7YNJ55y9qR1wD oCV5z/8biRzKqHOrhJ1ZDyxBH9lgSxLIEvThAOPE20pcO3NrV69gK5uMyGM3BkAwyWaI K3obVsH+rngjU3hLxeG4kS7k41nr7IgqQCFSLBIiV2j0yDcZE8VEot11G1XqNJEXASyD 79EjuXoAUXe0YbYDcJNAnmTpffB9EW+C5r72e89JgPsn9VLVEDFFUhHPpqjNiHnzi887 auZbm+YssS98EcVupLILXen8OhjPJzIWBDEp13IeLCJghZJEd1m+R+KfwAr7JiazHAV7 y1Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735218451; x=1735823251; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2xYN5a7hOoppgoAE3bkR8Zunji5zT+kUi/AFcDG3CeI=; b=CVwO5Rr9aF/cI+tqp302eMnegGa1e80KQhWxe2aEyOm5L6J/sKA/oxDPToYga0LLeJ ljBfFsMse0woR6A6Uleq3Ddzlf2aaLtefY+bFgGYMoPVff0uPlnydXbTAdTAIzsTPFuW GrxTxOLLCd/ZWSnLlnH1Da1K6ptBdz63mFiy4cBIWR8bnH2Bh7uiropfmlOPKzGCBeo1 SII39YSRjElksi8DRWTR3ObfCAnVgWlCh20x3EmP0eoaLUC25PjLKu48amtm1au7a3TQ VMUwU46HiCzBGoCFHoktx9wn+GSOYAMBLxiQcnoT0HkFQMQl6rM0vE+vdKMb2Cy37b8c xuvw== X-Forwarded-Encrypted: i=1; AJvYcCWhUgP80HMw+7h3WRE1d0UMFdijjnZ8noWAaywH7DmrmJUAbK2rBOT4fiTBvfrTByUxiaPUCdkxn1nj83g=@vger.kernel.org X-Gm-Message-State: AOJu0Yxcn4zTevbPwJTJq8izpxbEjD2pPquF4TFgnQqchWrD3Iv+OYko Ktu/Op8TnHlSCLlXtUXRmuCObNA5GGWkGKTXSN05haKVN0ThsfP213EuevQ7z68= X-Gm-Gg: ASbGncvoWoNa8Qxq+T0hnTf266b8NlJlrb8IGmKk02EgivNhltOIX+Q1F+CUuhnuj3J aB6EPNog1LchGQ9BFm5iC95EPulqtEg8Icy8BOU1F5LA9VAgaUEzYe6ksGRRS99CDLpiVoFEL+g Kkcaqs64ao3c0KVOk/yMjcTL6pnqceuiZ0V+l5UC6xfKfnLMVunIkdjM4ZNEmcQsbzUgeARCkuN C1DpaFQ6sefWGFWTERxxAMIlEv8v209J1kfq2EpYR/3jEG61k5Xy+w= X-Google-Smtp-Source: AGHT+IGvNY9x8znPid+jlSUugq+7Voy4lhkFD150p7UMeaZJEhSIyuzOQxvdWb877xCzmOFRcxCZRA== X-Received: by 2002:a05:600c:4f11:b0:435:9ed3:5698 with SMTP id 5b1f17b1804b1-43668b5e09bmr177464715e9.24.1735218451158; Thu, 26 Dec 2024 05:07:31 -0800 (PST) Received: from linaro.org ([82.76.168.176]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4364a376846sm264591185e9.0.2024.12.26.05.07.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Dec 2024 05:07:29 -0800 (PST) Date: Thu, 26 Dec 2024 15:07:27 +0200 From: Abel Vesa To: Johan Hovold Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Karol Herbst , Lyude Paul , Danilo Krummrich , Jani Nikula , Rodrigo Vivi , Joonas Lahtinen , Tvrtko Ursulin , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , Bjorn Andersson , Konrad Dybcio , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org Subject: Re: [PATCH v2 1/4] drm/dp: Add helper to set LTTPRs in transparent mode Message-ID: References: <20241211-drm-dp-msm-add-lttpr-transparent-mode-set-v2-0-d5906ed38b28@linaro.org> <20241211-drm-dp-msm-add-lttpr-transparent-mode-set-v2-1-d5906ed38b28@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On 24-12-11 15:42:27, Johan Hovold wrote: > On Wed, Dec 11, 2024 at 03:04:12PM +0200, Abel Vesa wrote: > > > +/** > > + * drm_dp_lttpr_set_transparent_mode - set the LTTPR in transparent mode > > + * @aux: DisplayPort AUX channel > > + * @enable: Enable or disable transparent mode > > + * > > + * Returns 0 on success or a negative error code on failure. > > + */ > > +int drm_dp_lttpr_set_transparent_mode(struct drm_dp_aux *aux, bool enable) > > +{ > > + u8 val = enable ? DP_PHY_REPEATER_MODE_TRANSPARENT : > > + DP_PHY_REPEATER_MODE_NON_TRANSPARENT; > > + int ret = drm_dp_dpcd_writeb(aux, DP_PHY_REPEATER_MODE, val); > > + > > + return ret == 1 ? 0 : ret; > > This looks correct, but I had to go look at drm_dp_dpcd_writeb() to make > sure it never returns 0 (for short transfers). Will follow Dmitry's proposal here. if (ret < 0) return ret; return (ret == 1) ? 0 : -EIO; > > > +} > > +EXPORT_SYMBOL(drm_dp_lttpr_set_transparent_mode); > > This appears to be what the driver currently uses, but why not > EXPORT_SYMBOL_GPL? > > > + > > +/** > > + * drm_dp_lttpr_init - init LTTPR transparency mode according to DP standard > > + * > > + * @aux: DisplayPort AUX channel > > + * @lttpr_count: Number of LTTPRs > > + * > > + * Returns 0 on success or a negative error code on failure. > > + */ > > +int drm_dp_lttpr_init(struct drm_dp_aux *aux, int lttpr_count) > > +{ > > + if (!lttpr_count) > > + return 0; > > + > > + /* > > + * See DP Standard v2.0 3.6.6.1 about the explicit disabling of > > + * non-transparent mode and the disable->enable non-transparent mode > > + * sequence. > > + */ > > + drm_dp_lttpr_set_transparent_mode(aux, true); > > Error handling? Yes, this makes sense. But other than throwing an error I don't think there is much to be done. I'll add an drm_err here just in case. > > > + > > + if (lttpr_count > 0 && !drm_dp_lttpr_set_transparent_mode(aux, false)) > > No need to check lttpr_count again here. So the logic behind lttpr_count and this transparency mode changing, as specified in the DP standard, is as follows: - If there are 0 LTTPRs counted, then nothing to be done, otherwise set to transparent mode. - Then, if there are between 0 and 8 LTTPRs counted, set non-transparent mode successfully. - Otherwise, rollback to transparent mode. This last rollback might result in two transparent mode settings without a non-transparent one in between, but AFAIU, that is OK. Making sure this doesn't happen would just make the implementation more ugly without any benefit, IMO. > > > + return 0; > > I'd check for errors instead of success here and do the rollback before > returning -EINVAL. > Yes, I think it would be more cleaner. Will do that. > > + > > + /* > > + * Roll-back to tranparent mode if setting non-tranparent mode failed or > > + * the number of LTTPRs is invalid > > + */ > > + drm_dp_lttpr_set_transparent_mode(aux, true); > > + > > + return -EINVAL; > > And return 0 explicitly here. Yes. Will do that. > > > +} > > +EXPORT_SYMBOL(drm_dp_lttpr_init); > > In any case this works well and is needed for external display on the > Lenovo ThinkPad T14s, while not breaking the X13s which does not need > it: > > Tested-by: Johan Hovold > > Johan Thanks for reviewing and testing! Abel