Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1131754pxf; Thu, 18 Mar 2021 22:42:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1R5jdsc469QRBIdnt7Wl4dte1ECR40kgfXBhvCs5SckqFmRzoO3mvckMSdzUsbaAloxYS X-Received: by 2002:a17:906:4955:: with SMTP id f21mr2510001ejt.74.1616132530271; Thu, 18 Mar 2021 22:42:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616132530; cv=none; d=google.com; s=arc-20160816; b=TFf6OmFcutcfQdYbzyOYtou3LO2WECqYT+stixQj4sGnp1EmPigP2l2NACxLbKIWP4 1/JDI/RBCGZhI9dHDNczm9tTAGrVO8gKrcMeNtcRvcF9wR+GkKJqxdJBmillZhgLRYyP dhYD2H4eNLwNfhQtCzo5jU5SrSscPU23X57lCBc+a6+aBCNBZbP89jgq8SjBp8ByvxgI csy58sV0MnYI1kS654Q5OldFUtR9OzB2KiQMKv7Lmr3t4+3SYv0+R57qMWyoveEqiz7h qw6bmPZUSZPhMRUqiWHd5wqmNTTfT5Bns0YlyUmwCK8+w5GOENkpzmwk8LyWO6JdhdF7 YKPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=5x5odp979WLlXOJ6f4tJdUumqOt4vIxvWJ/PSurH5YU=; b=eDUyl5FPsw1LTrgL2EErp/46Oqg2FLA648gF59eG0GkNz9/nEfUDGx0bnmG7Rb6+IO 58dfaTv66OnT6xYH2gb44wMz2jYOh08xwf2uyuf8lBRVdPmhgyEFaqERUG8ro3VkWCJy J43Vs1cOm3dDMJgVjTTd6ShYNeXGA4OGmf4JWnPEwBRcNrMIOTcmSWqqCi3eRFwiyioG 1iv5TJzREffj9l5xqnZzXU4DG3uU3Kt8/qsbP1HRRnFzuoMCC67Nx7NxwXD9LRfNDEPs gVAbyn12O4cWuxbx5nDgxGtILLnKNAkuL34kTb1cQdscyi0HgRTHGpQEnmZl3yocYN9K mZ5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O5MoIDuB; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s28si3115527edw.110.2021.03.18.22.41.46; Thu, 18 Mar 2021 22:42:10 -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=@linaro.org header.s=google header.b=O5MoIDuB; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233743AbhCSFks (ORCPT + 99 others); Fri, 19 Mar 2021 01:40:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233756AbhCSFki (ORCPT ); Fri, 19 Mar 2021 01:40:38 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49BAAC06174A for ; Thu, 18 Mar 2021 22:40:38 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id ga23-20020a17090b0397b02900c0b81bbcd4so6204482pjb.0 for ; Thu, 18 Mar 2021 22:40:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=5x5odp979WLlXOJ6f4tJdUumqOt4vIxvWJ/PSurH5YU=; b=O5MoIDuBIiaRpqaMmMntsxJHfiJlwp/xwuI0glHnfA7PqqqmUaH4ttcw53qTWVbwAo biZg2EXn7OtYFAK8R8GeA7nOGZpX4H1Dz3epp+PYQvcQIszCTaWoXyKQD4WFBNKpvVw3 KmU/hDS7/LfdlDl5JXKVS9UTvbQg0BylSZ8Of2GplJaaU1LEu73ks0DTAiOTuisLzNLQ r/jQ6hqXhS5tnyD6Wj84LbwwdbLg+jqSLaOzK0YEflxycdPxUwhXRLxC18ScUGuMZypT mmRv/TLOo0ZuNQVOi4Dit8C9UXWoB13NnrERnyV8bQgzYiu0Pk0Ske0i6WTn7o4ivQPq 5PXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=5x5odp979WLlXOJ6f4tJdUumqOt4vIxvWJ/PSurH5YU=; b=dMRdhfbVCZZnvjgJz6mVkeKV5Xfobk62wdJqrSIU70gghOAYa/lToymJPGusyYBZdS Xbflz8S/oMQ6KsUmnz/H6JYHRRTQOwb1vE0S5q9w/DjSQbBO8w0lM3xNR2QHksdOmhr2 uB6AQE1V2fAGdsOI3POoZcmfU6kHhAlghafYIG7N+eMNG8sVbT69JCM4Fe5lVXtUC+ip kzAjsWXllpfHKj3f7bHCQKJabHlYY/vzU09usu4AWIVJ6X+NgRZEvunRtKVoRlhSydd4 yRPWBsl84uv1LVeSEVIa3Kb04JGaRXc0WAuRMtqRXzp6SVH/ZOsWSIhtxZhyISaoCimv +hlQ== X-Gm-Message-State: AOAM532FWSqoh2jbeApD1zW5vT7mjnZ1MQcMMUI359TZ+khls8vkYKnV 8vPQp6R1F4G5CmP8iuZWLZk4dg== X-Received: by 2002:a17:90a:f40c:: with SMTP id ch12mr8055908pjb.176.1616132437613; Thu, 18 Mar 2021 22:40:37 -0700 (PDT) Received: from localhost ([122.171.124.15]) by smtp.gmail.com with ESMTPSA id j3sm4187463pjf.36.2021.03.18.22.40.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Mar 2021 22:40:36 -0700 (PDT) Date: Fri, 19 Mar 2021 11:10:35 +0530 From: Viresh Kumar To: Jie Deng Cc: Arnd Bergmann , "Enrico Weigelt, metux IT consult" , Linux I2C , virtualization@lists.linux-foundation.org, Linux Kernel Mailing List , "Michael S. Tsirkin" , Wolfram Sang , Jason Wang , 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 , Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= , Bjorn Andersson , yu1.wang@intel.com, shuo.a.liu@intel.com, Stefan Hajnoczi , Paolo Bonzini Subject: Re: [PATCH v8] i2c: virtio: add a virtio i2c frontend driver Message-ID: <20210319054035.47tn747lkagpip6v@vireshk-i7> References: <20210316074409.2afwsaeqxuwvj7bd@vireshk-i7> <0dfff1ac-50bb-b5bc-72ea-880fd52ed60d@metux.net> <20210319035435.a4reve77hnvjdzwk@vireshk-i7> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716-391-311a52 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19-03-21, 13:31, Jie Deng wrote: > > On 2021/3/19 11:54, Viresh Kumar wrote: > > On 18-03-21, 15:52, Arnd Bergmann wrote: > > > Allowing multiple virtio-i2c controllers in one system, and multiple i2c > > > devices attached to each controller is clearly something that has to work. > > Good. > > > > > I don't actually see a limitation though. Viresh, what is the problem > > > you see for having multiple controllers? > > I thought this would be a problem in that case as we are using the global > > virtio_adapter here. > > > > + vi->adap = &virtio_adapter; > > + i2c_set_adapdata(vi->adap, vi); > > > > Multiple calls to probe() will end up updating the same pointer inside adap. > > > > + vi->adap->dev.parent = &vdev->dev; > > > > Same here, overwrite. > > > > + /* Setup ACPI node for controlled devices which will be probed through ACPI */ > > + ACPI_COMPANION_SET(&vi->adap->dev, ACPI_COMPANION(pdev)); > > + vi->adap->timeout = HZ / 10; > > > > These may be fine, but still not ideal I believe. > > > > + ret = i2c_add_adapter(vi->adap); > > i > > This should be a problem as well, we must be adding this to some sort of list, > > doing some RPM stuff, etc ? > > > > Jie, the solution is to allocate memory for adap at runtime in probe and remove > > the virtio_adapter structure completely. > > > If you want to support that. Then I think we don't need to change the > following at all. > > > +??? .algo = &virtio_algorithm, > > + > > +??????? return ret; > > + > > +??? vi->adap = virtio_adapter; > This is strange, why are you allocating memory for adapter twice ? > Once for virtio_adapter and once for vi->adap ? Either fill the fields > directly for v->adap here and remove virtio_adapter or make vi->adap a > pointer. Yes, your previous version was partly okay but you don't need the virtio_algorithm structure to be allocated. There are only 4 fields you are updating here, just fill them directly in vi->adap. (FWIW, I also suggested the same when I said "Either fill the fields directly for v->adap here and remove virtio_adapter". ) See how drivers/i2c/busses/i2c-versatile.c and most of the other drivers have done it. -- viresh