Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp594957pxb; Wed, 24 Feb 2021 09:48:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJyGHbLV3m8DMvfrJSC1Mo3xOHHsYyMTVDxENUfqVsjaYdLarAbNPAi9mNZOfjL7dyznLAO1 X-Received: by 2002:a17:906:2a8b:: with SMTP id l11mr32329842eje.1.1614188901581; Wed, 24 Feb 2021 09:48:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614188901; cv=none; d=google.com; s=arc-20160816; b=DkGemYVBuXmxe91w83CBLHEDEKz9zAnxKZfA+a2o//7Ilb5GJArVLmMtIKMkJQQgxy YFdezsPE2J29rkz1XbTZRWiDaz5ot4jeeSQvZq7NlERrSD4SruMNfJPkbfrLpIR6Pz0y UFiu6paq4K35A3bMLkCrNwEM60nONKt1msy1gpYc4YbMGl5J9QQYsR169zStFcjUTMRv 1+4tTmC86/W0Yf8b2jbj7gUts9TjuBzzpEyZfbJrWaFGK6Pxv3ouzNzAf7wdDsxJtIY8 VBXIu2s+zT44ybN2yGdeOBr5yoffPueDlxstbALHACkn1tvwW60kCvMH0Jbv8Jt4Ba1h AofQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=szGV+7aObjZoi5mnUKGEjRtKB5YQVvCFN71VukUYruI=; b=TtGiTU9FMvx2JJwdd8EfMwqs7a+3F8UagLn/lb2rpOPVAV6REMQK8vPa1tulJTpoNy VXChyAMqXVxwQ2nF7kuKum2x0ziYHjDWdkJZFNLTVRRbUBGVOb3ahPT8Hoj+s4Ymh7jZ xhzf1+mJdXsknPnxDKojCoyksrno04QbRmVdau2g3bePGE04SdUFpt/O+WHvM39tevoT 7rMAqe4a6BYrfQuw7Q+xgYbIXzeTCaAdFqKI7TfWu9NODGXzZL+c4DqKx5RKZwQWws/N vsA75sjmM5I7AkB0aIiGAjrgbQsJ2Pb2pIPD/p+gmDHTDumez7H5S/gvtazQ5J5IVF0Y cF2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OFaiKo+V; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e11si1677980edz.97.2021.02.24.09.47.58; Wed, 24 Feb 2021 09:48:21 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=OFaiKo+V; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235867AbhBXRqK (ORCPT + 99 others); Wed, 24 Feb 2021 12:46:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229644AbhBXRqJ (ORCPT ); Wed, 24 Feb 2021 12:46:09 -0500 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BDFDC06174A; Wed, 24 Feb 2021 09:45:28 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id b21so1923064pgk.7; Wed, 24 Feb 2021 09:45:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=szGV+7aObjZoi5mnUKGEjRtKB5YQVvCFN71VukUYruI=; b=OFaiKo+Vy4oRCwbsHopxZe7ZEjUg43O4CmTWU78wzLDY6tN35JJOqhGwfs6cPNXqJw 7IUZRrHees1aUOTPvy8zUzrZdB2JUbdJJVV38NDQLM2S+HLKIx9c475ahyaNhg32eq8t 05creesKrWyX+BhBxgoJJPUCa2EKnnEuz8q7m4fwuW6evSn9o/28pkvX60pqpQNfBUsk MrHO0qaeqno1QE/cOgPCq9JrO5sIwQ4JReo4ipDU6r399cbGu4x0fu70dkPH4k3e7fTX jpchjTM+T0nOjMmtHRsCcd4PSlzPAxl1qkoLVO58rMQcFwRM3weqdp21Vt7KVJR113WH RdoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=szGV+7aObjZoi5mnUKGEjRtKB5YQVvCFN71VukUYruI=; b=EWJZSAydJlxKxS6eLhlDxXyDg0o6W+emUHif1Dq1d1MohClIHki1aWV1JQr/ONT5mY UZfPtXqr9Ul1bhFhQC8/g0y4YhU0db7qoL0E+9rlLG4tVgVV8Vspuv0F3RiDuLT5wM/Z npZP904Txbfjsaa4w2lxhNH/8IiunaNbbma0wOEuQmp28++aYhDpE64pMUru9rtpZyWv IIFc51C6+AB/AsRz12JBNqqeZ3nhnI21K4j0Lz2t5CBl2gH/yZ7k/uzTq0ONRRdtgh/c ++rWcJKNK2qZ1QMsX0OoV5qS/4YI5BbLtYPR5tv2dT1Ky/MKvG5zErb5D0OfxtZt46jd jf5w== X-Gm-Message-State: AOAM533BkBHqur2OZh9ITOUxPTQJza32eKqmUOgEfk8hGpgU0u3I31v1 hoG/nWnL+Ce3rN0/ygTGWChhXTfHyGo= X-Received: by 2002:a63:e614:: with SMTP id g20mr18466910pgh.275.1614188727360; Wed, 24 Feb 2021 09:45:27 -0800 (PST) Received: from [10.230.29.30] ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 190sm3510749pfv.155.2021.02.24.09.45.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Feb 2021 09:45:26 -0800 (PST) Subject: Re: [PATCH 1/2] leds: bcm6328: improve write and read functions To: Pavel Machek Cc: =?UTF-8?Q?=c3=81lvaro_Fern=c3=a1ndez_Rojas?= , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210223081732.9362-1-noltari@gmail.com> <20210223081732.9362-2-noltari@gmail.com> <20210223083449.GA9750@amd> <3826ACDE-EFF2-4CC5-82EE-2DBC991CF996@gmail.com> <20210223085819.GB9750@amd> <20210224173649.GA10809@amd> From: Florian Fainelli Message-ID: Date: Wed, 24 Feb 2021 09:45:25 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210224173649.GA10809@amd> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/24/2021 9:36 AM, Pavel Machek wrote: > Hi! > >>>> Yeah, but ideally you should not be copying comments; there should be >>>> one central place which does it and does it right. >>> >>> I’m open to suggestions :). >>> Which central place would be a good place for you? >> >> I did consider creating an include/linux/brcm/brcm_io.h header or >> something like that but I am really not sure what the benefit would >> be. > > Less code duplication? It is immediately clear that driver including > this is specific for brcm SoCs and would not try to work somewhere else? Yes maybe, there still does not feel like this deserves a shared header, but as long as the generated code is the same, why not. > >> As far as using _relaxed() this is absolutely correct because the bus >> logic that connects the CPU to its on-chip registers is non re-ordering >> non posted. That is true on the MIPS BE/LE and ARM when configured in LE >> or BE. > > If that's right on particular SoC, then _relaxed and normal versions > should be same; drivers still need to use normal versions, because > they may be running on different SoC...? readl() includes barriers and read_relaxed() does not, hence the difference in the name. There is no need to pay the price of a barrier when a) the bus architecture guarantees non re-ordering and posting and that statement is true on all the SoCs where these peripherals are used, and b) you have worked on fine tuning your drivers to get the most performance out of them. > >> We need the swapping for ARM because when running in ARM BE32, the data >> is going to be in the host CPU endian, but the register bus is hard >> wired to little endian. > > Yeah I see you need to do some byteswapping. But I'm pretty sure not > all MIPS BE boxes do the magic swapping, right? And drivers/leds is > not a place where you encode knowledge about SoC byte swapping. The Broadcom MIPS CPUs (we have/had an architectural license) can be strapped for BE or LE, and when that happens the bridge that connects to the registers follows the CPU's endian, which is why __raw_{read,write}l is appropriate for these specific peripherals. Given these peripherals can only be used on CPUs/SoCs made by Broadcom, any argument about portability to other SoCs is moot. -- Florian