Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp360971ybz; Tue, 21 Apr 2020 23:02:56 -0700 (PDT) X-Google-Smtp-Source: APiQypKWL1zj9C1lZjzWQP3EN5Ml//jscKeaADH/bPEbYVRfpU+a/tou9dVELfgLZ2gTNr6nf+ON X-Received: by 2002:a17:906:70d5:: with SMTP id g21mr6173979ejk.322.1587535375826; Tue, 21 Apr 2020 23:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587535375; cv=none; d=google.com; s=arc-20160816; b=hlAfOtmcAnAv6VpkG1X4nxPANF/101h3tMndVQTd2eNSDUxZ5cujhASQW1ojuhe/XO /tpFg7to6sgBuMZ0WVJv2fUucvVDeqUjLBYdE1veeWTGaMNECCdcBVWp3EZt5uelze2p L/B2hoiYIzV5xx5vFk8hOE/Qaqg3LFAalJ7yeEv7VUIcyEIs6bmbJCx7+XdMDohT42Td MSwWo0bHw6lFY7rwFtajuyqJf4AXXv3ZrNoWsEIGzObkxyqcbqxlfQpWASBvjJwEDWWm fGuxofw1jT4mSNJZldBUV9TsJ+0BTp6VJqqKMMA8dqZyqT9JLFMbzBH9wtCEoKGrfSal 6/og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=2LuMMbBz8IDypyUGABj1JHks4OFM80gtIkiIwW1LUpM=; b=0wHyO1s/uBBmOlnuQJ1Elxx9Wggf6gp2E5gHlSnmeQJp+Zgf5IqRbTht1eYxSNvdZR PteqJAgb5vCsia8gnXpKVwoeuiWEQHbQcC+JPqPj2vYnOwA/7ehwqersGJjdwdjGAUzA Nc9QSk3UK1jhQ4FJaFzzjpPJaSO/yJVj9CTFnZVq9Bgn/R8+wxUvQ+movgGaTIYSV87t /+DyJWdidSTKixdg1vr7Q/jOZo3bour5KOsQwtxxDl0cSGlSjKgalPIRC/4KLGZ0tJDy zsPYPXanmOMzsK1ULg1o6LydxkCMQlbTXp+WcMale/uh/yZYcJjC026/RfhcjUkfMNFH V8pQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l24si2892809eja.496.2020.04.21.23.02.33; Tue, 21 Apr 2020 23:02:55 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726495AbgDVGBd (ORCPT + 99 others); Wed, 22 Apr 2020 02:01:33 -0400 Received: from mail-sz.amlogic.com ([211.162.65.117]:29025 "EHLO mail-sz.amlogic.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbgDVGBd (ORCPT ); Wed, 22 Apr 2020 02:01:33 -0400 Received: from [10.28.39.241] (10.28.39.241) by mail-sz.amlogic.com (10.28.11.5) with Microsoft SMTP Server id 15.1.1591.10; Wed, 22 Apr 2020 14:02:22 +0800 Subject: Re: [PATCH v2 2/2] watchdog: Add new arm_smc_wdt watchdog driver To: Evan Benn , Julius Werner CC: LKML , Guenter Roeck , Anson Huang , Bjorn Andersson , Catalin Marinas , "David S. Miller" , Geert Uytterhoeven , Greg Kroah-Hartman , Leonard Crestez , Li Yang , Marcin Juszkiewicz , Matthias Brugger , Mauro Carvalho Chehab , Olof Johansson , Rob Herring , Shawn Guo , Valentin Schneider , Will Deacon , Wim Van Sebroeck , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , "moderated list:ARM/Mediatek SoC support" , LINUX-WATCHDOG , Jianxin Pan , Yonghui Yu , Xingyu Chen References: <20200421110520.197930-1-evanbenn@chromium.org> <20200421210403.v2.2.Ia92bb4d4ce84bcefeba1d00aaa1c1e919b6164ef@changeid> From: Xingyu Chen Message-ID: Date: Wed, 22 Apr 2020 14:02:21 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Originating-IP: [10.28.39.241] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi,Evan On 2020/4/22 9:39, Evan Benn wrote: > On Wed, Apr 22, 2020 at 6:31 AM Julius Werner wrote: >> >>> +static int smcwd_call(unsigned long smc_func_id, enum smcwd_call call, >>> + unsigned long arg, struct arm_smccc_res *res) >> >> I think you should just take a struct watchdog_device* here and do the >> drvdata unpacking inside the function. > > That makes sense, I avoided it because smcwd_call's are made during > 'probe', ~while > we are 'constructing' the wdd. But this is C, so I think I have > permission to do this! > >>> +static int smcwd_probe(struct platform_device *pdev) >>> +{ >>> + struct watchdog_device *wdd; >>> + int err; >>> + struct arm_smccc_res res; >>> + u32 *smc_func_id; >>> + >>> + smc_func_id = >>> + devm_kzalloc(&pdev->dev, sizeof(*smc_func_id), GFP_KERNEL); >>> + if (!smc_func_id) >>> + return -ENOMEM; >> >> nit: Could save the allocation by just casting the value itself to a >> pointer? Or is that considered too hacky? > > I am not yet used to what hacks are allowed in the kernel. > Where I learned C that would not be allowed. > I assumed the kernel allocator has fast paths for tiny sizes though. > >>> +static const struct of_device_id smcwd_dt_ids[] = { >>> + { .compatible = "mediatek,mt8173-smc-wdt" }, >>> + {} >>> +}; >>> +MODULE_DEVICE_TABLE(of, smcwd_dt_ids); >> >> So I'm a bit confused about this... I thought the plan was to either >> use arm,smc-id and then there'll be no reason to put platform-specific >> quirks into the driver, so we can just use a generic "arm,smc-wdt" >> compatible string on all platforms; or we put individual compatible >> strings for each platform and use them to hardcode platform-specific >> differences (like the SMC ID) in the driver. But now you're kinda >> doing both by making the driver code platform-independent but still >> using a platform-specific compatible string, that doesn't seem to fit >> together. (If the driver can be platform independent, I think it's >> nicer to have a generic compatible string so that future platforms >> which support the same interface don't have to land code changes in >> order to just use the driver.) > > Yes I think you are correct. I got some reviews about the compatible name, > but I think I misinterpreted those, and arm,smc-wdt would work. I did wonder > if Xingyu from amlogic needed to modify the driver more, EG with different > SMCWD_enum values for the amlogic chip, he could then just add an > amlogic compatible > and keep our devices running with the other compatible. Although of > course it would be nicer if > the amlogic firmware could copy the values here. Using DTS property(arm,smc-id) or vendor's compatible to specify the Function ID is available for the meson-A1.The generic "arm, smc-wdt" looks nicer for MTK and Amlogic sec wdt, but the driver may not cover the other vendor's platform-specific differences in the future, so the platform-specific compatible string may be introduced eventually. But again, I can accept the two methods above. Thanks > > Thanks > > Evan > > . >