From patchwork Fri Jul 2 13:56:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 469554 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1412721jao; Fri, 2 Jul 2021 06:58:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTJyrdDYqTUT9bHX8JS9RpVqCIwuHP0DdY5D1FOO1DHEAUEh6ZnRZKUH2w7Q67jdEy4LDU X-Received: by 2002:a17:902:e54c:b029:127:9485:49d1 with SMTP id n12-20020a170902e54cb0290127948549d1mr4455053plf.66.1625234291424; Fri, 02 Jul 2021 06:58:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625234291; cv=none; d=google.com; s=arc-20160816; b=YrEX9OFA/LVgXIaArbVdfaiuKW0zyZeR9ug/e8KDQAHSHyqRHi1ibWa81l21SYsC8L p8fHOCrL6jJ38ffis1p63H9z8n7TgVguGKx1I+IRVV82PFKoUg5s1GvU7eQDEPKE9VBe xe8U7E96/glTzZO1V4O5e8iDYxQkp3lNSVpfGY4rModMwmIsYfHkW54HWEwLWYeB442d LaqiX2SEZpNRubDuF5aVBMBUa2KWHm7ms1quRMAt9AATSF5cARk93ra6KOSCcYtPSkDe GioSVJVspCagq/Mp/eyEX7qE4u2gxndEiZcSNx6XR8tUPNyfxEkJHw/lKl7udY9og7tW Z8Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :delivered-to; bh=k0Qf8LnRzgJKGYnwaG9Xn2vyU5JdJZJXYA+9GZcR0qQ=; b=yKhzHHtFPqfKy2XngJlmE3FT6tmmAkFF3t8WOa1EUgCO31l6q5kOh/e0Uzfa4qyG2F ZB/ga2qsqJS0VW5EqqpuH7RE1cXLPpPfYA/FcrMLRYsfhVXhOe0IkBMHKAB2GgTiHuwi PQT0JrlM7eM0SfzFYD6XgoFBzNObcxKNG4NZS6hlmRB4jKOliirMIrLZB/QD43mYpnbe vw/0e8aSLzDhcrwZBwWiFt3tuL7yb+kSZuk0/QsiYx+BMIL3UOqksy7lKIQ22z8eaLln uq020Sx5Dd2D2RisDXpEz9ZmfDyzYqFoeo78tXYs99K5U5E8BzyzyOkGHXIkWUWDE4Hq 4mxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SFZAEuMw; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id k22si4127885pfa.201.2021.07.02.06.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 06:58:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SFZAEuMw; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 53D756E187; Fri, 2 Jul 2021 13:58:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2D6EE6E187 for ; Fri, 2 Jul 2021 13:58:05 +0000 (UTC) Received: by mail-lj1-x22e.google.com with SMTP id u25so13384292ljj.11 for ; Fri, 02 Jul 2021 06:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=k0Qf8LnRzgJKGYnwaG9Xn2vyU5JdJZJXYA+9GZcR0qQ=; b=SFZAEuMwq885wgiySUSkwZaWFS6KdfmllRvo2GqlVc0E46Gcj9z3SONVjHNnvKONaX RSXowlTb0gj8BZIpQCdiZAzA49p+7Pm3yFCX7n2uzKQRsfqYvc+NV4dFIp6JNqEqFfih Fxgg2gQidRD+EJXqDcy9rly7TmIMZWn7R0XTw8V4i3wgJHzgVHvkST8TwfezjzuP21PY /SZWP+XAmcP3Jm82cUGJw0U5y3hq5UAgwct8wC/rhyTPobguoEjJBE0/lgJcYJV7wlIh GT9jb7TMc8Tr5XN0zjSDCIcnELLmJoW67eYz0qsiwx1vo+diNKXsjE3UfRIfByyDUKdv S3jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=k0Qf8LnRzgJKGYnwaG9Xn2vyU5JdJZJXYA+9GZcR0qQ=; b=fpcBtavS6I0KbZnhsDXOKqOS+8W2jIgP6V0k2IOUSWucFFcbAGagAt1jB9w0AVpkgW Iev0JLpdvVaesylciNnp4j4JqF+gj1hRbIyuOOwJ69cbxx+fp5wTvHF9OZj080WpUPEM zkqnXsqfUO0lcDHStyZMSxNVIO7CAJDZpYkd1mGJOL0OoTQcM0m79OqfvyBLcX3GEESG wV53N3+XwW86Q6JNb6C5W7QbstEO7AYjSNpmRFgU/8MrEznyyd8iCh+GtouhLLhivuTY 9RH9TMvGMjgePQOtmxwz14AWfcpOC/GK3rhCPj2PYWxCGzrX5WYkpSRekImgrmQfB6hD 4wsQ== X-Gm-Message-State: AOAM533OUGNAt/g9m8MmVUKI1viwOXHohlYLXivf0sRA4EkFYODa6zRg uiSa+mFZ5Z7gL1sdOVT5bqYBVw== X-Received: by 2002:a2e:5c2:: with SMTP id 185mr4174770ljf.25.1625234283414; Fri, 02 Jul 2021 06:58:03 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id j17sm282058lfb.111.2021.07.02.06.58.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 06:58:03 -0700 (PDT) From: Linus Walleij To: Thierry Reding , Sam Ravnborg , dri-devel@lists.freedesktop.org Subject: [PATCH v3] drm/dbi: Print errors for mipi_dbi_command() Date: Fri, 2 Jul 2021 15:56:01 +0200 Message-Id: <20210702135601.3952726-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Noralf_Tr=C3=B8nnes?= , Douglas Anderson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The macro mipi_dbi_command() does not report errors unless you wrap it in another macro to do the error reporting. Report a rate-limited error so we know what is going on. Drop the only user in DRM using mipi_dbi_command() and actually checking the error explicitly, let it use mipi_dbi_command_buf() directly instead. After this any code wishing to send command arrays can rely on mipi_dbi_command() providing an appropriate error message if something goes wrong. Suggested-by: Noralf Trønnes Suggested-by: Douglas Anderson Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Make the macro actually return the error value if need be, by putting a single ret; at the end of the macro. (Neat trick from StackOverflow!) - Switch the site where I switched mipi_dbi_command() to mipi_dbi_command_buf() back to what it was. - Print the failed command in the error message. - Put the dbi in (parens) since drivers/gpu/drm/tiny/st7586.c was passing &dbidev->dbi as parameter to mipi_dbi_command() and this would expand to struct device *dev = &&dbidev->dbi->spi->dev which can't be parsed but struct device *dev = &(&dbidev->dbi)->spi-dev; should work. I hope. ChangeLog v1->v2: - Fish out the struct device * from the DBI SPI client and use that to print the errors associated with the SPI device. --- include/drm/drm_mipi_dbi.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.31.1 Reviewed-by: Noralf Trønnes Reviewed-by: Douglas Anderson diff --git a/include/drm/drm_mipi_dbi.h b/include/drm/drm_mipi_dbi.h index f543d6e3e822..05e194958265 100644 --- a/include/drm/drm_mipi_dbi.h +++ b/include/drm/drm_mipi_dbi.h @@ -183,7 +183,12 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb, #define mipi_dbi_command(dbi, cmd, seq...) \ ({ \ const u8 d[] = { seq }; \ - mipi_dbi_command_stackbuf(dbi, cmd, d, ARRAY_SIZE(d)); \ + struct device *dev = &(dbi)->spi->dev; \ + int ret; \ + ret = mipi_dbi_command_stackbuf(dbi, cmd, d, ARRAY_SIZE(d)); \ + if (ret) \ + dev_err_ratelimited(dev, "error %d when sending command %#02x\n", ret, cmd); \ + ret; \ }) #ifdef CONFIG_DEBUG_FS