Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3045553pxf; Sun, 14 Mar 2021 22:56:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxREHHAtz8KWLQSSBfEprq2JB4UC+KHCqo3Q1CWdvf8Vi8pCbemmNnnFLJWeIdZ8tgwuUBf X-Received: by 2002:aa7:db15:: with SMTP id t21mr28086625eds.145.1615787805551; Sun, 14 Mar 2021 22:56:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615787805; cv=none; d=google.com; s=arc-20160816; b=vWgzpLKKUeVHG2HhUGc9VuEwhN3mpziqCelQBYJhqea4nkt3nzl2LdGmhbULY6B5FD Mz8sd3bcu2mqv+g/0iGOhD00p3WcNoVpEzXUcLPbKGtmkFVnci+O+dbZGLR/JX3F2lFD xVH5vXlmt3K4UTC5xWgShc+M/3YkPNWAysk8KjkvvYMCqJSAlbVNT89ud/oPjeLSqZDH N2blrgr+fxOVuHRss74nTnD/D0IlHOg0+wS9VJf5dpINdwgu+PnQsPg8bNBG1cKbAjlg kYLKQyyXK1KXGy+0E5CuCW789LmoeE7SMW4fb7ZcNy6Jp0dv1POHedNYA08o1OLh6U+S xMaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=aCW+A6ZJxkC1f107C7NLtbNZRhkvkQy2GGc+7Wmcwmg=; b=tXN5suhMtQj0E8sv48Q3/fUZIX/5cD4M/SALjrqjnEp5J+rg8DuWf9QiJZwrfsKnek SjW27oInM+ytOn7M3DGxobo85nrjzSbtYf6q4omEBWIFqZCidoe714Lkk0s7NUqhzk3Y KqScyf3oXjXJYeGEytk5H/bpyvUf4/yWIU7FG2VnyV2+eYYDRbYuOgC2grRAgMH70Wit QgqUdiU210PAwcU0aPcaPRBokLQTn4PUJUYMGpAixknfpcAXk/9A48bP/fja85j0m+hf k+g+5r9I4rAYLNcbe32s+L+U/FX4xqTzn4kGWozNT5F2+a11FjTuRrqNOo2qU8iWXOj7 NxCA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e19si9838172ejj.523.2021.03.14.22.56.23; Sun, 14 Mar 2021 22:56:45 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229594AbhCOFxR (ORCPT + 99 others); Mon, 15 Mar 2021 01:53:17 -0400 Received: from mga12.intel.com ([192.55.52.136]:35239 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229699AbhCOFxA (ORCPT ); Mon, 15 Mar 2021 01:53:00 -0400 IronPort-SDR: SY972kZyzC9P/OPQu2L3Vfr6om02ydiPAugmLorZkDDsBf1guqNx9Ou1RwYk2zkzfYYyJUawu5 9pwVZPDYw4RA== X-IronPort-AV: E=McAfee;i="6000,8403,9923"; a="168310479" X-IronPort-AV: E=Sophos;i="5.81,249,1610438400"; d="scan'208";a="168310479" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2021 22:53:00 -0700 IronPort-SDR: Vbn6tI6GeandlErHLWZ2Q0OMzbleTZHw1ExsM5qz1JDna29LuzmP1mXar3JCw9pqCGXbdan6KS qlSar8SGB75Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,249,1610438400"; d="scan'208";a="601313453" Received: from unknown (HELO [10.239.154.55]) ([10.239.154.55]) by fmsmga006.fm.intel.com with ESMTP; 14 Mar 2021 22:52:54 -0700 Subject: Re: [PATCH v7] i2c: virtio: add a virtio i2c frontend driver To: Jason Wang , Arnd Bergmann Cc: Linux I2C , virtualization@lists.linux-foundation.org, "linux-kernel@vger.kernel.org" , "Michael S. Tsirkin" , Wolfram Sang , Wolfram Sang , Andy Shevchenko , conghui.chen@intel.com, kblaiech@mellanox.com, jarkko.nikula@linux.intel.com, Sergey Semin , Mike Rapoport , loic.poulain@linaro.org, Tali Perry , =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= , Bjorn Andersson , yu1.wang@intel.com, shuo.a.liu@intel.com, Viresh Kumar , Stefan Hajnoczi , Paolo Bonzini References: <8070f03d-8233-636b-5ea9-395e723f7a2c@intel.com> <503b88c9-1e82-a3a3-0536-d710ddc834a5@redhat.com> From: Jie Deng Message-ID: Date: Mon, 15 Mar 2021 13:52:53 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <503b88c9-1e82-a3a3-0536-d710ddc834a5@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/3/15 11:13, Jason Wang wrote: > > On 2021/3/15 9:14 上午, Jie Deng wrote: >> >> On 2021/3/12 16:58, Arnd Bergmann wrote: >>> On Fri, Mar 12, 2021 at 2:33 PM Jie Deng wrote: >>> >>>> + >>>> +/** >>>> + * struct virtio_i2c_req - the virtio I2C request structure >>>> + * @out_hdr: the OUT header of the virtio I2C message >>>> + * @buf: the buffer into which data is read, or from which it's >>>> written >>>> + * @in_hdr: the IN header of the virtio I2C message >>>> + */ >>>> +struct virtio_i2c_req { >>>> +       struct virtio_i2c_out_hdr out_hdr; >>>> +       uint8_t *buf; >>>> +       struct virtio_i2c_in_hdr in_hdr; >>>> +}; >>> The simpler request structure clearly looks better than the previous >>> version, >>> but I think I found another problem here, at least a theoretical one: >>> >>> When you map the headers into the DMA address space, they should >>> be in separate cache lines, to allow the DMA mapping interfaces to >>> perform cache management on each one without accidentally clobbering >>> another member. >>> >>> So far I think there is an assumption that virtio buffers are always >>> on cache-coherent devices, but if you ever have a virtio-i2c device >>> backend on a physical interconnect that is not cache coherent (e.g. a >>> microcontroller that shares the memory bus), this breaks down. >>> >>> You could avoid this by either allocating arrays of each type >>> separately, >>> or by marking each member that you pass to the device as >>> ____cacheline_aligned. >>> >>>        Arnd >> The virtio devices are software emulated. > > > This is not correct. There're already a brunch hardware virtio devices. > > Thanks > Then do you think it is necessary to mark the virtio bufs with ____cacheline_aligned ? I haven't seen any virtio interface being marked yet. If this is a problem, I believe it should  be common for all virtio devices, right ? Thanks. > >> The backend software may need to >> consider this since it may exchange data with physical devices. But I >> don't think >> we need it for this interface, because no DMA operation is involved >> between the >> frontend driver and backend driver. >> >> Regards, >> >> Jie >> >> >