Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2266541pxm; Fri, 4 Mar 2022 12:41:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwfmHPvlQRs+Tk8v9UspFFPHKgL6RaITJKgsuzbmdJOpe1iLRoNhVBQJBtNv1jmirqup/Qg X-Received: by 2002:a05:6a00:24c5:b0:4d1:65bf:1fe0 with SMTP id d5-20020a056a0024c500b004d165bf1fe0mr337044pfv.0.1646426511372; Fri, 04 Mar 2022 12:41:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1646426511; cv=pass; d=google.com; s=arc-20160816; b=E2KnR4oGlyRoCRgi5aFryOHEy5A3WHlLgOVJr5WyLNpAheRtUVdXaSzXySr2dqhJ4y Demz6rCvOe51GoVFAt6ALOqByVXWJBEBg4tCbP2AV9jE7QRfDMmzKF6Xa315Z5hrInAd qN7PR1NZTkw1cQK6CxfJ5SxLKvD/hl8sQEr3ecMs3iVfrHgXBUK8K+nr57tJ6HaYRW2l o9sMJqspto2kwB9XBGJC2yTrmpYL/msRboEjQHPcnjb6NOXm943O2MNGwfadE6xcwXai eZfvevD7OiuDjN8g8fl+B833FPuOaN60taebWOfRRbRZJE2JGtYGj/pQNDctbHvt7Aep KemQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=Jo9em+kGrQaLMjVMuZOCmPtHQaSySg5uC8Ody1xj6CE=; b=lt763dvOWViJc9kNxO3crvok9Vw8HtYhrgkB7qwOBvE1l+dz+M40i/jYtIvafz0S6D 2Ot/rBjQ8XuaTqWlWnmie2bGOVw0RlwPx0ZZTGoYctiH9ONX1z3TPIvzDju6kawnbw9u s2crHkrf6p487xZWSYt5KQxcMl04X6I/tfedvwq5fu7egUdJnH3aQnMYngKNA10CX55h gbm94fHOUwfNUI8WnYh7xOOEhDnUYBrcmztpwCobwp1YtG4IEEyoXO47NPGqjY28jXvT UDlNHA5CIwNY774EDpJA2kHuCBjHStnSLsLF3u/Kw7OgH9H6ceMaLkLy2RmPtYFWhsyl WL2w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=fgPatY5Y; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k20-20020a17090aaa1400b001bd14e01fc8si478246pjq.182.2022.03.04.12.41.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 12:41:51 -0800 (PST) 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=@amd.com header.s=selector1 header.b=fgPatY5Y; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 55EE32C7235; Fri, 4 Mar 2022 11:41:36 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238838AbiCDHgn (ORCPT + 99 others); Fri, 4 Mar 2022 02:36:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238549AbiCDHgm (ORCPT ); Fri, 4 Mar 2022 02:36:42 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2081.outbound.protection.outlook.com [40.107.212.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 151AFA2F29; Thu, 3 Mar 2022 23:35:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b9GZQRVTqmom0onir62HtYSJhlUO9SxoejKeV1aN5trNacowkjw78hCdD9dnErWFiYp+qwbmKNtnHmdYBki5dC8FGJc6jrHQn1PjqEK2QONZtmQ8JOgnGO+/HbLlTGzTnk+8kJYN6lwMkMp5OzLjxJhnaplW3YFSoEfUgAlqBVRNuT41yvUfDNSCgbVrai2D7ZG8lcSdDGacS7uw0LKVoD16572+ygaJW7ZR5x7qY/L0fdFKLm1qS029tCPzrLUDFUA0NhAwtOQar/sdcKwohnRJv43uPytNFnQZ6o1z9xmP7o1fzGJwpmxdbkl3+h0En+xGLls9Je1UhAXMQXaLzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Jo9em+kGrQaLMjVMuZOCmPtHQaSySg5uC8Ody1xj6CE=; b=awDad9N3YcorzCyqFINP/JzC9QFybs2HrbIsmbTo/Pn3j7jnZ1lP7lAVu4u9W7o1j1Ht52qCIjKzkMSJ94oUGZDRHwj2xA8L/cf9B0539FNcpms8+ulpnfYvBP54QejFpQIBSu6qd1fnigTXJBrk2Pr0u537o0pZW3xaVJp0QUBB/6L8+0wuw48kSpNx2XjkQ3GFZFtumK15hImVLRlPU9se04P5biRhycUSNeHoirMdufn34bYYxKmBGSX43imFnbH/lXg+3vCTIdilv/tW3fTqeE0d2s5BomNGzvuRpfdY1Hw7RcQan3hP3VJaXiw/MjeQYE8MIxS/iXwibQDECQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Jo9em+kGrQaLMjVMuZOCmPtHQaSySg5uC8Ody1xj6CE=; b=fgPatY5YShnpp1dfmogdeg2p6wnGbZ7+NoY4O/PgYhPxwx2v3O+zmCRheZqXlezhZ7JMMUdATgwkhYjMbE9oT8iLPFMBBoRVx1o49bho5kJ3fx0lA5D1drhqWu2xlzBfWq29gQ0r9DEuM+r2yIr6kZKz1TvFK99SA+q+L5kWrTg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) by BYAPR12MB3045.namprd12.prod.outlook.com (2603:10b6:a03:ac::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Fri, 4 Mar 2022 07:35:52 +0000 Received: from BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::e03f:901a:be6c:b581]) by BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::e03f:901a:be6c:b581%6]) with mapi id 15.20.5038.014; Fri, 4 Mar 2022 07:35:51 +0000 Message-ID: Date: Fri, 4 Mar 2022 08:35:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] i2c: at91: use dma safe buffers Content-Language: en-US To: Michael Walle , Codrin Ciubotariu , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Sumit Semwal Cc: linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, stable@vger.kernel.org References: <20220303161724.3324948-1-michael@walle.cc> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <20220303161724.3324948-1-michael@walle.cc> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: AM6P193CA0130.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::35) To BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6da3efe1-05ab-4d7f-5c1f-08d9fdb19b98 X-MS-TrafficTypeDiagnostic: BYAPR12MB3045:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O+KpSNg+VQuj8fXqfoiknauVU8TsPoL+JUBxFPfRoBX/1GwjyvmYboa6fd7Rx5NVWo/l4R6VfGJ+AtANgFpfxhnh9yHvpBcoLkQGcE9NK+SvTBJEJkvn1CBhlJVwcretT0Elk59HktdRDpsLh9uq2QC1RqDssYYvmiip13IpoRhrb7mmMWCh/lWQLQMiLL52PjueEtCEMdFRp4y/d5UTwejhGvysUg6G1jB3ETitUb1++WuHRdm2IQkGwGgsDdGwPW2Knmi98xsLptZFcgIrdHHgoTPWYU0vXjIY7lDw9lWpk64s3VsE51tgtzr8q4tx4Rin44rrfvRQHs7xv752AdJXoftldDuhnm2ze4MjCNJPVgE4/vidM6oNW+pJMZHEDW+WdfIbhmrNzn08VRuvWTcCv+rEDnv9C4Tn9HztouvDaUoFO9XY/2+Cm2tf2z4bZsIrhBv9rqOkX0jyESbecTTzTdXBpJYzOhcrtF3pzWMfVSZOywkTOS1T2U7dZeazovUUxgQMbjMs+yeFTpzaKTM+GmxRqhe2W5xTELMkIeMEs4NriXikgmHW9MBz5GaT4whHa7MCasXF9Cobb5tv2yclm6BGfByASJ2Se/q6VCDShAIArrQcwyeTVR6SgkTqEf1V17bUI4o1UZfQjj+ci+C3bhC9N0SwyB68EaHol9JLN1eRxWFGLjOZ7XaaBjLuZmmAno9/9QtnTcYiuBva9Riat4NEKxB/e1ld68y8/5M= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3587.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(6486002)(38100700002)(6666004)(36756003)(6506007)(31686004)(83380400001)(508600001)(110136005)(2906002)(4326008)(86362001)(316002)(6512007)(7416002)(31696002)(5660300002)(26005)(186003)(66476007)(66556008)(8676002)(2616005)(66946007)(8936002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dGljZGFIa2pxWkVaWnZMcTNIajAxbkNvaEppNmkzZzVKdFBxalBnNHN6czFa?= =?utf-8?B?VEVYNUxDakZHL253VWJEdXBOSmxsNmoxNTVzUHdwQzJLSkpyNUV0SkowaU1O?= =?utf-8?B?eGFCVjQvMVVrT1ljclA3Z0laOWgzb2hTZnRtZC82bk8zNFZtUjJQanRPNnVt?= =?utf-8?B?Kzk5dDBxY20yZks4eHhuU0VSTmJnbTdnRmI3Ti9FeW1naWc4dVdsMHZMTkxi?= =?utf-8?B?OGg1U2tQMk1rKzR1Yzh0VWFUNGN2Nk9FNXhwWTZxNFJCcHgzYTN0dzhjMzhk?= =?utf-8?B?NVhIWHdJUmYvM1dyRTVITzZqMVJFS2Y3WDRVNG5QYVRvVStlTk5CaEJsdUNU?= =?utf-8?B?SFVK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message-Id: 6da3efe1-05ab-4d7f-5c1f-08d9fdb19b98 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2022 07:35:51.4096 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Pu69Q1u5fSSgNOD/ALrmfaJwvtCXxCGyKdW+yRafzg0rkd0y5+mX2mvEo0y+lyw9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3045 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no 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 Am 03.03.22 um 17:17 schrieb Michael Walle: > 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. > > Cc: stable@vger.kernel.org > Signed-off-by: Michael Walle > --- > > I'm not sure if or which Fixes: tag I should add to this patch. The issue > seems to be since a very long time, but nobody seem to have triggered it. > FWIW, I'm using the sff,sfp driver, which triggers this. > > drivers/i2c/busses/i2c-at91-master.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/drivers/i2c/busses/i2c-at91-master.c b/drivers/i2c/busses/i2c-at91-master.c > index b0eae94909f4..a7a22fedbaba 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; Maybe call your variable differently. DMA-buf is an inter driver buffer sharing frame we use for GPU acceleration and V4L. It doesn't cause any technical issues, but the maintainer regex now triggers on that. So you are CCing people not related to this code in any way. Regards, Christian. > > dev_dbg(&adap->dev, "at91_xfer: processing %d messages:\n", num); > > @@ -703,7 +704,18 @@ 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: