Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp765476ybg; Sun, 26 Jul 2020 21:36:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT8Ooo6c4oNhqpT/VLDUoeLBGIB1EEq6OSWk4OOXTyx9CilDyuLfOLx46/fMvZ2vOvhNKj X-Received: by 2002:a05:6402:6c8:: with SMTP id n8mr4304268edy.195.1595824594306; Sun, 26 Jul 2020 21:36:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595824594; cv=none; d=google.com; s=arc-20160816; b=y/gtJ3RtlqdjnUw65EYk2KFsbfoAoI+B+AgrRhh/MYHQBxqpBmm8dswZieTgdpN4Kw mqXWwEBkKuZ0uKeZUbmdGBNj8HOYzN4gBcYwak+H+IulnUOTuByGAq28gpcYCwNYzcXj IlgTyi/GpJYl4E2pUyUXQ8/b644Jx/pNYV7MiewxYYKkiOuFBEZdiOnYuRvL4Mga8nxz ZEbZFo/NcJWwo+qkLXtt2iDpBoZ4xfmxz0b+unr4Ol3g1rVJPNpvFMkrCTC8Lja8Hz6k eVWIrpQhTiqLnmxYUA7nIKpmvVRq1Yy4lGsBRus6ODT/As0zsYBzGdo2CNrpqMjTnxn7 OJ2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=y2MT8K7LJP0h4HIjUSHIF3kx72ZyLwnnER3/s7uorqE=; b=j0DN8djgLFTM52eQYTvjI1EClI2mg5zIIPcYg4q8MgQ3YwIW5kcQRui98yJYwr5wo0 0pVAG8xMpOEChrISdhwoSvDk2GL4DH7Es273m9Fk546DW6se/XA0Eo2CbvakkCvpYvat LKpchfINNHTYfKBzCt+OHxLiF1X1Nkcn5hqCs7XwSQa6xnE2SVN54gVC7X2xec4Be2TX 4chxw5uoUmbA1BQBOqGz21FhtVNEUMgWUC7pnUwUn4QleHhDARlloKKdTWSS5hsPGAp5 9fefU95eSvcQ2tQ8o7fas9c9Tvl6eH9yNonHRWaR97VUo87SEkbkwmK+g31r2Ym7pY9I otpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=D8HCNvbb; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l30si1765070ede.587.2020.07.26.21.36.12; Sun, 26 Jul 2020 21:36:34 -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=@broadcom.com header.s=google header.b=D8HCNvbb; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726666AbgG0Ec1 (ORCPT + 99 others); Mon, 27 Jul 2020 00:32:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726541AbgG0EcX (ORCPT ); Mon, 27 Jul 2020 00:32:23 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD4D2C0619D4 for ; Sun, 26 Jul 2020 21:32:22 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id m15so7572772lfp.7 for ; Sun, 26 Jul 2020 21:32:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=y2MT8K7LJP0h4HIjUSHIF3kx72ZyLwnnER3/s7uorqE=; b=D8HCNvbbfeCXTArUC4WY1QDrs9HjLspd9XS6l+ZIduQcykgLo9mIag8AEPoxijQdxx N0I6GZ6ggif98PyvczFJQTezcR085wLtKWpW32z+fnl1YcUMRliE2ieD4PCcJ+Af9qM5 XgNj7w46y1O7ff2pkN657Rpag5lZjbuv52oqk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=y2MT8K7LJP0h4HIjUSHIF3kx72ZyLwnnER3/s7uorqE=; b=M8Kl3aTyNyi0mlLxLZd6rHlxgqgy9CZfXhp5KX0olqHVrDs65Ai6enlvDmVpQVWz6L pjNsPpCtpPLLY+eQ6U73I2Ka6pO8MDkzW+dQNLvg8dVzcnTk0/znbtQFYszl/QFX9+zW Y9AVgPMd+GZ1CcA045jbObWprvKosYXapMJlRLxfidLUB3f3lMsf+2qxs4Zp5oACRWhw HqcrTZqRayAuSaatrEDY1qEZBsenelHpRxPQWr7NENYg87CY97SrfzCxmU8PRhYeJKK4 TVbE7kD6CHnld4kHBBVRa69E+E+UfRFuF+Afuy/5jTGDXmOfi4RkFNj3fia5W40Kke5y heMw== X-Gm-Message-State: AOAM530kUm0Qp88NVcYCI38HySwS9wxwodKhAaN0aJBHugYxwsR8Mie9 siQUQ4Q6wmgpEsKtcVyuQYFq/8LZLG5RfStbL6iWzA== X-Received: by 2002:ac2:5502:: with SMTP id j2mr9290650lfk.50.1595824340928; Sun, 26 Jul 2020 21:32:20 -0700 (PDT) MIME-Version: 1.0 References: <1595115599-100054-1-git-send-email-dphadke@linux.microsoft.com> <116ac90c-8b49-ca89-90a4-9a28f43a7c50@broadcom.com> <20200722104128.GK1030@ninjato> <5048cf44-e2c2-ee31-a9fb-b823f16c2c7d@broadcom.com> <20200725101815.GA1519@ninjato> In-Reply-To: <20200725101815.GA1519@ninjato> From: Rayagonda Kokatanur Date: Mon, 27 Jul 2020 10:02:09 +0530 Message-ID: Subject: Re: [PATCH] i2c: iproc: fix race between client unreg and isr To: Wolfram Sang Cc: Ray Jui , Dhananjay Phadke , linux-i2c , Linux Kernel Mailing List , Ray Jui , BCM Kernel Feedback Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 25, 2020 at 3:48 PM Wolfram Sang wrote: > > > > I think the following sequence needs to be implemented to make this > > safe, i.e., after 'synchronize_irq', no further slave interrupt will be > > fired. > > > > In 'bcm_iproc_i2c_unreg_slave': > > > > 1. Set an atomic variable 'unreg_slave' (I'm bad in names so please come > > up with a better name than this) > > > > 2. Disable all slave interrupts > > > > 3. synchronize_irq > > > > 4. Set slave to NULL > > > > 5. Erase slave addresses > > What about this in unreg_slave? > > 1. disable_irq() > This includes synchronize_irq() and avoids the race. Because irq > will be masked at interrupt controller level, interrupts coming > in at the I2C IP core level should still be pending once we > reenable the irq. > > 2. disable all slave interrupts > > 3. enable_irq() > > 4. clean up the rest (pointer, address) > > Or am I overlooking something? This sequence will take care of all cases. @Dhananjay Phadke is it possible to verify this from your side once. Best regards, Raaygonda