Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3420066pxk; Mon, 21 Sep 2020 13:14:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyx0qczYccdZx/pOSgJElqU8mtoGj/nNGXSfpWZrYnFJ494J9JaQjZSVlAmwzKJynoz58Kc X-Received: by 2002:a17:906:cc8d:: with SMTP id oq13mr1242239ejb.280.1600719262652; Mon, 21 Sep 2020 13:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600719262; cv=none; d=google.com; s=arc-20160816; b=SltI4Wmiht1UwQUDphUUMLmvwWGs6exmAlW6QYOFs3NANisX0FDr2jEmvRgursrAcO XWakK8NithSqtYxfg2vjUQI2emlqulGoEdzmpdwry+/ymjbtIWUEOP5I5CActJcT9QaC 6/CBFW0bnvvEpQW5XPsC0030fqdrXcFMUseB3E9nnk++QHvEPI+SAiMSJUn5ka6Dzkxd cOYL5PEk24COVpfuNeccyjH7a0XuaAUs1TXydZW3KAoBu2rYcZ38297DlIbH6JVw0gKU gAhbmVz4lRyiwISkD1SuuOxsELbXfvSMJOqyVZamDDbn7RqfeVgvfqTG0CrkKnYiP55T 8RCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:date:to:cc:from:subject :references:in-reply-to:content-transfer-encoding:mime-version :dkim-signature; bh=W/Kxd3ZsTJKzJEkeZeLlo7BrMx4l7UcmMdHw88y51RQ=; b=PVbsi/R9MdnA+y5Kcnk1G5PaJxO4s1Q15zO0i3yt7dZH30N7621C/Q7FUwl8FCg0W4 FV4qtNtPOcXerxgYWTt0G02hHm/rzbsehXGxOy5yA11I74w8AA5hf/muuc7XdwcYtCyl r3I2LqNoV/f6eAlwIe/3tBM5CV3SGKT7B2aKkuTUgQTWeh710HlM0v6hMNKwgGrCtMCi HWquBnq+qGB4BghQ0G2L7TEUnBBpjCmPvHbMQpE6iqtbZoWLcHWWVrLIyn7lUEoZGYdI 5NbEzQr6xolFyTsJZL7kczTo5HZ2kqnk1JNm6gHicPVd5+0cWKw/99woZOCX59qJLHzy HC7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hVYFLWCh; 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 d20si8354622edq.603.2020.09.21.13.13.58; Mon, 21 Sep 2020 13:14:22 -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=hVYFLWCh; 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 S1726437AbgIUUNA (ORCPT + 99 others); Mon, 21 Sep 2020 16:13:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbgIUUM7 (ORCPT ); Mon, 21 Sep 2020 16:12:59 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6152FC0613CF for ; Mon, 21 Sep 2020 13:12:59 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id mm21so346223pjb.4 for ; Mon, 21 Sep 2020 13:12:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:content-transfer-encoding:in-reply-to:references :subject:from:cc:to:date:message-id:user-agent; bh=W/Kxd3ZsTJKzJEkeZeLlo7BrMx4l7UcmMdHw88y51RQ=; b=hVYFLWChiCBjVwypKK0nyxvfd37bkITGsEBYxWBdD10OR6NdYz0pzW1BJbHzXslJo0 xtK3VvUkMzKZbsQ7aCfvV6ZlkuAvQfTmGBV7ZSh1zyrAUTEkGDeSJAXhqEtbyVOTczYF jER8++ADxIio0/I76KHHvyQQhit8ZCWm8qIE0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding :in-reply-to:references:subject:from:cc:to:date:message-id :user-agent; bh=W/Kxd3ZsTJKzJEkeZeLlo7BrMx4l7UcmMdHw88y51RQ=; b=lPa8qWuRskajXC79CyM6I8blAaUDTAOk3ohJaKeWxfPtKAPY0WS2H/H3nXmRHcxqLd Loo62UegvnN/QZ2G/4XQCF8Q6K1kWgpejvyfPowddRuPZwDD8oC0/vZpoXSiXjqBGPR4 zqiUeVN8j2metmIaE6Zv/KRB/JsoPOZ10tf3LRuJ3L7A5puzzaJSqtqpHoPtxIJDwI8u /xYYPTamN4NxS0pkHOCIktrisEbNEjZATsjcgkXlZNQkxMme9eQCQ2uBA2hHlgh3JZig FghPQ085iZY5pixPcGN7Es8Bb2lhK2NDP4vrl2toYdqzVot3O/1o1gJbo27VrpNPyI5V WEjA== X-Gm-Message-State: AOAM531LYP2r4W/+UbT6YUUe6GhqAWb9V395rkyjX5WZfsLeI2J1QRr8 rhyCEJ1BLu+0dKAjV2JOocm2Qg== X-Received: by 2002:a17:90b:3cb:: with SMTP id go11mr802317pjb.152.1600719178625; Mon, 21 Sep 2020 13:12:58 -0700 (PDT) Received: from chromium.org ([2620:15c:202:1:3e52:82ff:fe6c:83ab]) by smtp.gmail.com with ESMTPSA id l188sm12643094pfl.200.2020.09.21.13.12.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 13:12:57 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: References: <20200917122558.23110-1-rojay@codeaurora.org> <160037421089.4188128.9425314091585708436@swboyd.mtv.corp.google.com> Subject: Re: [PATCH V4] i2c: i2c-qcom-geni: Add shutdown callback for i2c From: Stephen Boyd Cc: wsa@kernel.org, dianders@chromium.org, saiprakash.ranjan@codeaurora.org, gregkh@linuxfoundation.org, mka@chromium.org, akashast@codeaurora.org, msavaliy@qti.qualcomm.com, skakit@codeaurora.org, vkaur@codeaurora.org, pyarlaga@codeaurora.org, rnayak@codeaurora.org, agross@kernel.org, bjorn.andersson@linaro.org, linux-arm-msm@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, sumit.semwal@linaro.org, linux-media@vger.kernel.org To: rojay@codeaurora.org Date: Mon, 21 Sep 2020 13:12:56 -0700 Message-ID: <160071917655.4188128.4175000228517858211@swboyd.mtv.corp.google.com> User-Agent: alot/0.9.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting rojay@codeaurora.org (2020-09-21 04:21:04) > Hi Stephen, >=20 > On 2020-09-18 01:53, Stephen Boyd wrote: > > Quoting Roja Rani Yarubandi (2020-09-17 05:25:58) > >> diff --git a/drivers/i2c/busses/i2c-qcom-geni.c=20 > >> b/drivers/i2c/busses/i2c-qcom-geni.c > >> index dead5db3315a..b0d8043c8cb2 100644 > >> --- a/drivers/i2c/busses/i2c-qcom-geni.c > >> +++ b/drivers/i2c/busses/i2c-qcom-geni.c > >> }; > >>=20 > >> struct geni_i2c_err_log { > >> @@ -307,7 +311,6 @@ static void geni_i2c_abort_xfer(struct=20 > >> geni_i2c_dev *gi2c) > >>=20 > >> spin_lock_irqsave(&gi2c->lock, flags); > >> geni_i2c_err(gi2c, GENI_TIMEOUT); > >> - gi2c->cur =3D NULL; > >=20 > > This looks concerning. We're moving this out from under the spinlock. > > The irq handler in this driver seems to hold the spinlock all the time > > while processing and this function grabs it here to keep cur consistent > > when aborting the transfer due to a timeout. Otherwise it looks like=20 > > the > > irqhandler can race with this and try to complete the transfer while > > it's being torn down here. > >=20 > >> geni_se_abort_m_cmd(&gi2c->se); > >> spin_unlock_irqrestore(&gi2c->lock, flags); > >> do { > >> @@ -349,10 +352,62 @@ static void geni_i2c_tx_fsm_rst(struct=20 > >> geni_i2c_dev *gi2c) > >> dev_err(gi2c->se.dev, "Timeout resetting TX_FSM\n"); > >> } > >>=20 > >> +static void geni_i2c_rx_msg_cleanup(struct geni_i2c_dev *gi2c) > >=20 > > So maybe pass cur to this function? > >=20 >=20 > Sorry, i did not understand why to pass cur to this function? I'm suggesting to copy the cur data out of the gi2c pointer and then pass it to these functions so that it can't race with another transfer. Something like an atomic exchange may work. I haven't thought about it deeply, but we need to make sure the irq handler can't race with the cleanup functions.