From patchwork Thu Sep 5 07:52:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 173123 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp375017ilq; Thu, 5 Sep 2019 00:52:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzw+Yl0geBc3nY7kaduc7dYsSOhl5u19Z0G4OiuWpo6Bkr7v15LwEma9Mnp2d3XPZVz1cz X-Received: by 2002:a17:90a:6349:: with SMTP id v9mr2387917pjs.20.1567669941732; Thu, 05 Sep 2019 00:52:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567669941; cv=none; d=google.com; s=arc-20160816; b=e0nsXpPIEOxQqwJxpB8HKm1+1ouBx7IviM8jPfx9QOVVs90L+A15YW8ArU3gplewvK eJOoRCCm+i5ObmscJMCnOhcleM0Y7ZAWxTeT5n0txaf0Wmp9XDAR0+JtSuhqQZi98PvW j2h4tkZMEarYS335Qs7uXA3d9vILVGLJVWqQeIrlPb8yyCxKd78rm/yxbPbKSAm/O2sK nLwGmNKv4cifTPOVxGW9htF0dkrjyelHCTphEKhOD43CG+5Du047rupqNPrjHV8kxobj v2ru4Ac1B1L2CowE2vWxKV8b607IgLpYJBd8BP0S8OQLOA1s1sPolrCDmpYgeVMjdogq 7Dhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=O9chrP35VeaOQspYv6yq0N6dO1x9er7VLpJQvN93FOI=; b=R/MOR8cLpSd0gHHOHASgRc/TEfaCqn0RhG7OYZ9MBaN0LG5FzebuLNyeDNeevsNYRl k5Omk7LzbuR5u2cuDYzWNlB7y9y/q3kvwnTS7oKHOh+Vl8eC+KFFu8kMIhqKP1XM0xrv dMiGsc1YpZTDJdyzW4fOkees+didF6q/Ko8qTuiYa97H5N6WActoGDKvm7y9+jN1lqXs I9lD0JY1DK8Yyv4X9LFQcA8YB1LGQzDyZ/spID+DV2DDuJtkopdyIkgNzVgm7uCik8cx SjC2XNDshEMerMc67lWquqBFbFrnUH4OJVP6Na6rqZ1JLTP71VnTwjWDQ5sAkzNawTQ4 xILg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jbQFjKO6; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r9si1296821plo.104.2019.09.05.00.52.21; Thu, 05 Sep 2019 00:52:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jbQFjKO6; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730704AbfIEHwU (ORCPT + 2 others); Thu, 5 Sep 2019 03:52:20 -0400 Received: from mail-wr1-f54.google.com ([209.85.221.54]:41595 "EHLO mail-wr1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731672AbfIEHwU (ORCPT ); Thu, 5 Sep 2019 03:52:20 -0400 Received: by mail-wr1-f54.google.com with SMTP id h7so482669wrw.8 for ; Thu, 05 Sep 2019 00:52:18 -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:in-reply-to:references; bh=O9chrP35VeaOQspYv6yq0N6dO1x9er7VLpJQvN93FOI=; b=jbQFjKO6Qmkr3vx8C0XsOTK+x7zrOxshYBIVG7sm9rgWvOAJMvAeFSduofVvDDe5er TK61PFDj3AgbrmAv1r+Al9SaMV8HOTWcaHS1nHEKt/tE+uPuRYWDiaG7hoy7NEX1pby5 narsaOua/J7JS7NIgo6i1GyQAX9PMaMiyqvcF4WlfEXl0ezdXbQ3kL9wnvYWp29AMFwO CH+nTirZx7HPPYzGt/mYDjNXMG7M4AtEbpm4qibTCSvvUbXdTXBAHJDsXSQV7FZerQZb 4Wi6eNLOZa8Auw5uqGklYXGwK1noKCmKNaHYGorNCyyfb4JrAyt4KoXtRjQaZxVJzXzM J+qg== 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:in-reply-to :references; bh=O9chrP35VeaOQspYv6yq0N6dO1x9er7VLpJQvN93FOI=; b=OlfBukruZ9YOHsuGhvvNan40aiTdmAMsj63s1fDBmtzq+kg+/GMCMplbCBbwVUkkjO ahtOgE6CNhMUR3pWcZl+CYAeyLXmWZmgHBgZNcgDO5fpHbfoFHbPRup9CPfTzDjZYfl0 vivVU2PZdHeW5kXxsKeu6XaMLAEOFWkGoh/KBkNyt6H+2c0CTZPJ5hupAt15rumcAbdO KBeZBzV0DsxR+VohHu9CVGgOGg1uPk+d6tkYqHtZi7fZrHqvs0+uhnNhXNyJYR7vTuD4 bVfa7SeZdcXLKeEkvSXRW3uB4PVEvgD14hUn8I422v3gQo2utM3EBKHN4laQpCKgFTGY W94A== X-Gm-Message-State: APjAAAVs+3C7i9rYUqhok/p5YaSj8lxKHJ1InRUGRu+EHNLZx5eie5jY 8/pgozeu4fcSg0AFM0v6Hs7y1Q== X-Received: by 2002:a5d:680e:: with SMTP id w14mr1338770wru.3.1567669938104; Thu, 05 Sep 2019 00:52:18 -0700 (PDT) Received: from localhost.localdomain ([95.147.198.36]) by smtp.gmail.com with ESMTPSA id a13sm3418784wrf.73.2019.09.05.00.52.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2019 00:52:17 -0700 (PDT) From: Lee Jones To: alokc@codeaurora.org, agross@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, bjorn.andersson@linaro.org, linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, wsa@the-dreams.de, vkoul@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Lee Jones Subject: [PATCH 2/2] i2c: qcom-geni: Provide an option to disable DMA processing Date: Thu, 5 Sep 2019 08:52:13 +0100 Message-Id: <20190905075213.13260-2-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905075213.13260-1-lee.jones@linaro.org> References: <20190905075213.13260-1-lee.jones@linaro.org> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org We have a production-level laptop (Lenovo Yoga C630) which is exhibiting a rather horrific bug. When I2C HID devices are being scanned for at boot-time the QCom Geni based I2C (Serial Engine) attempts to use DMA. When it does, the laptop reboots and the user never sees the OS. The beautiful thing about this approach is that, *if* the Geni SE DMA ever starts working, we can remove the C code and any old properties left in older DTs just become NOOP. Older kernels with newer DTs (less of a priority) *still* will not work - but they do not work now anyway. Fixes: 8bc529b25354 ("soc: qcom: geni: Add support for ACPI") Signed-off-by: Lee Jones Reviewed-by: Vinod Koul --- drivers/i2c/busses/i2c-qcom-geni.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c index a89bfce5388e..8822dea82980 100644 --- a/drivers/i2c/busses/i2c-qcom-geni.c +++ b/drivers/i2c/busses/i2c-qcom-geni.c @@ -353,13 +353,16 @@ static void geni_i2c_tx_fsm_rst(struct geni_i2c_dev *gi2c) static int geni_i2c_rx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg, u32 m_param) { + struct device_node *np = gi2c->se.dev->of_node; dma_addr_t rx_dma; unsigned long time_left; - void *dma_buf; + void *dma_buf = NULL; struct geni_se *se = &gi2c->se; size_t len = msg->len; - dma_buf = i2c_get_dma_safe_msg_buf(msg, 32); + if (!of_property_read_bool(np, "qcom,geni-se-no-dma")) + dma_buf = i2c_get_dma_safe_msg_buf(msg, 32); + if (dma_buf) geni_se_select_mode(se, GENI_SE_DMA); else @@ -392,13 +395,16 @@ static int geni_i2c_rx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg, static int geni_i2c_tx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg, u32 m_param) { + struct device_node *np = gi2c->se.dev->of_node; dma_addr_t tx_dma; unsigned long time_left; - void *dma_buf; + void *dma_buf = NULL; struct geni_se *se = &gi2c->se; size_t len = msg->len; - dma_buf = i2c_get_dma_safe_msg_buf(msg, 32); + if (!of_property_read_bool(np, "qcom,geni-se-no-dma")) + dma_buf = i2c_get_dma_safe_msg_buf(msg, 32); + if (dma_buf) geni_se_select_mode(se, GENI_SE_DMA); else