Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2019216pxb; Thu, 16 Sep 2021 23:35:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8b0j3Z3ORLyHlY3gxLS+9zBoXnjmVYGN3eME0yU4wve4/fmz7z5qKA1wt4hlk/3EvIhJq X-Received: by 2002:a17:906:4ccf:: with SMTP id q15mr10750722ejt.9.1631860539313; Thu, 16 Sep 2021 23:35:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631860539; cv=none; d=google.com; s=arc-20160816; b=DeiM7WiU1Vn6W0VdXqpZSf7iCl73jhyJs3C7mid9WUJOqQ0trup7xGpZWQ3fwSa6fp BH/Yx3CLsq94aljVa7hhBTNBHHk6lBd9RG6wyq3zKZQJzPR8FPUbz8zQiwZ+76kLO40Q CaWcbgMKraDOU/D2POJush+RoUTFnhVwaNAerxbRzLSahN8xTfD5UAifoHkJXFEGKNMY hGtPex9pY6hd+kLnMuiqcyrEbRFXEC7WRFLxMdqX3sK0zK+DmXWwqevgIiwr/+I7UfnM cwAIqJWF7f4PLOykOchRCN8AfDpgO04GrjdeP8tkHDWTaWUiius+rTzC05KK6U92KupM bcEg== 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:user-agent:from :references:in-reply-to:mime-version:dkim-signature; bh=ojoWMvWYiGgf8hZbpbLo/au+nVIOyXutlWB62AfZAFw=; b=NNLQPLQjNzVWuLoqdsK0xQSU5rdyWZ3om14ETxwBTmEc+cYY1l9b17qhvdYqCmazWq ZLetn+1DNs1RvwN+7wJXZU4n4mDEwxudXZ9JVeTOzfJhGUMFhqK7sjyqnvD7/3KVpJjd uBg8u8I4PgdGw1POvSSEdlRAWFSLI+jWc2g+cSFsYgYkzA76ipoFo+laTYwDRlYB38rG 7eYxdhlaWC7Va300b0t0WluuI18bxOf27B49UcTDBXNMOiFdrJLHYwubXfxIiiPUhtgq Do98PFfzGbU+LNSK2BcfPXzYbKVCL53dxdpPt7mYSudxqaBdHzbNEPPC1291jfAV/39i pvYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GfloMrd2; 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 n10si4143438edx.603.2021.09.16.23.35.16; Thu, 16 Sep 2021 23:35:39 -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=GfloMrd2; 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 S238063AbhIPUQ7 (ORCPT + 99 others); Thu, 16 Sep 2021 16:16:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbhIPUQy (ORCPT ); Thu, 16 Sep 2021 16:16:54 -0400 Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49512C061574 for ; Thu, 16 Sep 2021 13:15:32 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id 97-20020a9d006a000000b00545420bff9eso2958207ota.8 for ; Thu, 16 Sep 2021 13:15:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:user-agent:date:message-id :subject:to:cc; bh=ojoWMvWYiGgf8hZbpbLo/au+nVIOyXutlWB62AfZAFw=; b=GfloMrd2w/KYv4zk0CGJz9edZXIutQAmTBaa5aaDUIGci3XF1xOKwOwFF7KDN4gWK6 Chvmx9+KqA0rt4GCN4G1on/YjJGR/eWtdpkfVxXdeuaCcsY7f3fMsgDg4g0cTYb4oKcX VB+7JGwkeN/g2GcdMVaHm9g6URAoilmovScgo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:in-reply-to:references:from :user-agent:date:message-id:subject:to:cc; bh=ojoWMvWYiGgf8hZbpbLo/au+nVIOyXutlWB62AfZAFw=; b=SNh0MWCBxDzb5oA07fYDLw3Felkv53kOfF1mAjtuESDhcVYZFR0NekrcWAFdlROW11 RLL36kmsZk2HrnpuypEyAI/XIRmXcRVyUBZDQCg0928PzTsO8pNFG7Tt9BFGy6Cy9PfP /r1AxC/zIXsQN5esQjUNYlicHacpIt9XslsyIWOQas3iKHyc1coISEFrEiIC/Lv/jxNI I/kd9kAnHfJ+VSqPvD/pRFcVTzWCHnsz7QfqSuyphfgiGKVrdoKdwXgCuJj6z/TPzsMK /KHuvVjaN6FxC0nd/ZRMWLyhmQwuKWHOFTozFs0RUSu2Xf4Lq1dNQMi2vgyAJkwb40Wg cXLA== X-Gm-Message-State: AOAM531NCuPNyo9103cQ/5ZzR+9lDolE6TYf2swnr6dNiVAcRkd/SpmX 9R/yF4pbKVMamB74alF9n+KqeAznFVj8gQiLLaXzrA== X-Received: by 2002:a05:6830:18c7:: with SMTP id v7mr6307269ote.126.1631823331648; Thu, 16 Sep 2021 13:15:31 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 16 Sep 2021 13:15:31 -0700 MIME-Version: 1.0 In-Reply-To: References: <20210914162825.v3.1.I85e46da154e3fa570442b496a0363250fff0e44e@changeid> <20210914162825.v3.3.Ibf9b125434e3806b35f9079f6d8125578d76f138@changeid> From: Stephen Boyd User-Agent: alot/0.9.1 Date: Thu, 16 Sep 2021 13:15:31 -0700 Message-ID: Subject: Re: [PATCH v3 3/3] drm/bridge: parade-ps8640: Add support for AUX channel To: Doug Anderson 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 Quoting Doug Anderson (2021-09-15 14:27:40) > 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/ I think the rule is that the DRM specific printk stuff should be used so that they can be stuck into the drm logs. On chromeOS we also have a record of the drm logs that we can use to debug things, split away from the general kernel printk logs. So using DRM prints when there's a DRM device around is a good thing to do. > > > > > + 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. ;-) Yeah it's bikeshedding. I don't really care about this either but I find it easier to read when the assignment isn't wrapped across multiple lines. If the buffer approach is preferable then maybe use the address macros to clarify which register is being set? unsigned int base = PAGE0_SWAUX_ADDR_7_0; addr_len[PAGE0_SWAUX_ADDR_7_0 - base] = msg->address; addr_len[PAGE0_SWAUX_ADDR_15_8 - base] = msg->address >> 8; addr_len[PAGE0_SWAUX_ADDR_23_16 - base] = msg->address >> 16; addr_len[PAGE0_SWAUX_ADDR_23_16 - base] |= msg->request << 4; ... > > > > > + 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? > Oh I missed that. We're still supposed to return data to upper layers on a NACKed read?