From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A15AC433EF for ; Mon, 1 Nov 2021 17:33:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 49B9B60E52 for ; Mon, 1 Nov 2021 17:33:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 49B9B60E52 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6fwOxFy7r2F+o/365v0+wLRAIjzyN4erjDsBqkDIyuw=; b=VAjca3SseV1hjG on2mRB1Vv6FzR/uyEnuMUme40zdpbD7xDkxK6XPuX0jzE+mc4ULXjavI0+O3yREC96pQ5SkQJpSm9 00PcqpBnzCQ6RMBMYEHPjrsNQ8489BjEaBf5cLOMEiupjny/gzpYHzidgI9vnJ4lAskAwfkrqL0+R GbY8UU9QK2bTQDrsTCq8ru+wDN3eCyr4t8rnL2McX3z6AaQxxBIfRqfbEgnxpfqdIuMdn/oiT/JP3 WIXTTeii6OKNaWJhRv+/JqAW+qyveET82x8z2vlgmTcKOJY5tHiu0nrDrK7Atlj6OH+/97e4eVqMq J8GhOz55RB+JchsoL5HA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhbA1-00GuV2-Ce; Mon, 01 Nov 2021 17:31:53 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhb9x-00GuTt-2s for linux-arm-kernel@lists.infradead.org; Mon, 01 Nov 2021 17:31:50 +0000 Received: by mail-pl1-x62e.google.com with SMTP id p18so8701315plf.13 for ; Mon, 01 Nov 2021 10:31:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=NtXayfTUJqN0+HnL18EFdYPTjw8r+9ANxCl9WnYlDq8=; b=Voisx85ftQ9ebXLfKeWT0X2TDAchK9ZJ5g6bI2MkUr27Rms+2MCI5wdkc9NM+aI3L7 PIod2Fxk6BGbz/JSbHuIpVOuAAa1wkx6btD6dNUf00nU/Ucfk22S0T/fndYSvrOEnsIS wlvk6doBhqvOEuuQoukZ44SDZSoatTrTma/IeW+Ju3/3ktTACSFVZgx//Eezf8Xmh2Nx dOhk8v3NSeFo/pOfqDUyCSgd4nwiIAGmKMqkUpXeFnOTyhjRw8nczRX0g9Vo8hQI8+o1 +P6UY/TJo2rBYhNeoEJpDx5xSDSViK5elD12VITHXChm7D5an8+tjbTqDjUWHtDMmfZ9 Uz4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=NtXayfTUJqN0+HnL18EFdYPTjw8r+9ANxCl9WnYlDq8=; b=ayOOxnXD3k93oQw1Sl3klDJ3ZSxWY4FfndWdPfk6Sts5FwXxoqhW5WylLF2sB1QeFv hws+mp50OXkTNK8Jxx8PVPBEbTrinHBmviY/Evo8MWQEHs/thFKv456ebFdvtwonI5dU zXnSaPwNwdA5U/cMzRwfLoyIC9oCtqRwpOhCh9jRdjEINRrKJKtJ9Dw1J+thqvmWwdQe xpEkr3xk6vLVq+5XsYdFwI4xKgWPjB/T/UusLhc33o3BShagDhFVrvyjIT8ClIKLzLek Yhq3mvLbQx/oIsrEGgyXXsAtPwzmmFcaiGq06OGZsIFzm8k5pQWp2PJeNlbEkdwL36fG IATg== X-Gm-Message-State: AOAM533vKJrgqvtbHeraMeyl+xii1SngeoQSBKC2bHM/Tf+lhU0NQeuw SovZAgjzUin/EKUHKe71gw4= X-Google-Smtp-Source: ABdhPJxcYS501VmNX6gHmkSUboOHq80KnozPWaDUu/SJ7HdJd6F2DxV0pqHKuSXV2xOvQuTdkccByg== X-Received: by 2002:a17:902:bd94:b0:13f:f96c:aa22 with SMTP id q20-20020a170902bd9400b0013ff96caa22mr26544710pls.43.1635787908362; Mon, 01 Nov 2021 10:31:48 -0700 (PDT) Received: from ojas ([122.161.50.72]) by smtp.gmail.com with ESMTPSA id ls14sm77889pjb.49.2021.11.01.10.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:31:48 -0700 (PDT) Date: Mon, 1 Nov 2021 23:01:21 +0530 From: Ojaswin Mujoo To: Stefan Wahren Cc: nsaenz@kernel.org, gregkh@linuxfoundation.org, dan.carpenter@oracle.com, phil@raspberrypi.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] staging: vchiq: Replace global state with per device state Message-ID: <20211101172843.GA17771@ojas> References: <5b51970f601c4bf5165fc70174085a809b3c0316.1635764115.git.ojaswin98@gmail.com> <84300618-98c8-0f44-e5a5-8d7fd6c853b0@i2se.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <84300618-98c8-0f44-e5a5-8d7fd6c853b0@i2se.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211101_103149_169296_AF7FC5A6 X-CRM114-Status: GOOD ( 27.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Nov 01, 2021 at 01:19:17PM +0100, Stefan Wahren wrote: > Hi Ojaswin, > > Am 01.11.21 um 12:09 schrieb Ojaswin Mujoo: > > Currently, the driver has a global g_state variable which is initialised > > during probe and directly used all over the driver code. However, this > > prevents the driver to support multiple VideoCore VPUs at the same time. > > > > Replace this global state with a per device state which is initialised > > and allocated during probing. > > > > Signed-off-by: Ojaswin Mujoo > ... > > > > /* > > @@ -1763,6 +1795,7 @@ static int vchiq_probe(struct platform_device *pdev) > > struct device_node *fw_node; > > const struct of_device_id *of_id; > > struct vchiq_drvdata *drvdata; > > + struct vchiq_device *vchiq_dev; > > int err; > > > > of_id = of_match_node(vchiq_of_match, pdev->dev.of_node); > > @@ -1784,7 +1817,18 @@ static int vchiq_probe(struct platform_device *pdev) > > > > platform_set_drvdata(pdev, drvdata); > > > > - err = vchiq_platform_init(pdev, &g_state); > > + vchiq_dev = kzalloc(sizeof(struct vchiq_device), GFP_KERNEL); > > + vchiq_dev->state = kzalloc(sizeof(struct vchiq_state), GFP_KERNEL); > > + vchiq_dev->vchiq_pdev = *pdev; > > + > > + g_state = vchiq_dev->state; > > + > > just a quick idea: how about storing the global state within vchiq_drvdata? > > So there is no need to reinvent somekind of vchiq device which is the > "same" as the platform device. After that you are able to access the > private driver data via platform_get_drvdata(). Hi Stefan, Thank for looking into this. I agree that the vchiq_device is just a sorta extension of the pdev. However, regarding using the drvdata, I had some questions. So I understand the purpose of this patch is to make sure our driver is able to support multiple devices, that is it can work with say, an SoC with 2 VideoCore VPUs. In this case, we would need to maintain 2 states for each VPU instead of a global state, however if we use something like the following: drvdata = (struct vchiq_drvdata *)of_id->data; drvdata->state = kzalloc(sizeof(struct vchiq_state), GFP_KERNEL); platform_set_drvdata(pdev, drvdata); Correct me if I'm wrong but I think the assignment to drvdata in line 1 above will return a pointer to the same structure. In which case, the line 2 will always overwrite the older state that is present. That's why I was initialising a separate object (vchiq_device) everytime the probe was called so that each device can have their own device specific structs. Please let me know if my understanding of drvdata is wrong here. > > Best regards > Thank you! Ojaswin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel