Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2192861iof; Tue, 7 Jun 2022 22:45:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3KX2oobRctE9wRh8LcWG1WGILOV9EI+glRnhb4lJDfNKVUIuVnDPNVONuF4LyUwyG1gai X-Received: by 2002:a05:6a00:18a9:b0:51b:f63b:6f7c with SMTP id x41-20020a056a0018a900b0051bf63b6f7cmr20504284pfh.49.1654667152944; Tue, 07 Jun 2022 22:45:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654667152; cv=none; d=google.com; s=arc-20160816; b=h+G/UpmBXNHdRb8zecqJl75aL70DVnbHimC+gzt5KvKLBY9x+R648rtY486ZyDYNhM 3tNXVBIf+DsrQjUwFLyeftXgbkQ6N/z1z820591j8Fa0+8hFj5+s8LRcOwbJf4S7cDi/ MgELqyafWZb+WouI5XPackCRvaRxmPqmr3TxvbvMp8wmtFAhSsUhn7MRPREBrWRWbpV9 fBuHnYCGTjz1BciepuVMCmOFo1E48+fdpT2lyxzyf413NMZGtu2LKyaEjv9TLyCJxIqm BV8oO2jI43mT13Myyx8zt4VYWnkU086+aSvSikZ9tq+S+c4IROMBnpWqJxmsJF7AOAuC vSfA== 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=HXvp0XxCa76k9qAbbtE2jP+iETjuZ62eFqGmsneTPc8oSmLAoE3UgjoOGVVH8emB9C L7OP5AJGfk9M1yew6HPFBkYpLfm2a3j6oGJmuQTVMxrt5pOM9zJWDo2Rcu9shbjxB/O5 g05PGSChYF5//VSoKKGjxnHSPFwo5ECtys2d0LwDrkGUQTLsIRUj1tiUDMG8b+q45X9G hWv84jzPZqHiPWYOVJTqwBhx0mpUC01lnTW1EvC9YvQY+XXYEJplLrThB8Zj2Wkwvf3I SLBto+kVgBCeuQ6x3lqQInbTMzSzZRATnkurAbznVxqx4gYSJa9OVbR5q1OX1F8JWxvc +t+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BxvWUSuX; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id f4-20020a056a00238400b0050ad22888dasi17137529pfc.158.2022.06.07.22.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:45:52 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BxvWUSuX; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 96B664988F1; Tue, 7 Jun 2022 22:10:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356894AbiFGTrz (ORCPT + 99 others); Tue, 7 Jun 2022 15:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353908AbiFGSss (ORCPT ); Tue, 7 Jun 2022 14:48:48 -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 46E665587; Tue, 7 Jun 2022 11:03:11 -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 4D83AB82343; Tue, 7 Jun 2022 18:03:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 980CCC34115; Tue, 7 Jun 2022 18:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654624989; bh=P0JhZEhnX0JrfUblM9gr7pRAlhvGRIoAzFxWTDmIUCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BxvWUSuX5tn6J6mNmhRoFhp1CfDAEezRR4tOK72QhrJ8XRfSYfBrXbovfJ3Az6ziz BKGeEMeSE3b3Lp6XuL5gxZyNsqG7OY5+57NbFTN1c5yyaLM0cSuMs8ZZKjn6Swa88C y+m4/YafI2vWvNH+uRQw046+vGvzyjjXEZW8l8P0= 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.15 485/667] i2c: at91: use dma safe buffers Date: Tue, 7 Jun 2022 19:02:30 +0200 Message-Id: <20220607164949.248469337@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164934.766888869@linuxfoundation.org> References: <20220607164934.766888869@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