From patchwork Fri Jan 17 08:56:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 858524 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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 60C461F9AB6 for ; Fri, 17 Jan 2025 08:56:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737104209; cv=none; b=MbXCqz4V1MnEkPm2X8Ayi2EK+IwrTaP65yyzpMBZlDMABdaCl2kgBlz1uzdV4Vv9kO7FYnmn+DecJN7qMqPV4ajgSHZMRV5AyeDUSgCyjHRHLTgmGpPmPKm+2igcmvwvHvqduxV1CmqFwcZUqFKAMxHjZs0se4pr+CsgTH/eaEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737104209; c=relaxed/simple; bh=DNcZKhPphZjqikPskSkFBsKleO9AnJ+79jeieCaJFks=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tHb0MajIOBhtDV/3FYFBHdfk6Uvk2Nog2NHAjXeo3CajKwGuhaJ96F8dFPihfHW9PcVm0CaYxF7O55o91eEG4sl5IUduMmDM8JBpiaTIrTYZ2S3BTvDmkpLXcqLV04Iwb2sXuBknmjWGAZscJpbmhiyzFIFbvKP1J+pqbEskfXk= 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=kG9ZyQFD; arc=none smtp.client-ip=209.85.208.173 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="kG9ZyQFD" Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-3061513d353so18493391fa.2 for ; Fri, 17 Jan 2025 00:56:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737104205; x=1737709005; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Uw0PYTWvXGZN0XXOXiRMt4CYqzLIv8o5kdoflMTCxBQ=; b=kG9ZyQFDkMuqku8wW7yFiFnwb7fYLD7hWGQePYvX+w7v/ZnFcpV31FuzVGa0e0eENp 98bG2IrXgYJ3VEtsa39wjHuEvRwIaNAoRG3ERJm2lWEfWAF3eaqmeGVw33DVC6Z7oCJC CowZIuxcAM1uLTBb4HC9H+ZLzHwc1piCkhHpA01y4UJ/meHgvk7qtj5NaJm4TQ7Qx1Zt TBmVcTs0eNkQGhbeDbMVlL67dV/jJ6H/q/2+dr9frrhDInh3Stxl9aNGwvYn9HVbbnz9 HGIufyscpHWaHg8w4Nay/v9F++JoW0ggyrbQb8MVez0Yhma0jHev+UNYhKWVVH++N6Wb yKHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737104205; x=1737709005; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Uw0PYTWvXGZN0XXOXiRMt4CYqzLIv8o5kdoflMTCxBQ=; b=ceH2qQNSnX7CuQl9qt7qNqwA+Q3mutW24paLmUXR77qw2eOCk2yi3fFRXP11IfKMVo CqccBxLhF7s4O8BZeelUq5qgd88ITiA+vwMeqc0a1J7s4Cy1M7HVuiiimehZ8Kj1sYaN /RGG69T47ttwj0FSg9zLkdl61ISm876D5bQASDm7k7PLkhc6BhdTCmkSISGN2Y+3VDja iM7dhTZM4mMJUaRgP5SN1T4C3LJ+spH4Iu0Qtj56OCy0c1w8KwcB9P8CO7tD6Sv/+2vL fxOk4tL1hqI/PK3kPitPFtc3tUq2O5HQtvzisRr6BmA/ryLtKC/4Y8VPNuPkh5NSHMz9 xd8g== X-Forwarded-Encrypted: i=1; AJvYcCXxlb30C80Hm6mmXxGb0AEj46/oZ2M8vMDSdGZKqlj5jaNFX76SIYgBq7/Zk5pb664+hF6ACBa+uzSsF9gm@vger.kernel.org X-Gm-Message-State: AOJu0YykKizrR3LsdwyBFQzqfoIZUuJ8QpZzfRCnuT1bRKfNf2EOtN/r QIvqNKf+AAc8FmnLbk5zIEjduV9RqTYTXbuEe9iI9ZJcCTphjp7RzMkVlErQaJQ= X-Gm-Gg: ASbGncup1Olnrl2tUzIYIFvfAwbDstxxFp/aKTE4//COxzmlOgL7uexBPkFfz0Fk4cY k+y/97gapvFLzSPUu7sLXsB2XOES9sKaUw01lfArEUgJfhl5MuK5M39tcW/o7SPB6vgIb23igIG KdxpGSBN/NiZpB/SU9JAQlyVE5OlbCYIYBxpKruM06dRhetAqpcvEAFweH84LZA9T+oQpAiYES4 1JXtmrhPqsdoImrMJ7w3XqrrT23h0hINChMnkXQLaYhWazxprJTU/z1ULfL18Ze X-Google-Smtp-Source: AGHT+IFAk4rF5mbTcFLJ/pbll3KPD/l3xZj5+xMa71cK6maSe664yCOXJyvv/2medmkgXq3KTeOyQQ== X-Received: by 2002:a2e:be9d:0:b0:300:3a15:8f2a with SMTP id 38308e7fff4ca-3072ca60c6amr6229501fa.2.1737104205372; Fri, 17 Jan 2025 00:56:45 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3072a330764sm3402101fa.3.2025.01.17.00.56.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 00:56:44 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 17 Jan 2025 10:56:37 +0200 Subject: [PATCH RFC 2/7] drm/display: dp: implement new access helpers Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-drm-rework-dpcd-access-v1-2-7fc020e04dbc@linaro.org> References: <20250117-drm-rework-dpcd-access-v1-0-7fc020e04dbc@linaro.org> In-Reply-To: <20250117-drm-rework-dpcd-access-v1-0-7fc020e04dbc@linaro.org> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , Jani Nikula Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=13606; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=DNcZKhPphZjqikPskSkFBsKleO9AnJ+79jeieCaJFks=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnihtFIXi+twbKEsS8KONvOTAmsgTtU1stn+Zwo wPjeaMkxciJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ4obRQAKCRCLPIo+Aiko 1QrxB/4kdGoIrc9ZoWP4S+0v06FxENqP2AoN/Eo5N2Yanu3ft4rAkCW7cWFMPIeYLNbaCt7ElRp v46dzWBk8wXZ68gkjUGcbXJvwx3eftPA2gSgDXVe4eQjD3VJs2KoO4lWt03xxqBmTquhQktTcLK zAnK+JLtMatCDVWlVFqXbHtiSfMlYKobvdLKLUlR3taIyxWy9GG6bkPFIB1BWwo9ON9xGp0en+L MTi0kQwOq3zmU/sPZJ2wK0Bf+GQns4/e0fdZIeobmpqv1H67x52IhHiFmFNcHR9kIdGsAQnr0ha GJYpPeGZZSs6ffTBTP83y1g8UyJfBB/bTJ6z+GVSPvlguGWL X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Existing DPCD access functions return an error code or the number of bytes being read / write in case of partial access. However a lot of drivers either (incorrectly) ignore partial access or mishandle error codes. In other cases this results in a boilerplate code which compares returned value with the size. Implement new set of DPCD access helpers, which ignore partial access, always return 0 or an error code. Implement existing helpers using the new functions to ensure backwards compatibility. Suggested-by: Jani Nikula Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/display/drm_dp_helper.c | 42 +++++++------- drivers/gpu/drm/display/drm_dp_mst_topology.c | 27 +++++---- include/drm/display/drm_dp_helper.h | 81 ++++++++++++++++++++++++++- include/drm/display/drm_dp_mst_helper.h | 10 ++-- 4 files changed, 119 insertions(+), 41 deletions(-) diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c index 809c65dcb58983693fb335b88759a66919410114..5a693f2779284467e2d05b9d8b2c2bee0ad6c112 100644 --- a/drivers/gpu/drm/display/drm_dp_helper.c +++ b/drivers/gpu/drm/display/drm_dp_helper.c @@ -495,13 +495,13 @@ EXPORT_SYMBOL(drm_dp_bw_code_to_link_rate); static inline void drm_dp_dump_access(const struct drm_dp_aux *aux, - u8 request, uint offset, void *buffer, int ret) + u8 request, uint offset, void *buffer, size_t size, int ret) { const char *arrow = request == DP_AUX_NATIVE_READ ? "->" : "<-"; - if (ret > 0) + if (ret == 0) drm_dbg_dp(aux->drm_dev, "%s: 0x%05x AUX %s (ret=%3d) %*ph\n", - aux->name, offset, arrow, ret, min(ret, 20), buffer); + aux->name, offset, arrow, ret, min_t(int, size, 20), buffer); else drm_dbg_dp(aux->drm_dev, "%s: 0x%05x AUX %s (ret=%3d)\n", aux->name, offset, arrow, ret); @@ -559,8 +559,10 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request, if (ret >= 0) { native_reply = msg.reply & DP_AUX_NATIVE_REPLY_MASK; if (native_reply == DP_AUX_NATIVE_REPLY_ACK) { - if (ret == size) + if (ret == size) { + ret = 0; goto unlock; + } ret = -EPROTO; } else @@ -602,9 +604,9 @@ int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset) int ret; ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, &buffer, 1); - WARN_ON(ret == 0); + WARN_ON(ret == -EPROTO); - drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, &buffer, ret); + drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, &buffer, 1, ret); return ret < 0 ? ret : 0; } @@ -634,21 +636,21 @@ void drm_dp_dpcd_set_powered(struct drm_dp_aux *aux, bool powered) EXPORT_SYMBOL(drm_dp_dpcd_set_powered); /** - * drm_dp_dpcd_read() - read a series of bytes from the DPCD + * drm_dp_dpcd_read_data() - read a series of bytes from the DPCD * @aux: DisplayPort AUX channel (SST or MST) * @offset: address of the (first) register to read * @buffer: buffer to store the register values * @size: number of bytes in @buffer * - * Returns the number of bytes transferred on success, or a negative error + * Returns zero (0) on success, or a negative error * code on failure. -EIO is returned if the request was NAKed by the sink or * if the retry count was exceeded. If not all bytes were transferred, this * function returns -EPROTO. Errors from the underlying AUX channel transfer * function, with the exception of -EBUSY (which causes the transaction to * be retried), are propagated to the caller. */ -ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset, - void *buffer, size_t size) +int drm_dp_dpcd_read_data(struct drm_dp_aux *aux, unsigned int offset, + void *buffer, size_t size) { int ret; @@ -671,45 +673,45 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset, } if (aux->is_remote) - ret = drm_dp_mst_dpcd_read(aux, offset, buffer, size); + ret = drm_dp_mst_dpcd_read_data(aux, offset, buffer, size); else ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, buffer, size); - drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, buffer, ret); + drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, buffer, size, ret); return ret; } -EXPORT_SYMBOL(drm_dp_dpcd_read); +EXPORT_SYMBOL(drm_dp_dpcd_read_data); /** - * drm_dp_dpcd_write() - write a series of bytes to the DPCD + * drm_dp_dpcd_write_data() - write a series of bytes to the DPCD * @aux: DisplayPort AUX channel (SST or MST) * @offset: address of the (first) register to write * @buffer: buffer containing the values to write * @size: number of bytes in @buffer * - * Returns the number of bytes transferred on success, or a negative error + * Returns zero (0) on success, or a negative error * code on failure. -EIO is returned if the request was NAKed by the sink or * if the retry count was exceeded. If not all bytes were transferred, this * function returns -EPROTO. Errors from the underlying AUX channel transfer * function, with the exception of -EBUSY (which causes the transaction to * be retried), are propagated to the caller. */ -ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset, - void *buffer, size_t size) +int drm_dp_dpcd_write_data(struct drm_dp_aux *aux, unsigned int offset, + void *buffer, size_t size) { int ret; if (aux->is_remote) - ret = drm_dp_mst_dpcd_write(aux, offset, buffer, size); + ret = drm_dp_mst_dpcd_write_data(aux, offset, buffer, size); else ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_WRITE, offset, buffer, size); - drm_dp_dump_access(aux, DP_AUX_NATIVE_WRITE, offset, buffer, ret); + drm_dp_dump_access(aux, DP_AUX_NATIVE_WRITE, offset, buffer, size, ret); return ret; } -EXPORT_SYMBOL(drm_dp_dpcd_write); +EXPORT_SYMBOL(drm_dp_dpcd_write_data); /** * drm_dp_dpcd_read_link_status() - read DPCD link status (bytes 0x202-0x207) diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c b/drivers/gpu/drm/display/drm_dp_mst_topology.c index f8cd094efa3c0bd6f75b52a0410b0910d8026a76..f8db5be53a33e87e94b864ba48151354e091f5aa 100644 --- a/drivers/gpu/drm/display/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c @@ -2128,20 +2128,20 @@ drm_dp_port_set_pdt(struct drm_dp_mst_port *port, u8 new_pdt, } /** - * drm_dp_mst_dpcd_read() - read a series of bytes from the DPCD via sideband + * drm_dp_mst_dpcd_read_data() - read a series of bytes from the DPCD via sideband * @aux: Fake sideband AUX CH * @offset: address of the (first) register to read * @buffer: buffer to store the register values * @size: number of bytes in @buffer * * Performs the same functionality for remote devices via - * sideband messaging as drm_dp_dpcd_read() does for local + * sideband messaging as drm_dp_dpcd_read_data() does for local * devices via actual AUX CH. * - * Return: Number of bytes read, or negative error code on failure. + * Return: Zero (0) on success, or negative error code on failure. */ -ssize_t drm_dp_mst_dpcd_read(struct drm_dp_aux *aux, - unsigned int offset, void *buffer, size_t size) +int drm_dp_mst_dpcd_read_data(struct drm_dp_aux *aux, + unsigned int offset, void *buffer, size_t size) { struct drm_dp_mst_port *port = container_of(aux, struct drm_dp_mst_port, aux); @@ -2151,20 +2151,20 @@ ssize_t drm_dp_mst_dpcd_read(struct drm_dp_aux *aux, } /** - * drm_dp_mst_dpcd_write() - write a series of bytes to the DPCD via sideband + * drm_dp_mst_dpcd_write_data() - write a series of bytes to the DPCD via sideband * @aux: Fake sideband AUX CH * @offset: address of the (first) register to write * @buffer: buffer containing the values to write * @size: number of bytes in @buffer * * Performs the same functionality for remote devices via - * sideband messaging as drm_dp_dpcd_write() does for local + * sideband messaging as drm_dp_dpcd_write_data() does for local * devices via actual AUX CH. * - * Return: number of bytes written on success, negative error code on failure. + * Return: zero (0) on success, negative error code on failure. */ -ssize_t drm_dp_mst_dpcd_write(struct drm_dp_aux *aux, - unsigned int offset, void *buffer, size_t size) +int drm_dp_mst_dpcd_write_data(struct drm_dp_aux *aux, + unsigned int offset, void *buffer, size_t size) { struct drm_dp_mst_port *port = container_of(aux, struct drm_dp_mst_port, aux); @@ -3490,9 +3490,8 @@ static int drm_dp_send_dpcd_read(struct drm_dp_mst_topology_mgr *mgr, goto fail_free; } - ret = min_t(size_t, txmsg->reply.u.remote_dpcd_read_ack.num_bytes, - size); - memcpy(bytes, txmsg->reply.u.remote_dpcd_read_ack.bytes, ret); + memcpy(bytes, txmsg->reply.u.remote_dpcd_read_ack.bytes, size); + ret = 0; fail_free: kfree(txmsg); @@ -3530,7 +3529,7 @@ static int drm_dp_send_dpcd_write(struct drm_dp_mst_topology_mgr *mgr, if (txmsg->reply.reply_type == DP_SIDEBAND_REPLY_NAK) ret = -EIO; else - ret = size; + ret = 0; } kfree(txmsg); diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h index 8f4054a560396a43750570a8c2e95624039ab8ad..548237a81ef0359dab1ed7df6ef0fd1e0c76e0c5 100644 --- a/include/drm/display/drm_dp_helper.h +++ b/include/drm/display/drm_dp_helper.h @@ -522,10 +522,85 @@ struct drm_dp_aux { int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset); void drm_dp_dpcd_set_powered(struct drm_dp_aux *aux, bool powered); -ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset, - void *buffer, size_t size); -ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset, + +int drm_dp_dpcd_read_data(struct drm_dp_aux *aux, unsigned int offset, void *buffer, size_t size); +int drm_dp_dpcd_write_data(struct drm_dp_aux *aux, unsigned int offset, + void *buffer, size_t size); + +/** + * drm_dp_dpcd_read() - read a series of bytes from the DPCD + * @aux: DisplayPort AUX channel (SST or MST) + * @offset: address of the (first) register to read + * @buffer: buffer to store the register values + * @size: number of bytes in @buffer + * + * Deprecated wrapper around drm_dp_dpcd_read(). + * Returns the number of bytes transferred on success, or a negative error + * code on failure. + */ +static inline ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, + unsigned int offset, + void *buffer, size_t size) +{ + int ret = drm_dp_dpcd_read_data(aux, offset, buffer, size); + + if (ret < 0) + return ret; + + return size; +} + +/** + * drm_dp_dpcd_read_byte() - read a single byte from the DPCD + * @aux: DisplayPort AUX channel + * @offset: address of the register to read + * @valuep: location where the value of the register will be stored + * + * Returns zero (0) on success, or a negative error code on failure. + */ +static inline int drm_dp_dpcd_read_byte(struct drm_dp_aux *aux, + unsigned int offset, u8 *valuep) +{ + return drm_dp_dpcd_read_data(aux, offset, valuep, 1); +} + +/** + * drm_dp_dpcd_write_byte() - write a single byte to the DPCD + * @aux: DisplayPort AUX channel + * @offset: address of the register to write + * @value: value to write to the register + * + * Returns zero (0) on success, or a negative error code on failure. + */ +static inline int drm_dp_dpcd_write_byte(struct drm_dp_aux *aux, + unsigned int offset, u8 value) +{ + return drm_dp_dpcd_write_data(aux, offset, &value, 1); +} + +/** + * drm_dp_dpcd_write() - write a series of bytes from the DPCD + * @aux: DisplayPort AUX channel (SST or MST) + * @offset: address of the (first) register to write + * @buffer: buffer containing the values to write + * @size: number of bytes in @buffer + * + * Deprecated wrapper around drm_dp_dpcd_write(). + * Returns the number of bytes transferred on success, or a negative error + * code on failure. + */ +static inline ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, + unsigned int offset, + void *buffer, size_t size) +{ + int ret = drm_dp_dpcd_write_data(aux, offset, buffer, size); + + if (ret < 0) + return ret; + + return size; +} /** * drm_dp_dpcd_readb() - read a single byte from the DPCD diff --git a/include/drm/display/drm_dp_mst_helper.h b/include/drm/display/drm_dp_mst_helper.h index a80ba457a858f36ac2110a6fdd91d8a1570b58e1..d527b323a7a8c92b93280fcc8cd3025e21cdcf02 100644 --- a/include/drm/display/drm_dp_mst_helper.h +++ b/include/drm/display/drm_dp_mst_helper.h @@ -899,10 +899,12 @@ int __must_check drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr, bool sync); -ssize_t drm_dp_mst_dpcd_read(struct drm_dp_aux *aux, - unsigned int offset, void *buffer, size_t size); -ssize_t drm_dp_mst_dpcd_write(struct drm_dp_aux *aux, - unsigned int offset, void *buffer, size_t size); +int drm_dp_mst_dpcd_read_data(struct drm_dp_aux *aux, + unsigned int offset, + void *buffer, size_t size); +int drm_dp_mst_dpcd_write_data(struct drm_dp_aux *aux, + unsigned int offset, + void *buffer, size_t size); int drm_dp_mst_connector_late_register(struct drm_connector *connector, struct drm_dp_mst_port *port); From patchwork Fri Jan 17 08:56:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 858523 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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 068BD1F91EB for ; Fri, 17 Jan 2025 08:56:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737104215; cv=none; b=q6l26dvO4oV5M4/ZjHn2zKn6pU2iyfPSvQJVDdlESLUp8EC3MdMiUK9tPlDcMSUXDI7/cDq4FQ8BwSGpmzIh8ce/O9BQE8EKMe6Vmk4ZHRuPSPHUgQthlsni2d8nkad/zw4ej9Z4QHen3TiqiGcEmxUqOh2f8WvAh+ng3EMHmTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737104215; c=relaxed/simple; bh=u0enUT6rCyZ8RqHzkNWyQVgEzKAZFsn/cehDhTu72TM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WKcxy5KdM4Ds+D1RItrDtVKf9TZTFP3x5OokEoA9CKpTuoFLRgbsu0ueHcTASUhRZwjrftIWM1bJwGYR3CF9xsGfofD2m9RkCiYlXmbR2Z1ZB83q/iQlFkGWRRU2/CEdKTIcP/oytpUarlXIvUwZRQuKVMM+oPn6FAqCg6S5L4s= 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=nzcXJwBr; arc=none smtp.client-ip=209.85.208.179 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="nzcXJwBr" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-304d9a1f198so16536801fa.0 for ; Fri, 17 Jan 2025 00:56:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737104210; x=1737709010; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=VLM1E94zeSWa7OSuX8gMRqzReFqeBbOp8I7gc5sLd6w=; b=nzcXJwBrZWsPFgBWyCoOl4yP/dYPMUdPpzakPWvLjWZGT1/5dluGIpVUeKeQLvaHc4 xoivxhUYt09go/RMugsDtbN7hP89WP85FY1jnsdAieF4Qaw7jzG4oMCQ/64MoLCZEbe1 1fIeSzx4zcIXyG6idLT7uYCwvIwAS7d/IBmKzPaI9nd9HvzjIccfVdp2asANjia5ioJ4 kIYHSKXnDbLPnLmVP119AiCIp8TdNZURTUFMwpD095JrmZHdWoAc3d6Mgmf0dhckGhV3 sXeTvxWwtZDR6LZHWwbaTnU+DxliFHQ6HXLzg+QymjgewekZXgvD30+1ogCmGo7e1l2A 2PZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737104210; x=1737709010; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VLM1E94zeSWa7OSuX8gMRqzReFqeBbOp8I7gc5sLd6w=; b=uj/iWEZSeKzZjw+WQNnW2MCqU6Lw9Dz2fZO5TtYq2V4xcFfCUUGEGIOonDSOrN2m9W VYHsVIJtBHino3EnOKwSd8rE1wLFPfsSePrutvhZKvqraIbjw94kdFFY8/UGdx87yOxJ 9ryI0Kbtpx0fRx5z176200Q2ybs3Ef9AXTGJUTtOVOcAcLGLYuh3vShwMotbGaUVhJN/ Kfd8rWSEcaWXDoUo0MeXWvENd94Ukh5vjL8ey6zYxy/Xydl4PMqFTUTICI5V60hmvVKg 4kO3wv47OsXNbiNaWlriAFVSEBaH42TsImAM/LjLOGamUQQZfkIYAE5MY5/ml4jaKASo DipQ== X-Forwarded-Encrypted: i=1; AJvYcCX0dV3eprTTrHZAFGPth2HQFw7915O4Z5QgcQeT46M3l619bgyqEOoqRWOfOnyRFVvCI/BdteFqREa33rtD@vger.kernel.org X-Gm-Message-State: AOJu0YwlDLDzRSnER5FluTXOae3DPHWlFTI53Cc9epPaMuAJ7i+pnpJo 1P/lE1Pwakahx5/NF4bSlNn1rmdc+TVy29rB6Ljnz+giH2Jyh2aSzt4K5/zCCh0= X-Gm-Gg: ASbGncse66EG091pkEK2L8x6Q4pGUs8GgM0Xurk6Tx41Je0jQx26eJy6I/tdmWa2mZw 4jcDOIO35w4SHjfvPxQeADwksu/olF1x72LuRPX9Ov3OhRTiFDRQb0BkpHQfyeyuJGOZrArydOr S6Ukpfrdfnw7Kd3VRbeoltl/cWuk3nx54THc7VWE96agNSsXSkPTF1guyuhg47+L3aKgDOj9DF4 oq1luIGCTOEQwvKHK3ZUXtWOMvZwZhT72P9sOV9kNnE/GAGvp5D1YHPxUeMCdB/ X-Google-Smtp-Source: AGHT+IFBojLKFUsRi46jxUj/82lpPoLlFcmw7BAFGVljTWhsMBbJ3khzAeUTmD1KdTt251Lb09lVSw== X-Received: by 2002:a2e:b81c:0:b0:302:251a:bd04 with SMTP id 38308e7fff4ca-3072ca88ffbmr4931551fa.9.1737104210175; Fri, 17 Jan 2025 00:56:50 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3072a330764sm3402101fa.3.2025.01.17.00.56.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 00:56:48 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 17 Jan 2025 10:56:39 +0200 Subject: [PATCH RFC 4/7] drm/display: dp-aux-dev: use new DCPD access helpers Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-drm-rework-dpcd-access-v1-4-7fc020e04dbc@linaro.org> References: <20250117-drm-rework-dpcd-access-v1-0-7fc020e04dbc@linaro.org> In-Reply-To: <20250117-drm-rework-dpcd-access-v1-0-7fc020e04dbc@linaro.org> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , Jani Nikula Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1383; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=u0enUT6rCyZ8RqHzkNWyQVgEzKAZFsn/cehDhTu72TM=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnihtFPa5XPtqF5ObSemv7vpAvzUlPQNy8VMpjv RyX+pGyC/iJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ4obRQAKCRCLPIo+Aiko 1QRZB/0b3sThkQAPK5Beb+5Pf6cn7vHPGIu4Piqk8s/CE8IKzDU+27jDQ/KOgIcLM2BOs2vmZRO Zb+L/0xMQ9kLSlMyp3NFHQgEBlO+Aykl4la4dDQlxroc5GjAHq5a0kE12q/R+uEhtIuF07wQg1x fEAQqzuQKE3zaFrKVvExUkljI4lnB+mKBBCKKLgnuCYwGcmdP6lD6AYqD7JZY1JvBCK3NedPORt O1972W2CsHJgB6bG+6JHa+l8s81kV1XjdIQE+dVGwLN8SYUp8BhKDlVSml67E0+KzneY1GoD3Qz zZsiuc6wSv2wOm9emHzfTlD7MgX2pW/EVxdGt16cNyjCQ0y3 X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Switch drm_dp_aux_dev.c to use new set of DPCD read / write helpers. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/display/drm_dp_aux_dev.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/display/drm_dp_aux_dev.c b/drivers/gpu/drm/display/drm_dp_aux_dev.c index 29555b9f03c8c42681c17c4a01e74a966cf8611f..a31ab3f41efb71fd5f936c24ba5c3b8ebea68a5e 100644 --- a/drivers/gpu/drm/display/drm_dp_aux_dev.c +++ b/drivers/gpu/drm/display/drm_dp_aux_dev.c @@ -163,17 +163,16 @@ static ssize_t auxdev_read_iter(struct kiocb *iocb, struct iov_iter *to) break; } - res = drm_dp_dpcd_read(aux_dev->aux, pos, buf, todo); - + res = drm_dp_dpcd_read_data(aux_dev->aux, pos, buf, todo); if (res <= 0) break; - if (copy_to_iter(buf, res, to) != res) { + if (copy_to_iter(buf, todo, to) != todo) { res = -EFAULT; break; } - pos += res; + pos += todo; } if (pos != iocb->ki_pos) @@ -211,12 +210,11 @@ static ssize_t auxdev_write_iter(struct kiocb *iocb, struct iov_iter *from) break; } - res = drm_dp_dpcd_write(aux_dev->aux, pos, buf, todo); - + res = drm_dp_dpcd_write_data(aux_dev->aux, pos, buf, todo); if (res <= 0) break; - pos += res; + pos += todo; } if (pos != iocb->ki_pos) From patchwork Fri Jan 17 08:56:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 858522 Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (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 CB93B1F91E1 for ; Fri, 17 Jan 2025 08:56:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737104218; cv=none; b=lELhDGGFLDLWzDr/qUNPHzWWa75L0y0cIGFDpFPptn+Fml2LYFuUaZG0LTCLQ0+9eiIHgFtjNN4NHokk9uHXFZO7y8M9U9YhivvW4jZCGdGKM7r96Wmvk8HW+/FwNS5d2IDr5db2QLI2exkIBQDL85Q9Gc0ehJOFn9U9dwbhdtQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737104218; c=relaxed/simple; bh=TJuc4RRF8VtMJDchcyjdI4OhT4nZLA2Y/JKIfwZo8hU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=e6C7bAGfrttWNsmUoiWleK84cd6Q9j0PaDKbmhQ3j7cbwHgPn++CGgNecEv24dsLQcuhF0rfUpwknf2/5RImLjkyd4CRoKZ5N2bWgQrgK0J5T0lvlVDV7NA1yttBqAaJ+hVbUBZcbqUbCDI5UgZUZv0q1FlZKCBHHRHg/ZPlxAA= 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=W6REiTUB; arc=none smtp.client-ip=209.85.208.174 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="W6REiTUB" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-305d843d925so15823791fa.2 for ; Fri, 17 Jan 2025 00:56:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737104215; x=1737709015; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Mkej2Dgbml3avSflLlUvt7qJpvnNaMgjKXK5J7iu/Ps=; b=W6REiTUBoZDDpeLeePsCcBCnVDUeSSQks0CZGc6S9fEth6pP7T/REE8qguVJKGFw7r oh9tZrwuM1QxdOVc3wpnSyHCCmRXSkWg2W+JicpZlQ0MzMfxNEQN0ZaAKGosJxYUjjLU azaKpfxPl4Hk95JWtRqaMYzJRpuHkuFQoDfxK4C/KzjkoI/ZIlutSL+xlGRZqYT1URHe 0r4F/2Ew7rUbCvmVUtcPnVl3IWKVbwmNDApEXHoVKkv29yuMEpDAevLiVWIeNhlO7VZh XEHS0yeYJCZldAeqiRuqa/MA7I66vbvhoZxQX7kAQOfgp2Qbsc8Cxfl0zy3PX8jLopnp ptLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737104215; x=1737709015; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mkej2Dgbml3avSflLlUvt7qJpvnNaMgjKXK5J7iu/Ps=; b=eU8I0TCQteCyLEvlxBC7duabiLmdEUpUgRKfjhaYk7iPMLhsznxvxCdkmlrAZqEf14 KJIptXlwSisT/Ecgm42xWmIpFt4nZ5XXAubEwujfETVvzx6C4FPE8WJzWd29yATbWFkA ojxPkwDeKqcPz6L/QbGCGb35VR6dhs2V0J22K69WCfHu7qMQy0cDrFPmuAIc/L/kQPBg UIbUgggU6oNkxvsdT6r2tXAyrnXJIdlN8q8A6Ge7Nzl1kDUIqESLHiIUXacNk/saxmQe JSTb/r+a/cTdnmPWvEU2lh1y5ePznkeQWRUDo269zWlQckc7A8O+icZk6jrAVtGxfKco iMdA== X-Forwarded-Encrypted: i=1; AJvYcCVbbZho2FMeaWujHsyfVstx0U5RSClQIIudmIzOlVisu3PB0FOXZB+osOnHlSfY+I7XlFVfI1fdGSQeKxRk@vger.kernel.org X-Gm-Message-State: AOJu0Yx/9GIrqEwC9u4sD/F/XlLJVDV/4eHAzo5OzEFu462/CMm5xgoe UkUhJ/pi2K3Qx+7Kek8ht+1njXoRW8fVF0sKlQZOXNpkO1+NAj3GJlWROEVL3Qo= X-Gm-Gg: ASbGnctNZz8hVmMUxn2DdHmfvXRHoDpVABEUcSFD9ALCgm+wISOqWOpR03/8Q3YitX9 3+TeyFaHBVdKLt54vPNsN2znZHKC+VMNnS3JAlasSn25spbG0Jq9H1z6rPikX82c/YQO8KeYjI8 RooeH/uuD9/DbnLz+Q+7bLHZVGIWSXSZjH8rhCXiot/D1E45KPghMZg6cTSpRnkIp89bB7mG72M LBYaYk0zCLDAm/UeHXVVCA2D/hB7bwmUgGj9oRUin8/h4EqOoESUqfbWZRuCrU7 X-Google-Smtp-Source: AGHT+IFm4k0duptfNNqNo9ovG1IM2PPWDcpt/zalR+xfYDZ9sS188Lv3M8hO8zDK38dYyNuQxcG/kg== X-Received: by 2002:a2e:a813:0:b0:302:29a5:6e01 with SMTP id 38308e7fff4ca-3072ca5b52bmr6092241fa.2.1737104214887; Fri, 17 Jan 2025 00:56:54 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3072a330764sm3402101fa.3.2025.01.17.00.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 00:56:53 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 17 Jan 2025 10:56:41 +0200 Subject: [PATCH RFC 6/7] drm/display: dp-mst-topology: use new DCPD access helpers Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-drm-rework-dpcd-access-v1-6-7fc020e04dbc@linaro.org> References: <20250117-drm-rework-dpcd-access-v1-0-7fc020e04dbc@linaro.org> In-Reply-To: <20250117-drm-rework-dpcd-access-v1-0-7fc020e04dbc@linaro.org> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , Jani Nikula Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=8833; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=TJuc4RRF8VtMJDchcyjdI4OhT4nZLA2Y/JKIfwZo8hU=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnihtFvWQ7P4k24wQB6JVUqLQ/RDOvd3K1a3Riq YPOy3h1nKaJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ4obRQAKCRCLPIo+Aiko 1aSsCACCHvHcjKSucNtYm2HFIAs2pWYBvtuSNh9BuQQ8keXDVJsunSVxSfSvS9Dn6u01kJLo4vp ISp9HRzB3RatWLR4fz7X2XY7W5E59xmDRe8iJ5f6QpJzuqR8JxNrDygr0NHNRyJhw7DArNiXr0S FSZHpLWhMDdQ7Op/UAd/H37+g3d7BrZCgqGDHJW0JBKcfXABl8xdw9qmKmHSKLe1Y/DFc2Js9UK 2l26yAtUsH/9FvMcYNKyAma5SOdVnm22tMbRtfLoj3ex1tZhXMZMMrGs2n/HfWxaN7iJ5p4LcyD ZSEXl/dokLsbh94iWsthxfl1Gv4DzKgUFqYqwi9dnBzE41so X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Switch drm_dp_mst_topology.c to use new set of DPCD read / write helpers. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/display/drm_dp_mst_topology.c | 105 +++++++++++++------------- 1 file changed, 51 insertions(+), 54 deletions(-) diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c b/drivers/gpu/drm/display/drm_dp_mst_topology.c index f8db5be53a33e87e94b864ba48151354e091f5aa..1bd9fc0007d214f461ea5476c9f04bb5167e5af0 100644 --- a/drivers/gpu/drm/display/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c @@ -2189,15 +2189,12 @@ static int drm_dp_check_mstb_guid(struct drm_dp_mst_branch *mstb, guid_t *guid) mstb->port_parent, DP_GUID, sizeof(buf), buf); } else { - ret = drm_dp_dpcd_write(mstb->mgr->aux, - DP_GUID, buf, sizeof(buf)); + ret = drm_dp_dpcd_write_data(mstb->mgr->aux, + DP_GUID, buf, sizeof(buf)); } } - if (ret < 16 && ret > 0) - return -EPROTO; - - return ret == 16 ? 0 : ret; + return ret; } static void build_mst_prop_path(const struct drm_dp_mst_branch *mstb, @@ -2733,14 +2730,13 @@ static int drm_dp_send_sideband_msg(struct drm_dp_mst_topology_mgr *mgr, do { tosend = min3(mgr->max_dpcd_transaction_bytes, 16, total); - ret = drm_dp_dpcd_write(mgr->aux, regbase + offset, - &msg[offset], - tosend); - if (ret != tosend) { - if (ret == -EIO && retries < 5) { - retries++; - goto retry; - } + ret = drm_dp_dpcd_write_data(mgr->aux, regbase + offset, + &msg[offset], + tosend); + if (ret == -EIO && retries < 5) { + retries++; + goto retry; + } else if (ret < 0) { drm_dbg_kms(mgr->dev, "failed to dpcd write %d %d\n", tosend, ret); return -EIO; @@ -3618,7 +3614,7 @@ enum drm_dp_mst_mode drm_dp_read_mst_cap(struct drm_dp_aux *aux, if (dpcd[DP_DPCD_REV] < DP_DPCD_REV_12) return DRM_DP_SST; - if (drm_dp_dpcd_readb(aux, DP_MSTM_CAP, &mstm_cap) != 1) + if (drm_dp_dpcd_read_byte(aux, DP_MSTM_CAP, &mstm_cap) < 0) return DRM_DP_SST; if (mstm_cap & DP_MST_CAP) @@ -3673,10 +3669,10 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms mgr->mst_primary = mstb; drm_dp_mst_topology_get_mstb(mgr->mst_primary); - ret = drm_dp_dpcd_writeb(mgr->aux, DP_MSTM_CTRL, - DP_MST_EN | - DP_UP_REQ_EN | - DP_UPSTREAM_IS_SRC); + ret = drm_dp_dpcd_write_byte(mgr->aux, DP_MSTM_CTRL, + DP_MST_EN | + DP_UP_REQ_EN | + DP_UPSTREAM_IS_SRC); if (ret < 0) goto out_unlock; @@ -3691,7 +3687,7 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms mstb = mgr->mst_primary; mgr->mst_primary = NULL; /* this can fail if the device is gone */ - drm_dp_dpcd_writeb(mgr->aux, DP_MSTM_CTRL, 0); + drm_dp_dpcd_write_byte(mgr->aux, DP_MSTM_CTRL, 0); ret = 0; mgr->payload_id_table_cleared = false; @@ -3757,8 +3753,8 @@ EXPORT_SYMBOL(drm_dp_mst_topology_queue_probe); void drm_dp_mst_topology_mgr_suspend(struct drm_dp_mst_topology_mgr *mgr) { mutex_lock(&mgr->lock); - drm_dp_dpcd_writeb(mgr->aux, DP_MSTM_CTRL, - DP_MST_EN | DP_UPSTREAM_IS_SRC); + drm_dp_dpcd_write_byte(mgr->aux, DP_MSTM_CTRL, + DP_MST_EN | DP_UPSTREAM_IS_SRC); mutex_unlock(&mgr->lock); flush_work(&mgr->up_req_work); flush_work(&mgr->work); @@ -3807,18 +3803,18 @@ int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr, goto out_fail; } - ret = drm_dp_dpcd_writeb(mgr->aux, DP_MSTM_CTRL, - DP_MST_EN | - DP_UP_REQ_EN | - DP_UPSTREAM_IS_SRC); + ret = drm_dp_dpcd_write_byte(mgr->aux, DP_MSTM_CTRL, + DP_MST_EN | + DP_UP_REQ_EN | + DP_UPSTREAM_IS_SRC); if (ret < 0) { drm_dbg_kms(mgr->dev, "mst write failed - undocked during suspend?\n"); goto out_fail; } /* Some hubs forget their guids after they resume */ - ret = drm_dp_dpcd_read(mgr->aux, DP_GUID, buf, sizeof(buf)); - if (ret != sizeof(buf)) { + ret = drm_dp_dpcd_read_data(mgr->aux, DP_GUID, buf, sizeof(buf)); + if (ret < 0) { drm_dbg_kms(mgr->dev, "dpcd read failed - undocked during suspend?\n"); goto out_fail; } @@ -3877,8 +3873,8 @@ drm_dp_get_one_sb_msg(struct drm_dp_mst_topology_mgr *mgr, bool up, *mstb = NULL; len = min(mgr->max_dpcd_transaction_bytes, 16); - ret = drm_dp_dpcd_read(mgr->aux, basereg, replyblock, len); - if (ret != len) { + ret = drm_dp_dpcd_read_data(mgr->aux, basereg, replyblock, len); + if (ret < 0) { drm_dbg_kms(mgr->dev, "failed to read DPCD down rep %d %d\n", len, ret); return false; } @@ -3916,9 +3912,9 @@ drm_dp_get_one_sb_msg(struct drm_dp_mst_topology_mgr *mgr, bool up, curreply = len; while (replylen > 0) { len = min3(replylen, mgr->max_dpcd_transaction_bytes, 16); - ret = drm_dp_dpcd_read(mgr->aux, basereg + curreply, - replyblock, len); - if (ret != len) { + ret = drm_dp_dpcd_read_data(mgr->aux, basereg + curreply, + replyblock, len); + if (ret < 0) { drm_dbg_kms(mgr->dev, "failed to read a chunk (len %d, ret %d)\n", len, ret); return false; @@ -4867,9 +4863,9 @@ static bool dump_dp_payload_table(struct drm_dp_mst_topology_mgr *mgr, int i; for (i = 0; i < DP_PAYLOAD_TABLE_SIZE; i += 16) { - if (drm_dp_dpcd_read(mgr->aux, - DP_PAYLOAD_TABLE_UPDATE_STATUS + i, - &buf[i], 16) != 16) + if (drm_dp_dpcd_read_data(mgr->aux, + DP_PAYLOAD_TABLE_UPDATE_STATUS + i, + &buf[i], 16) < 0) return false; } return true; @@ -4958,23 +4954,24 @@ void drm_dp_mst_dump_topology(struct seq_file *m, } seq_printf(m, "dpcd: %*ph\n", DP_RECEIVER_CAP_SIZE, buf); - ret = drm_dp_dpcd_read(mgr->aux, DP_FAUX_CAP, buf, 2); - if (ret != 2) { + ret = drm_dp_dpcd_read_data(mgr->aux, DP_FAUX_CAP, buf, 2); + if (ret < 0) { seq_printf(m, "faux/mst read failed\n"); goto out; } seq_printf(m, "faux/mst: %*ph\n", 2, buf); - ret = drm_dp_dpcd_read(mgr->aux, DP_MSTM_CTRL, buf, 1); - if (ret != 1) { + ret = drm_dp_dpcd_read_data(mgr->aux, DP_MSTM_CTRL, buf, 1); + if (ret < 0) { seq_printf(m, "mst ctrl read failed\n"); goto out; } seq_printf(m, "mst ctrl: %*ph\n", 1, buf); /* dump the standard OUI branch header */ - ret = drm_dp_dpcd_read(mgr->aux, DP_BRANCH_OUI, buf, DP_BRANCH_OUI_HEADER_SIZE); - if (ret != DP_BRANCH_OUI_HEADER_SIZE) { + ret = drm_dp_dpcd_read_data(mgr->aux, DP_BRANCH_OUI, buf, + DP_BRANCH_OUI_HEADER_SIZE); + if (ret < 0) { seq_printf(m, "branch oui read failed\n"); goto out; } @@ -6098,14 +6095,14 @@ struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port) /* DP-to-DP peer device */ if (drm_dp_mst_is_virtual_dpcd(immediate_upstream_port)) { - if (drm_dp_dpcd_read(&port->aux, - DP_DSC_SUPPORT, &endpoint_dsc, 1) != 1) + if (drm_dp_dpcd_read_data(&port->aux, + DP_DSC_SUPPORT, &endpoint_dsc, 1) < 0) return NULL; - if (drm_dp_dpcd_read(&port->aux, - DP_FEC_CAPABILITY, &endpoint_fec, 1) != 1) + if (drm_dp_dpcd_read_data(&port->aux, + DP_FEC_CAPABILITY, &endpoint_fec, 1) < 0) return NULL; - if (drm_dp_dpcd_read(&immediate_upstream_port->aux, - DP_DSC_SUPPORT, &upstream_dsc, 1) != 1) + if (drm_dp_dpcd_read_data(&immediate_upstream_port->aux, + DP_DSC_SUPPORT, &upstream_dsc, 1) < 0) return NULL; /* Enpoint decompression with DP-to-DP peer device */ @@ -6143,8 +6140,8 @@ struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port) if (drm_dp_has_quirk(&desc, DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD)) { u8 dpcd_ext[DP_RECEIVER_CAP_SIZE]; - if (drm_dp_dpcd_read(immediate_upstream_aux, - DP_DSC_SUPPORT, &upstream_dsc, 1) != 1) + if (drm_dp_dpcd_read_data(immediate_upstream_aux, + DP_DSC_SUPPORT, &upstream_dsc, 1) < 0) return NULL; if (!(upstream_dsc & DP_DSC_DECOMPRESSION_IS_SUPPORTED)) @@ -6166,11 +6163,11 @@ struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port) * therefore the endpoint needs to be * both DSC and FEC capable. */ - if (drm_dp_dpcd_read(&port->aux, - DP_DSC_SUPPORT, &endpoint_dsc, 1) != 1) + if (drm_dp_dpcd_read_data(&port->aux, + DP_DSC_SUPPORT, &endpoint_dsc, 1) < 0) return NULL; - if (drm_dp_dpcd_read(&port->aux, - DP_FEC_CAPABILITY, &endpoint_fec, 1) != 1) + if (drm_dp_dpcd_read_data(&port->aux, + DP_FEC_CAPABILITY, &endpoint_fec, 1) < 0) return NULL; if ((endpoint_dsc & DP_DSC_DECOMPRESSION_IS_SUPPORTED) && (endpoint_fec & DP_FEC_CAPABLE))