Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp842615pxb; Wed, 15 Sep 2021 14:48:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbqQn0cGe9wX0FLwcozjEJ8YzxKSt/+OZL5b/Gq2ZJj+lzXc4jS4zR8jTrf3mj6+aPMaGA X-Received: by 2002:a05:6638:1352:: with SMTP id u18mr1766621jad.147.1631742537775; Wed, 15 Sep 2021 14:48:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631742537; cv=none; d=google.com; s=arc-20160816; b=oYCr0eTHJ1gYi7xkJu90EGcns84Ji89MI2uDbJ9+oxKlNqJqQP3b+fmoC4tZDK49Mj GDwUfsKfPTNIti5IWmzPX317FYZBl7sdbmA2J/5qda8QoAYeTRpP+uwoNiKyBQ5Y/xED iUOYIHnK9pGRy0q7PPL5o8WwgF40gNRJtCRlDrLvoYrq65MoR8eogstwG9OgUvPcgznV GhlKjluLQEw43Dp/xSN7qSyYCU3/RobrTbLgWAExNaw4r//bZ/Y039/D5XzyiXYw67uy pzU/UUX9LGtU0zKN2oDcKpfzEWldl8qByDl3ZbUe+V4Xlo9muqDA0Fu+pjEC5NxH3Y17 NZIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Xdzl68kgUwZsmDH1EOQb6npCsfHZBZag3uzeD/gnyF0=; b=zQ5CDK6dXy4XgjBgJ7AS9NAeeOxld0Ytxzbrjinpr7fzVGwvjXCGC+Ibd+NcoYThb+ kBOPL1RvuQjTIv+mFkXG1AP7uM9k86GVQ2TMxw/j953b1LDkxIBQ7E2T3OsC4YcmYQzQ D2upO7lS+X1JLlAGjaTIkrK4C8lZnNaR2XzPkP7iFIeo06YM1tAQoHJdKP4+rnsWIyFo PejuCVZlRLGjs3EPFfNSYmbxwG4qEP+HNl7vLWQunbKUpMqsVjdH/74kR5dEPeBpL5a1 2aag8pHzfcEN867KnOLTqAQUAHa9DZSxKjxPWKHuPsTpwiaXxPqYOY4c2O6z7EQc1F4q 9IMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dXtqHIzg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h25si1097315ioj.39.2021.09.15.14.48.30; Wed, 15 Sep 2021 14:48:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dXtqHIzg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232154AbhIOV3P (ORCPT + 99 others); Wed, 15 Sep 2021 17:29:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231927AbhIOV3O (ORCPT ); Wed, 15 Sep 2021 17:29:14 -0400 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D9AEC061574 for ; Wed, 15 Sep 2021 14:27:55 -0700 (PDT) Received: by mail-qt1-x82c.google.com with SMTP id u21so3743735qtw.8 for ; Wed, 15 Sep 2021 14:27:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Xdzl68kgUwZsmDH1EOQb6npCsfHZBZag3uzeD/gnyF0=; b=dXtqHIzgU5z0jfyNbPBAdO6dyOruzGJqO7SF8KPSfg+bsVT/RjMQd049CA7t89Gysc +WgEUpfDGwtgJloX3zzSa1FOvOYu3f8dw7VO6TL5Anyu6ciPSOIYFD2yXSUlolcsRzlv 8srN5A8mW91oOQksU6orqNMRDt9SAmZSbXIsA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Xdzl68kgUwZsmDH1EOQb6npCsfHZBZag3uzeD/gnyF0=; b=BDW8tCCJeQ7M3GdIG7Isw7k4gbO1voiopA8QEnxHTgKrznKJIXEp7LLtisrtbdVDfy kx/Nn1Qn0UV0xndV6Y2fKzERtDXz9Ph3fAQw2rVmr7ud7Vj6rOljEIvghhIkIIa+yheG E7rZg/bucBaamP94vDatAhzFLBt1B5dTozzgqdhcHKbOeVLjuS9bdxHZZt0gPEjDsG5r JpfK0fX0kJpcxE0QDcf+yRlF/S2dVjbqFKzYqQgRoGjU3JM4CVuYZA3qpw/X7QhraKpe XWkuPApouIi+//4R1YgUVUokBh8THIWdN+OZ5wKiCPzbgRuvQmxfjbhfHz9OII0TUf1t thSQ== X-Gm-Message-State: AOAM53000Wny9EhEwUm66ymebv6pm027k6mK+xYCYhRmxRF1J7Xdqar+ Cma2IjBehPo1W5pivTyJygc9H3dWlETO+w== X-Received: by 2002:ac8:411d:: with SMTP id q29mr1991655qtl.349.1631741273273; Wed, 15 Sep 2021 14:27:53 -0700 (PDT) Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com. [209.85.219.176]) by smtp.gmail.com with ESMTPSA id z11sm740724qtw.8.2021.09.15.14.27.52 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Sep 2021 14:27:52 -0700 (PDT) Received: by mail-yb1-f176.google.com with SMTP id y13so8651328ybi.6 for ; Wed, 15 Sep 2021 14:27:52 -0700 (PDT) X-Received: by 2002:a25:bb93:: with SMTP id y19mr2716698ybg.266.1631741272077; Wed, 15 Sep 2021 14:27:52 -0700 (PDT) MIME-Version: 1.0 References: <20210914162825.v3.1.I85e46da154e3fa570442b496a0363250fff0e44e@changeid> <20210914162825.v3.3.Ibf9b125434e3806b35f9079f6d8125578d76f138@changeid> In-Reply-To: From: Doug Anderson Date: Wed, 15 Sep 2021 14:27:40 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 3/3] drm/bridge: parade-ps8640: Add support for AUX channel To: Stephen Boyd Cc: LKML , Philip Chen , Andrzej Hajda , Daniel Vetter , David Airlie , Jernej Skrabec , Jonas Karlman , Laurent Pinchart , Neil Armstrong , Robert Foss , dri-devel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Sep 14, 2021 at 5:57 PM Stephen Boyd wrote: > > Quoting Philip Chen (2021-09-14 16:28:45) > > diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c b/drivers/gpu/drm/bridge/parade-ps8640.c > > index 8d3e7a147170..dc349d729f5a 100644 > > --- a/drivers/gpu/drm/bridge/parade-ps8640.c > > +++ b/drivers/gpu/drm/bridge/parade-ps8640.c > > @@ -117,6 +144,129 @@ static inline struct ps8640 *bridge_to_ps8640(struct drm_bridge *e) > [...] > > + case DP_AUX_I2C_WRITE: > > + case DP_AUX_I2C_READ: > > + break; > > + default: > > + return -EINVAL; > > + } > > + > > + ret = regmap_write(map, PAGE0_AUXCH_CFG3, AUXCH_CFG3_RESET); > > + if (ret) { > > + dev_err(dev, "failed to write PAGE0_AUXCH_CFG3: %d\n", ret); > > Can we use DRM_DEV_ERROR()? I've never gotten clear guidance here. For instance, in some other review I suggested using the DRM wrapper and got told "no" [1]. ;-) The driver landed without the DRM_ERROR versions. I don't really care lots so it's fine with me to use use DRM_DEV_ERROR, I just wish I understood the rules... [1] https://lore.kernel.org/all/49db7ef3-fa53-a274-7c69-c2d840b13058@denx.de/ > > + return ret; > > + } > > + > > + /* Assume it's good */ > > + msg->reply = 0; > > + > > + addr_len[0] = msg->address & 0xff; > > + addr_len[1] = (msg->address >> 8) & 0xff; > > + addr_len[2] = ((msg->request << 4) & SWAUX_CMD_MASK) | > > + ((msg->address >> 16) & SWAUX_ADDR_19_16_MASK); > > It really feels like this out to be possible with some sort of > cpu_to_le32() API. We're shoving msg->address into 3 bytes and then > adding in the request and some length. So we could do something like: > > u32 addr_len; > > addr_len = FIELD_PREP(SWAUX_ADDR_MASK, msg->address); > addr_len |= FIELD_PREP(SWAUX_CMD_MASK, msg->request); > if (len) > addr_len |= FIELD_PREP(LEN_MASK, len - 1); > else > addr_len |= FIELD_PREP(LEN_MASK, SWAUX_NO_PAYLOAD ); > > cpu_to_le32s(&addr_len); > > regmap_bulk_write(map, PAGE0_SWAUX_ADDR_7_0, &addr_len, sizeof(addr_len)); You're arguing that your version of the code is more efficient? Easier to understand? Something else? To me, Philip's initial version is crystal clear and easy to map to the bridge datasheet but I need to think more to confirm that your version is right. Thinking is hard and I like to avoid it when possible. In any case, it's definitely bikeshedding and I'll yield if everyone likes the other version better. ;-) > > + return ret; > > + } > > + > > + switch (data & SWAUX_STATUS_MASK) { > > + /* Ignore the DEFER cases as they are already handled in hardware */ > > + case SWAUX_STATUS_NACK: > > + case SWAUX_STATUS_I2C_NACK: > > + /* > > + * The programming guide is not clear about whether a I2C NACK > > + * would trigger SWAUX_STATUS_NACK or SWAUX_STATUS_I2C_NACK. So > > + * we handle both cases together. > > + */ > > + if (is_native_aux) > > + msg->reply |= DP_AUX_NATIVE_REPLY_NACK; > > + else > > + msg->reply |= DP_AUX_I2C_REPLY_NACK; > > + > > + len = data & SWAUX_M_MASK; > > + return len; > > Why no 'return data & SWAUX_M_MASK;' and skip the assignment? Actually, I think it's the "return" that's a bug, isn't it? If we're doing a "read" and we're returning a positive number of bytes then we need to actually _read_ them. Reading happens below, doesn't it? -Doug