Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp184132pxa; Tue, 18 Aug 2020 20:44:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPm7bbUY+dnk+U0kgfS5+b86/f6KbbM7nHudvXA4VCMTUeKiR+E8FXzxXSqpmyGMzt9651 X-Received: by 2002:a17:906:a253:: with SMTP id bi19mr22616944ejb.338.1597808694842; Tue, 18 Aug 2020 20:44:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597808694; cv=none; d=google.com; s=arc-20160816; b=W63Zq7N/A6AQdIIK7W3hWKcEL9/jjwOJjiNWZ2BVAgj96SHVLdN/hrBEGPwhlXv5wo 9CH6AZ8xFI8VVvfhvT1S/EyZ8a7BLa4KIO7DbIOGerQaulaA8EUo8AdYzm0udWZG03K/ K6AYQA/QVSG6jM6+Uu0NCqPdvCouGrm7hxV2xcpqZqP/BfMCmKTeMlo0pUkny52KLuZ/ 5vVu40Y06M8tOZfqlm1iJZ3/TyCiSMgJqmwMuBxd9H4Su2D+y4HaMMb5JvH3OnpV6iAC eYjZOBBvP46rB8Lr0EC+wcqm7qrhOKvd/M2IGT9KagzPhhOTvJFMKJN8+q9//EAoArmF VnJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:date:to:cc:from :subject:references:in-reply-to:content-transfer-encoding :mime-version:dkim-signature; bh=LM6WEk9ZkbFt6Qg2UpRFNU3bLjYzPUz6PTE3Cs+whU4=; b=wugwqMpgsiCo2OILIK8BE4GdJbxOi8VwiHACQxQrcMwA57cI00NaT4pdomGQt4C6Vc //CFF4XDsDMKOdeJT0Vamw3OFNcqQ3T8CZyVjt6P6nb1JRwCpkTub9PFERqIZUDP5iQ1 JZGEhji9bUcJdzYiARVxqsv+PvxC/+eI9nAWrjwPmfYFvDWWsb9bxnpKBttSRuERSZ5y STuVLGnpP0bTotKTX6vcee0xbcbxshEcTR0zNxnQTloYUScXmEbfr44nDQe0lMoE1uv4 NxjQ218sn30VE2CpCPpOg+vvJiKH8qCucQN/J70gDSHHHeL1SBj8Ebai7cO2FHWlCyzw I+OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="FA4/UU2g"; 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 co5si9042315edb.210.2020.08.18.20.44.31; Tue, 18 Aug 2020 20:44:54 -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="FA4/UU2g"; 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 S1726671AbgHSDoC (ORCPT + 99 others); Tue, 18 Aug 2020 23:44:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726617AbgHSDoA (ORCPT ); Tue, 18 Aug 2020 23:44:00 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4E41C061389 for ; Tue, 18 Aug 2020 20:43:58 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id i92so566446pje.0 for ; Tue, 18 Aug 2020 20:43:58 -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=LM6WEk9ZkbFt6Qg2UpRFNU3bLjYzPUz6PTE3Cs+whU4=; b=FA4/UU2gVgjS/rjFwfGsWgyT+dH+LvVeCqbFb0OUeI/gWzIGoXU3gQBgpbuyKlQv1S vY0apjSOiH5Lmx9d0Sdve7ESWLk1aZ9Odq7o4p8SeYfjhXQE+rqoEw212IS1yE/nbqH5 nb+EQqH1uyhEGYhD4HnH/3sBRgbmW9+WeJlLA= 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=LM6WEk9ZkbFt6Qg2UpRFNU3bLjYzPUz6PTE3Cs+whU4=; b=aG6r+m3oJs2ZA/pelLeKdPuIqfXAFPlin9Y4GrEskVM1cClRkK8GsBbyhi2RYuBuBa insSVp9nzB7H6ICXlkTttde3dDy1PHnWGuX6vJ7/YMq405KydkykDdkD19xa0dQ4lgNZ aCCyXcUvVHJDrLOPI9u9eDif021n9EEbxqez9DeIh8bntm7JzRwHHEZXSIM2uJjx911C b6e4beMz68YPHZ91h7yX/QxEgYmip2M75HlBjWDArhI5AJ2d49CMkEPIcgOBTvfNEGVN M9fdpKnidAUF/KpD38RxY9J7mDDTOOuUKF5lOP7mzrSK40oR3ds7EcLQ1GEmp5ZeK8fY 38AA== X-Gm-Message-State: AOAM531H0RG/a6EZzP+/Rx4wSnZAL4DsdQcxGPQiJik3gB2w5FvmSyNu oSl9EmZskz9b+yGRxtcKT5to6A== X-Received: by 2002:a17:90a:c593:: with SMTP id l19mr2507622pjt.20.1597808638416; Tue, 18 Aug 2020 20:43:58 -0700 (PDT) Received: from chromium.org ([2620:15c:202:1:3e52:82ff:fe6c:83ab]) by smtp.gmail.com with ESMTPSA id o14sm255147pjw.11.2020.08.18.20.43.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 20:43:57 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20200814095540.32115-3-rojay@codeaurora.org> References: <20200814095540.32115-1-rojay@codeaurora.org> <20200814095540.32115-3-rojay@codeaurora.org> Subject: Re: [PATCH 2/2] i2c: i2c-qcom-geni: Add shutdown callback for i2c From: Stephen Boyd Cc: dianders@chromium.org, saiprakash.ranjan@codeaurora.org, gregkh@linuxfoundation.org, mka@chromium.org, akashast@codeaurora.org, msavaliy@qti.qualcomm.com, skakit@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, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, Roja Rani Yarubandi To: Roja Rani Yarubandi , wsa@kernel.org Date: Tue, 18 Aug 2020 20:43:56 -0700 Message-ID: <159780863669.334488.18038785498966010175@swboyd.mtv.corp.google.com> User-Agent: alot/0.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Roja Rani Yarubandi (2020-08-14 02:55:40) > If the hardware is still accessing memory after SMMU translation > is disabled(as part of smmu shutdown callback), then the Put a space before ( > IOVAs(I/O virtual address) which it was using will go on the bus Put a space before ( > as the physical addresses which will result in unknown crashes > like NoC/interconnect errors. >=20 > So, adding shutdown callback to i2c driver to unmap DMA mappings > during system "reboot" or "shutdown". >=20 Deserves a Fixes: tag if it's fixing a problem, which it looks like it is. > Signed-off-by: Roja Rani Yarubandi > --- > drivers/i2c/busses/i2c-qcom-geni.c | 36 ++++++++++++++++++++++++++++++ > include/linux/qcom-geni-se.h | 5 +++++ I'd prefer this is squashed with the previous patch. The first patch doesn't really stand on its own anyway. > 2 files changed, 41 insertions(+) >=20 > diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-= qcom-geni.c > index 53ca41f76080..749c225f95c4 100644 > --- a/drivers/i2c/busses/i2c-qcom-geni.c > +++ b/drivers/i2c/busses/i2c-qcom-geni.c > @@ -613,6 +613,41 @@ static int geni_i2c_remove(struct platform_device *p= dev) > return 0; > } > =20 > +static void geni_i2c_shutdown(struct platform_device *pdev) > +{ > + int ret; > + struct geni_i2c_dev *gi2c =3D platform_get_drvdata(pdev); > + struct geni_se *se =3D &gi2c->se; > + u32 dma; > + u32 dma_dbg_reg; Typically this is just called 'val'. > + > + ret =3D pm_runtime_get_sync(gi2c->se.dev); > + if (ret < 0) { > + dev_err(gi2c->se.dev, "Failed to resume device:%d\n", ret= ); Maybe just write: "Failed to resume device\n"? Not sure anyone cares what the error code is. And if they did, it would be connected to the colon so it will be hard to read. Add a space after colon if you want to keep the return value please. > + return; > + } > + > + dma =3D readl_relaxed(se->base + SE_GENI_DMA_MODE_EN); > + if (dma) { > + dma_dbg_reg =3D readl_relaxed(gi2c->se.base + SE_DMA_DEBU= G_REG0); > + if (dma_dbg_reg & DMA_TX_ACTIVE) { > + geni_i2c_abort_xfer(gi2c); > + gi2c->cur_wr =3D 0; > + if (gi2c->err) > + geni_i2c_tx_fsm_rst(gi2c); > + geni_se_tx_dma_unprep(se, gi2c->tx_dma, gi2c->xfe= r_len); > + } > + if (dma_dbg_reg & DMA_RX_ACTIVE) { > + geni_i2c_abort_xfer(gi2c); > + gi2c->cur_rd =3D 0; > + if (gi2c->err) > + geni_i2c_rx_fsm_rst(gi2c); > + geni_se_rx_dma_unprep(se, gi2c->rx_dma, gi2c->xfe= r_len); > + } Can this be a function? It sort of seems like we should be doing the same sort of stuff if we're canceling a DMA transaction in flight. > + } > + pm_runtime_put_sync_suspend(gi2c->se.dev); > +} > + > static int __maybe_unused geni_i2c_runtime_suspend(struct device *dev) > { > int ret; > diff --git a/include/linux/qcom-geni-se.h b/include/linux/qcom-geni-se.h > index dd464943f717..acad69be747d 100644 > --- a/include/linux/qcom-geni-se.h > +++ b/include/linux/qcom-geni-se.h > @@ -77,6 +77,7 @@ struct geni_se { > #define SE_DMA_RX_FSM_RST 0xd58 > #define SE_HW_PARAM_0 0xe24 > #define SE_HW_PARAM_1 0xe28 > +#define SE_DMA_DEBUG_REG0 0xe40 > =20 > /* GENI_FORCE_DEFAULT_REG fields */ > #define FORCE_DEFAULT BIT(0) > @@ -207,6 +208,10 @@ struct geni_se { > #define RX_GENI_CANCEL_IRQ BIT(11) > #define RX_GENI_GP_IRQ_EXT GENMASK(13, 12) > =20 > +/* DMA DEBUG Register fields */ Please follow other style, ie. SE_DMA_DEBUG_REG0 fields > +#define DMA_TX_ACTIVE BIT(0) > +#define DMA_RX_ACTIVE BIT(1) > + > /* SE_HW_PARAM_0 fields */ > #define TX_FIFO_WIDTH_MSK GENMASK(29, 24) > #define TX_FIFO_WIDTH_SHFT 24