Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2194255iof; Tue, 7 Jun 2022 22:49:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwz1Lw5AjQ8rlcw00GcsE7VOqb8OnhoDxo4STzGdqduvr/wvnABKTFmxxnKDAyxTxRZ5HpY X-Received: by 2002:a17:90a:1f4c:b0:1e6:6f77:c573 with SMTP id y12-20020a17090a1f4c00b001e66f77c573mr37736923pjy.17.1654667341913; Tue, 07 Jun 2022 22:49:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654667341; cv=none; d=google.com; s=arc-20160816; b=BaUY7KwTRkLOujYb0LouWbgl3QluJyy258v251VZMYbKFW+wpVH+512OsqLvn5XPdi ZfR4blxvC5RJnuMdEMcVqpayQrCroe4cxp3Cp45N1IUV0vf5VIrQgAVTnYzIGEzVLDMh +iyKIv6kHVL7hE6zNa4FVBreGXlQ6dxBTdqzrYaxqupIotPXRYL7arRN4qkAiopzbpMV 0Y189e5qKqp2iP0vKw8RKMrjcBUY747ix2hCzPm7ZT3WAA75vU+ersC1pBKvD4pqfmSw ODFESouKwrnTr6CXni0t5uv2BgUx4d7yHEvOO5JxbQayOmY+fAExZEQ6xM1Obom+x3re qGPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cXSdbI78t/O/6mmePk9/r9bg5ql3j8lKtGsJtiNNEpQ=; b=AtmyDmXhRbtWDtM6sA3vbl7higosuGEd3VUIoQ69ew6iWp7XlZIm/yDqBlseSbKwyU F4NmZKjcivre9w2ws95ktH1ctqcWwgtO7HHApmcaJtSH1uLPJxgMgninmpOmtBJlVS3r +RXuUHZ8ZL4jm43Cx4QB7iQXcHy5mpdJi9X7eZO2MfXQvh2GyZu+TdyhZbyq+VYwKWny 1B2m9JpADHZZOE/JyKlFH4dusLy3nrWjBII8IBIzWhb9Zs938/1keNV2ctioxUwCNSLb jXAbGC0lSMfs4ffLEKdfM8QuWIvcwRQGiel0r2xrWUSN8Qm6W0MAovq6e3YiNYqaqfQC hCVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fVEJJO1r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k15-20020a170902ce0f00b00163ef8dee02si27167566plg.391.2022.06.07.22.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:49:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fVEJJO1r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7202333CF6F; Tue, 7 Jun 2022 22:15:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347621AbiFHA0w (ORCPT + 99 others); Tue, 7 Jun 2022 20:26:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382838AbiFGWEw (ORCPT ); Tue, 7 Jun 2022 18:04:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2995A195941; Tue, 7 Jun 2022 12:16:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D86DFB822C0; Tue, 7 Jun 2022 19:16:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5016CC385A2; Tue, 7 Jun 2022 19:16:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629377; bh=P0JhZEhnX0JrfUblM9gr7pRAlhvGRIoAzFxWTDmIUCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fVEJJO1rvCZdCf2OA6dlCir10FjalPcFMRtq4pxGGib0RCptjxrG31DxkKz9f5mzw y8ZcK6vVIAMrHxCNUhQ7dqqmZPyED7mEXW2ZgCKH+qHvqWD+36hMPdtyLfeEgWXQdS MWGjQwk+NgHS2b4QOJxoTFzFKlRFOLeyekLAseNI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Walle , Codrin Ciubotariu , Wolfram Sang , Sasha Levin Subject: [PATCH 5.18 668/879] i2c: at91: use dma safe buffers Date: Tue, 7 Jun 2022 19:03:06 +0200 Message-Id: <20220607165022.239488914@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Walle [ Upstream commit 03fbb903c8bf7e53e101e8d9a7b261264317c411 ] The supplied buffer might be on the stack and we get the following error message: [ 3.312058] at91_i2c e0070600.i2c: rejecting DMA map of vmalloc memory Use i2c_{get,put}_dma_safe_msg_buf() to get a DMA-able memory region if necessary. Fixes: 60937b2cdbf9 ("i2c: at91: add dma support") Signed-off-by: Michael Walle Reviewed-by: Codrin Ciubotariu Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-at91-master.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/i2c/busses/i2c-at91-master.c b/drivers/i2c/busses/i2c-at91-master.c index b0eae94909f4..5eca3b3bb609 100644 --- a/drivers/i2c/busses/i2c-at91-master.c +++ b/drivers/i2c/busses/i2c-at91-master.c @@ -656,6 +656,7 @@ static int at91_twi_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, int num) unsigned int_addr_flag = 0; struct i2c_msg *m_start = msg; bool is_read; + u8 *dma_buf; dev_dbg(&adap->dev, "at91_xfer: processing %d messages:\n", num); @@ -703,7 +704,17 @@ static int at91_twi_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, int num) dev->msg = m_start; dev->recv_len_abort = false; + if (dev->use_dma) { + dma_buf = i2c_get_dma_safe_msg_buf(m_start, 1); + if (!dma_buf) { + ret = -ENOMEM; + goto out; + } + dev->buf = dma_buf; + } + ret = at91_do_twi_transfer(dev); + i2c_put_dma_safe_msg_buf(dma_buf, m_start, !ret); ret = (ret < 0) ? ret : num; out: -- 2.35.1