Re: [PATCH v1] bnx2x: use generic power management
On Sat, 27 Jun 2020 at 00:44, David Miller wrote: > > From: Vaibhav Gupta > Date: Wed, 24 Jun 2020 23:21:17 +0530 > > > With legacy PM, drivers themselves were responsible for managing the > > device's power states and takes care of register states. > > > > After upgrading to the generic structure, PCI core will take care of > > required tasks and drivers should do only device-specific operations. > > > > The driver was also calling bnx2x_set_power_state() to set the power state > > of the device by changing the device's registers' value. It is no more > > needed. > > > > Compile-tested only. > > > > Signed-off-by: Vaibhav Gupta > > Applied, thanks. Thanks everyone :) -- Vaibhav Gupta
Re: [PATCH 5/5] dt-bindings: timer: Add CLINT bindings
On Fri, May 29, 2020 at 4:48 AM Rob Herring wrote: > > On Tue, May 26, 2020 at 05:32:30PM -0700, Palmer Dabbelt wrote: > > On Thu, 21 May 2020 23:29:36 PDT (-0700), sean...@gmail.com wrote: > > > On 5/22/20 1:54 AM, Anup Patel wrote: > > > > On Fri, May 22, 2020 at 1:35 AM Sean Anderson wrote: > > > > > > > > > > On 5/21/20 9:45 AM, Anup Patel wrote: > > > > > > +Required properties: > > > > > > +- compatible : "sifive,clint-1.0.0" and a string identifying the > > > > > > actual > > > > > > + detailed implementation in case that specific bugs need to be > > > > > > worked around. > > > > > > > > > > Should the "riscv,clint0" compatible string be documented here? This > > > > > > > > Yes, I forgot to add this compatible string. I will add in v2. > > > > > > > > > peripheral is not really specific to sifive, as it is present in most > > > > > rocket-chip cores. > > > > > > > > I agree that CLINT is present in a lot of non-SiFive RISC-V SOCs and > > > > FPGAs but this IP is only documented as part of SiFive FU540 SOC. > > > > (Refer, https://static.dev.sifive.com/FU540-C000-v1.0.pdf) > > > > > > > > The RISC-V foundation should host the CLINT spec independently > > > > under https://github.com/riscv and make CLINT spec totally open. > > > > > > > > For now, I have documented it just like PLIC DT bindings found at: > > > > Documentation/devicetree/bindings/interrupt-controller/sifive,plic-1.0.0.txt > > > > > > The PLIC seems to have its own RISC-V-sponsored documentation [1] which > > > was split off from the older privileged specs. By your logic above, > > > should it be renamed to riscv,plic0.txt (with a corresponding change in > > > the documented compatible strings)? > > > > > > [1] https://github.com/riscv/riscv-plic-spec > > > > Let's propose tagging that PLIC spec as v1.0.0 in the platform spec group, > > but > > I don't see a reason why that wouldn't be viable. Assuming that's all OK, > > we > > can start calling this a RISC-V PLIC (in addition to a SiFive PLIC, as > > they'll > > be compatible). > > > > > > > > > > If RISC-V maintainers agree then I will document it as "RISC-V CLINT". > > > > > > > > @Palmer ?? @Paul ?? > > > > The CLINT is a SiFive spec. It has open source RTL so it's been > > implemented in > > other designs, but it's not a RISC-V spec. The CLIC, which is a superset of > > the CLINT, is a RISC-V spec. IIRC it's not finished yet (it's the fast > > interrupts task group), but presumably we should have a "riscv,clic-2.0.0" > > (or > > whatever it ends up being called) compat string to go along with the > > specification. > > Whatever you all decide on, note that "sifive," is a SiFive > thing (as it is documented) and corresponds to tag of the IP > implmentation (at least it is supposed to). So you can't just copy that > with 'riscv,' unless you have the same IP versioning > and update the documentation. I agree that "sifive," is a SiFive thingy. Unfortunately, lot of RISC-V implementations (SiFive and non-SiFive) have DTS generated from RTL (not part of Linux sources) where most of them use "riscv,clint0" as compatible string for CLINT. > > Using a spec version is fine, but not standalone. You need > implementation specific compatible too because no one perfectly > implements any spec and/or there details a spec may not cover. Sure, a generic compatible string "riscv,clint0" OR "sifive,clint-1.0.0" along with an implementation specific compatible string sounds good to me. Regards, Anup
Re: KASAN: use-after-free Read in tipc_nl_node_dump_monitor_peer (2)
Hello, syzbot has tested the proposed patch and the reproducer did not trigger crash: Reported-and-tested-by: syzbot+c96e4dfb32f8987fd...@syzkaller.appspotmail.com Tested on: commit: 152c6a4d genetlink: get rid of family->attrbuf git tree: https://github.com/congwang/linux.git net kernel config: https://syzkaller.appspot.com/x/.config?x=20c907630cbdbe5 dashboard link: https://syzkaller.appspot.com/bug?extid=c96e4dfb32f8987fdeed compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) Note: testing is done by a robot and is best-effort only.
Re: [PATCH 4/4] staging: rtl8188eu: Replace function name with __func__
On Fri, Jun 26, 2020 at 11:36:42AM -0400, Brooke Basile wrote: > Fix the following checkpatch warning: > WARNING: Prefer using '"%s...", __func__' to using 'rtw_get_bcn_info', > this function's name, in a string > > Signed-off-by: Brooke Basile > --- > drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c > b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c > index bf6b2fe9735f..0c43c0dcf95c 100644 > --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c > +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c > @@ -986,10 +986,10 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) > if (bencrypt) > pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WEP; > } > - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: > pnetwork->encryp_protocol is %x\n", > - pnetwork->BcnInfo.encryp_protocol)); > - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: > pnetwork->encryp_protocol is %x\n", > - pnetwork->BcnInfo.encryp_protocol)); > + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s: > pnetwork->encryp_protocol is %x\n", > + __func__, pnetwork->BcnInfo.encryp_protocol)); > + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s: > pnetwork->encryp_protocol is %x\n", > + __func__, pnetwork->BcnInfo.encryp_protocol)); > rtw_get_cipher_info(pnetwork); > > /* get bwmode and ch_offset */ This patch fails to apply to my latest branch, can you rebase it and resend if it is still needed? thanks, greg k-h
Re: [PATCH V3] firmware: stratix10-svc: Fix some error handling code
On Fri, Jun 26, 2020 at 09:37:20PM +0200, Christophe JAILLET wrote: > --- > v2: takes Dan's comment into account and fix another resource leak. > v3: merge the previous 4 patches in a single one to ease review No, 4 small patches are _MUCH_ easier to review than one larger one that mixes everything together. Who told you to put them together?
Re: [PATCH V3] firmware: stratix10-svc: Fix some error handling code
On Fri, Jun 26, 2020 at 09:37:20PM +0200, Christophe JAILLET wrote: > Fix several error handling issues: When you have to list a bunch of different things you do in a driver, that's a huge hint this needs to be broken up into multiple patches. Please do that here. thanks, greg k-h
Re: [PATCH] fbtft-bus.c: Removing that prohibited space before ')'
On Sat, Jun 27, 2020 at 12:51:50AM -0400, B K Karthik wrote: > fbtft-bus.c: > > fixing ERROR: space prohibited before that close parenthesis ')' by removing > that space and ',' in line 65 and 67. > > Signed-off-by: B K Karthik > --- > drivers/staging/fbtft/fbtft-bus.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/fbtft/fbtft-bus.c > b/drivers/staging/fbtft/fbtft-bus.c > index 63c65dd67b17..847cbfbbd766 100644 > --- a/drivers/staging/fbtft/fbtft-bus.c > +++ b/drivers/staging/fbtft/fbtft-bus.c > @@ -62,9 +62,9 @@ out: > \ > } > \ > EXPORT_SYMBOL(func); > > -define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8, ) > +define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8) > define_fbtft_write_reg(fbtft_write_reg16_bus8, __be16, u16, cpu_to_be16) > -define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16, ) > +define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16) Also, did you test-build this patch? I think this just broke the build...
Re: [PATCH] fbtft-bus.c: Removing that prohibited space before ')'
On Sat, 2020-06-27 at 00:51 -0400, B K Karthik wrote: > fbtft-bus.c: > > fixing ERROR: space prohibited before that close parenthesis ')' by removing > that space and ',' in line 65 and 67. [] > diff --git a/drivers/staging/fbtft/fbtft-bus.c > b/drivers/staging/fbtft/fbtft-bus.c > index 63c65dd67b17..847cbfbbd766 100644 > --- a/drivers/staging/fbtft/fbtft-bus.c > +++ b/drivers/staging/fbtft/fbtft-bus.c > @@ -62,9 +62,9 @@ out: > \ > } > \ > EXPORT_SYMBOL(func); > > -define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8, ) > +define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8) > define_fbtft_write_reg(fbtft_write_reg16_bus8, __be16, u16, cpu_to_be16) > -define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16, ) > +define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16) Q: Did you compile the files modified by this patch before you submitted it? A: No
Re: linux-next: Fixes tag needs some work in the block tree
Hi Jens, On Fri, 26 Jun 2020 20:25:31 -0600 Jens Axboe wrote: > > Right, but that's what git format-patch does when the line is long. I just tested, and "git format-patch" (for me) does *not* split those lines. -- Cheers, Stephen Rothwell pgpMPaX2H1NdF.pgp Description: OpenPGP digital signature
Re: [PATCH] fbtft-bus.c:
On Sat, Jun 27, 2020 at 12:50:04AM -0400, B K Karthik wrote: > fbtft-bus.c: > > fixing ERROR: space prohibited before that close parenthesis ')' by removing > that space and ',' in line 65 and 67. > > Signed-off-by: B K Karthik > --- > drivers/staging/fbtft/fbtft-bus.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Your subject line is really odd :( Please read the following text from my patch-bot: - You did not specify a description of why the patch is needed, or possibly, any description at all, in the email body. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/SubmittingPatches for what is needed in order to properly describe the change. - You did not write a descriptive Subject: for the patch, allowing Greg, and everyone else, to know what this patch is all about. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/SubmittingPatches for what a proper Subject: line should look like. And fix up both the subject lines, and the changelog body text so that it looks correct. Look at the other patches for this code that have been accepted as examples of what to do. thanks, greg k-h
Re: [PATCH] staging: media: usbvision: removing prohibited space before ',' (ctx:WxW)
A: http://en.wikipedia.org/wiki/Top_post Q: Were do I find info about this thing called top-posting? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail? A: No. Q: Should I include quotations after my reply? http://daringfireball.net/2007/07/on_top On Fri, Jun 26, 2020 at 11:42:49AM -0400, B K KARTHIK PES2201800185STUDENT ECE DeptPESU EC Campus wrote: > Oh, I'm sorry but wouldn't it be helpful if we had a file that lists > all drivers that are scheduled for removal? The TODO file in the directory for the driver should have this information in it. I don't know if all of the media drivers have this, if not, then there is no way you could have known this. thanks, greg k-h
Re: linux-next: Fixes tag needs some work in the block tree
Hi Konstantin, On Fri, 26 Jun 2020 21:56:05 -0400 Konstantin Ryabitsev wrote: > > On Fri, Jun 26, 2020 at 07:32:15PM -0600, Jens Axboe wrote: > > On 6/26/20 5:07 PM, Stephen Rothwell wrote: > > > Hi all, > > > > > > In commit > > > > > > cd664b0e35cb ("io_uring: fix hanging iopoll in case of -EAGAIN") > > > > > > Fixes tag > > > > > > Fixes: bbde017a32b3 ("io_uring: add memory barrier to synchronize > > > > > > has these problem(s): > > > > > > - Subject has leading but no trailing parentheses > > > - Subject has leading but no trailing quotes > > > > > > Please do not split Fixes tags over more than one line. > > > > Gah, that's b4 messing it up. I've actually seen this before, but > > I caught it. If you look at the actual commit, this is what the b4 > > output ends up being for the fixes line: > > > > [snip] > > io_kiocb's result and iopoll_completed") > > > > Fixes: bbde017a32b3 ("io_uring: add memory barrier to synchronize > > > > even though it's correct in the email. I'm guessing some issue having to > > do with the longer line? > > Yeah, I'll try to see if there's something I can do here, but it's going > to be largely guesswork. Here's the original email: > > https://lore.kernel.org/lkml/22111b29e298f5f606130fcf4307bda99dbec089.1593077359.git.asml.sile...@gmail.com/raw > > The Fixes: footer really does get split into two. It's not that hard to > add logic just for the Fixes tag (since it conveniently follows a set > pattern), but finding a universal fix for split footers will be more > difficult. > > I'll see what I can do. But (what am I missing?) the Fixes: tag has been split over 2 lines in the original message ... on lore and my copy. There is nothing for b4 to do here, the author needs to do this right. -- Cheers, Stephen Rothwell pgptkJwEvBQnn.pgp Description: OpenPGP digital signature
Re: [PATCH 2/2] pci: Add parameter to disable attaching untrusted devices
On Fri, Jun 26, 2020 at 11:53:34AM -0700, Rajat Jain wrote: > a) I think what was decided was introducing a device core "location" > property that can be exposed to userspace to help it to decide whether > or not to attach a driver to a device. Yes, that is still the plan. Great, but this patch ignores that and starts to add policy :( > (Mild sidenote: userspace may not need to distinguish between internal > and external devices if it can assume that no internal PCI devices > will show up after "echo 0 > /sys/bus/pci/drivers_autoprobe". But > nevertheless...) It can not assume that. > b) Note that even with (a) in place, we still need a parameter that > can ensure that drivers are not bound to external devices at boot, > *before* userspace gets a chance to disable "drivers_autoprobe". Why do you think you need that? I kind of doubt you really want this, but ick, if you really do, make it a policy decision that you bake into the kernel as a build option, so that no one else has to use it :) > https://lkml.org/lkml/2020/6/15/1453 Ick, please use lore.kernel.org, we don't control lkml.org and it's not all that reliable. > Is it OK to add such a parameter in device core? You don't have internal/external/wherever in the driver core yet, so don't start adding policy before you get that... thanks, greg k-h
[PATCH 1/2] platform/chrome: cros_ec_typec: Use workqueue for port update
Use a work queue to call the port update routines, instead of doing it directly in the PD notifier callback. This will prevent other drivers with PD notifier callbacks from being blocked on the port update routine completing. Signed-off-by: Prashant Malani --- drivers/platform/chrome/cros_ec_typec.c | 28 - 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 0c041b79cbba..630170fb2cbe 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -58,6 +58,7 @@ struct cros_typec_data { /* Array of ports, indexed by port number. */ struct cros_typec_port *ports[EC_USB_PD_MAX_PORTS]; struct notifier_block nb; + struct work_struct port_work; }; static int cros_typec_parse_port_props(struct typec_capability *cap, @@ -619,18 +620,29 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec) return 0; } -static int cros_ec_typec_event(struct notifier_block *nb, - unsigned long host_event, void *_notify) +static void cros_typec_port_work(struct work_struct *work) { - struct cros_typec_data *typec = container_of(nb, struct cros_typec_data, -nb); - int ret, i; + struct cros_typec_data *typec = container_of(work, +struct cros_typec_data, +port_work); + int ret; + int i; for (i = 0; i < typec->num_ports; i++) { ret = cros_typec_port_update(typec, i); if (ret < 0) dev_warn(typec->dev, "Update failed for port: %d\n", i); } +} + + +static int cros_ec_typec_event(struct notifier_block *nb, + unsigned long host_event, void *_notify) +{ + struct cros_typec_data *typec = container_of(nb, struct cros_typec_data, +nb); + + schedule_work(>port_work); return NOTIFY_OK; } @@ -689,6 +701,12 @@ static int cros_typec_probe(struct platform_device *pdev) if (ret < 0) return ret; + INIT_WORK(>port_work, cros_typec_port_work); + + /* +* Safe to call port update here, since we haven't registered the +* PD notifier yet. +*/ for (i = 0; i < typec->num_ports; i++) { ret = cros_typec_port_update(typec, i); if (ret < 0) -- 2.27.0.212.ge8ba1cc988-goog
[PATCH 2/2] platform/chrome: cros_ec_typec: Add PM support
Define basic suspend resume functions for cros-ec-typec. On suspend, we simply ensure that any pending port update work is completed, and on resume, we re-poll the port state to account for any changes/disconnections that might have occurred during suspend. Signed-off-by: Prashant Malani --- drivers/platform/chrome/cros_ec_typec.c | 34 + 1 file changed, 34 insertions(+) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 630170fb2cbe..68f15a47450c 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -725,11 +725,45 @@ static int cros_typec_probe(struct platform_device *pdev) return ret; } +#ifdef CONFIG_PM_SLEEP + +static int cros_typec_suspend(struct device *dev) +{ + struct cros_typec_data *typec = dev_get_drvdata(dev); + + cancel_work_sync(>port_work); + + return 0; +} + +static int cros_typec_resume(struct device *dev) +{ + struct cros_typec_data *typec = dev_get_drvdata(dev); + + /* Refresh port state. */ + schedule_work(>port_work); + + return 0; +} + +static const struct dev_pm_ops cros_typec_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(cros_typec_suspend, cros_typec_resume) +}; + +#define DEV_PM_OPS (_typec_pm_ops) + +#else + +#define DEV_PM_OPS NULL + +#endif /* CONFIG_PM_SLEEP */ + static struct platform_driver cros_typec_driver = { .driver = { .name = DRV_NAME, .acpi_match_table = ACPI_PTR(cros_typec_acpi_id), .of_match_table = of_match_ptr(cros_typec_of_match), + .pm = DEV_PM_OPS, }, .probe = cros_typec_probe, }; -- 2.27.0.212.ge8ba1cc988-goog
[PATCH v4 23/23] arm64: tegra: Add support for APE sound card on Jetson Nano and TX1
This adds APE sound card support on Jetson Nano and TX1 which is based on simple-card driver. Earlier in the series simple-card driver is enhanced to work with multiple ASoC components. Based on board design required I/O interfaces are exposed for I2S and DMIC. More complicated audio paths will be added going forward. Signed-off-by: Sameer Pujar --- arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts | 94 ++ arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts | 49 +++ arch/arm64/boot/dts/nvidia/tegra210.dtsi | 67 +++ 3 files changed, 210 insertions(+) diff --git a/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts b/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts index 3c21137..7c4b521 100644 --- a/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts +++ b/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts @@ -166,4 +166,98 @@ }; }; }; + + tegra_sound { + status = "okay"; + + simple-audio-card,name = "jetson-tx1-ape"; + + simple-audio-card,widgets = + "Microphone", "MIC", + "Speaker", "SPK"; + + simple-audio-card,routing = + "SPK","I2S1 Playback", + "SPK","I2S2 Playback", + "SPK","I2S3 Playback", + "SPK","I2S4 Playback", + "SPK","I2S5 Playback", + "I2S1 Capture", "MIC", + "I2S2 Capture", "MIC", + "I2S3 Capture", "MIC", + "I2S4 Capture", "MIC", + "I2S5 Capture", "MIC", + "DMIC1 Capture", "MIC", + "DMIC2 Capture", "MIC", + "DMIC3 Capture", "MIC"; + + /* BE links */ + simple-audio-card,dai-link@1 { + format = "i2s"; + bitclock-master = <_i2s1>; + frame-master = <_i2s1>; + + cpu_i2s1: cpu@0 { + sound-dai = <_i2s1 0>; + }; + }; + + simple-audio-card,dai-link@2 { + format = "i2s"; + bitclock-master = <_i2s2>; + frame-master = <_i2s2>; + + cpu_i2s2: cpu@0 { + sound-dai = <_i2s2 0>; + }; + }; + + simple-audio-card,dai-link@3 { + format = "i2s"; + bitclock-master = <_i2s3>; + frame-master = <_i2s3>; + + cpu_i2s3: cpu@0 { + sound-dai = <_i2s3 0>; + }; + }; + + simple-audio-card,dai-link@4 { + format = "i2s"; + bitclock-master = <_i2s4>; + frame-master = <_i2s4>; + + cpu_i2s4: cpu@0 { + sound-dai = <_i2s4 0>; + }; + }; + + simple-audio-card,dai-link@5 { + format = "i2s"; + bitclock-master = <_i2s5>; + frame-master = <_i2s5>; + + cpu_i2s5: cpu@0 { + sound-dai = <_i2s5 0>; + }; + }; + + simple-audio-card,dai-link@6 { + cpu@0 { + sound-dai = <_dmic1 0>; + }; + }; + + simple-audio-card,dai-link@7 { + cpu@0 { + sound-dai = <_dmic2 0>; + }; + }; + + simple-audio-card,dai-link@8 { + cpu@0 { + sound-dai = <_dmic3 0>; + }; + }; + }; }; diff --git a/arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts b/arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts index 721f66c..31994f6 100644 --- a/arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts +++ b/arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts @@ -842,4 +842,53 @@ }; }; }; + + tegra_sound { + status = "okay"; + + simple-audio-card,name = "jetson-nano-ape"; + simple-audio-card,widgets = + "Microphone", "MIC", + "Speaker", "SPK"; + simple-audio-card,routing = + "SPK","I2S3 Playback", + "SPK","I2S4 Playback", + "I2S3
[PATCH v4 21/23] arm64: tegra: Add DT binding for AHUB components
This patch adds few AHUB modules for Tegra210, Tegra186 and Tegra194. Bindings for following modules are added. * AHUB added as a child node under ACONNECT * AHUB includes many HW accelerators and below components are added as its children. * ADMAIF * I2S * DMIC * DSPK (added for Tegra186 and Tegra194 only, since Tegra210 does not have this module) Signed-off-by: Sameer Pujar --- arch/arm64/boot/dts/nvidia/tegra186.dtsi | 231 - arch/arm64/boot/dts/nvidia/tegra194.dtsi | 239 ++- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 152 +++- 3 files changed, 619 insertions(+), 3 deletions(-) diff --git a/arch/arm64/boot/dts/nvidia/tegra186.dtsi b/arch/arm64/boot/dts/nvidia/tegra186.dtsi index 34d249d..01bae88 100644 --- a/arch/arm64/boot/dts/nvidia/tegra186.dtsi +++ b/arch/arm64/boot/dts/nvidia/tegra186.dtsi @@ -85,7 +85,7 @@ ranges = <0x0290 0x0 0x0290 0x20>; status = "disabled"; - dma-controller@293 { + adma: dma-controller@293 { compatible = "nvidia,tegra186-adma"; reg = <0x0293 0x2>; interrupt-parent = <>; @@ -140,6 +140,235 @@ clock-names = "clk"; status = "disabled"; }; + + tegra_ahub: ahub@2900800 { + compatible = "nvidia,tegra186-ahub"; + reg = <0x02900800 0x800>; + clocks = < TEGRA186_CLK_AHUB>; + clock-names = "ahub"; + assigned-clocks = < TEGRA186_CLK_AHUB>; + assigned-clock-parents = < TEGRA186_CLK_PLL_A_OUT0>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x02900800 0x02900800 0x11800>; + #sound-dai-cells = <1>; + status = "disabled"; + + tegra_admaif: admaif@290f000 { + compatible = "nvidia,tegra186-admaif"; + reg = <0x0290f000 0x1000>; + dmas = < 1>, < 1>, + < 2>, < 2>, + < 3>, < 3>, + < 4>, < 4>, + < 5>, < 5>, + < 6>, < 6>, + < 7>, < 7>, + < 8>, < 8>, + < 9>, < 9>, + < 10>, < 10>, + < 11>, < 11>, + < 12>, < 12>, + < 13>, < 13>, + < 14>, < 14>, + < 15>, < 15>, + < 16>, < 16>, + < 17>, < 17>, + < 18>, < 18>, + < 19>, < 19>, + < 20>, < 20>; + dma-names = "rx1", "tx1", + "rx2", "tx2", + "rx3", "tx3", + "rx4", "tx4", + "rx5", "tx5", + "rx6", "tx6", + "rx7", "tx7", + "rx8", "tx8", + "rx9", "tx9", + "rx10", "tx10", + "rx11", "tx11", + "rx12", "tx12", + "rx13", "tx13", + "rx14", "tx14", + "rx15", "tx15", + "rx16", "tx16", + "rx17", "tx17", + "rx18", "tx18", + "rx19", "tx19", + "rx20", "tx20"; + #sound-dai-cells = <1>; + status = "disabled"; + }; + + tegra_i2s1: i2s@2901000 { + compatible = "nvidia,tegra186-i2s", +"nvidia,tegra210-i2s"; + reg = <0x2901000 0x100>; + clocks = < TEGRA186_CLK_I2S1>, +< TEGRA186_CLK_I2S1_SYNC_INPUT>; +
[PATCH v4 16/23] ASoC: soc-pcm: Get all BEs along DAPM path
dpcm_end_walk_at_be() stops the graph walk when first BE is found for the given FE component. In a component model we may want to connect multiple DAIs from different components. A new flag is introduced in 'snd_soc_card', which when set allows DAI/component chaining. Later PCM operations can be called for all these listed components for a valid DAPM path. Signed-off-by: Sameer Pujar --- include/sound/soc.h | 1 + sound/soc/soc-pcm.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 1e0376f..95e02a7 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1069,6 +1069,7 @@ struct snd_soc_card { int num_of_dapm_widgets; const struct snd_soc_dapm_route *of_dapm_routes; int num_of_dapm_routes; + bool component_chaining; /* lists of probed devices belonging to this card */ struct list_head component_dev_list; diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 6dc21b6..7f612e3 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -1322,7 +1322,8 @@ int dpcm_path_get(struct snd_soc_pcm_runtime *fe, /* get number of valid DAI paths and their widgets */ paths = snd_soc_dapm_dai_get_connected_widgets(cpu_dai, stream, list, - dpcm_end_walk_at_be); + fe->card->component_chaining ? + NULL : dpcm_end_walk_at_be); dev_dbg(fe->dev, "ASoC: found %d audio %s paths\n", paths, stream ? "capture" : "playback"); -- 2.7.4
[PATCH v4 17/23] ASoC: dt-bindings: simple-card: Add compatible for component chaining
New compatible "simple-cc-audio-card" is exposed for simple-card driver which allows usage of DAI link chaining and thus connects multiple components together in a system. Signed-off-by: Sameer Pujar --- Documentation/devicetree/bindings/sound/simple-card.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/sound/simple-card.yaml b/Documentation/devicetree/bindings/sound/simple-card.yaml index 8132d0c..fcd0fd3 100644 --- a/Documentation/devicetree/bindings/sound/simple-card.yaml +++ b/Documentation/devicetree/bindings/sound/simple-card.yaml @@ -145,6 +145,7 @@ properties: enum: - simple-audio-card - simple-scu-audio-card +- simple-cc-audio-card "#address-cells": const: 1 -- 2.7.4
[PATCH v4 22/23] arm64: tegra: Enable AHUB components on few Tegra platforms
This patch enables AHUB, ADMAIF modules for following Tegra platforms. Along with this specific instances of I/O modules are enabled as per the board design. * Jetson TX1 - I2S1, I2S2, I2S3, I2S4 and I2S5 - DMIC1, DMIC2 and DMIC3 * Jetson Nano - I2S3 and I2S4 - DMIC1 and DMIC2 * Jetson TX2 - I2S1, I2S2, I2S3, I2S4, I2S5 and I2S6 - DMIC1, DMIC2 and DMIC3 - DSPK2 * Jetson AGX Xavier - I2S1, I2S2, I2S4 and I2S6 - DMIC2 and DMIC3 - DSPK1 This helps to register above components with ASoC core. Signed-off-by: Sameer Pujar --- arch/arm64/boot/dts/nvidia/tegra186-p2771-.dts | 48 ++ arch/arm64/boot/dts/nvidia/tegra194-p2972-.dts | 36 arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts | 42 ++- arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts | 36 4 files changed, 161 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/nvidia/tegra186-p2771-.dts b/arch/arm64/boot/dts/nvidia/tegra186-p2771-.dts index a70fd4e..cb24b81 100644 --- a/arch/arm64/boot/dts/nvidia/tegra186-p2771-.dts +++ b/arch/arm64/boot/dts/nvidia/tegra186-p2771-.dts @@ -20,6 +20,54 @@ interrupt-controller@2a4 { status = "okay"; }; + + ahub@2900800 { + status = "okay"; + + admaif@290f000 { + status = "okay"; + }; + + i2s@2901000 { + status = "okay"; + }; + + i2s@2901100 { + status = "okay"; + }; + + i2s@2901200 { + status = "okay"; + }; + + i2s@2901300 { + status = "okay"; + }; + + i2s@2901400 { + status = "okay"; + }; + + i2s@2901500 { + status = "okay"; + }; + + dmic@2904000 { + status = "okay"; + }; + + dmic@2904100 { + status = "okay"; + }; + + dmic@2904200 { + status = "okay"; + }; + + dspk@2905100 { + status = "okay"; + }; + }; }; i2c@316 { diff --git a/arch/arm64/boot/dts/nvidia/tegra194-p2972-.dts b/arch/arm64/boot/dts/nvidia/tegra194-p2972-.dts index 90b6ea5..f71c3bd 100644 --- a/arch/arm64/boot/dts/nvidia/tegra194-p2972-.dts +++ b/arch/arm64/boot/dts/nvidia/tegra194-p2972-.dts @@ -21,6 +21,42 @@ interrupt-controller@2a4 { status = "okay"; }; + + ahub@2900800 { + status = "okay"; + + admaif@290f000 { + status = "okay"; + }; + + i2s@2901000 { + status = "okay"; + }; + + i2s@2901100 { + status = "okay"; + }; + + i2s@2901300 { + status = "okay"; + }; + + i2s@2901500 { + status = "okay"; + }; + + dmic@2904100 { + status = "okay"; + }; + + dmic@2904200 { + status = "okay"; + }; + + dspk@2905000 { + status = "okay"; + }; + }; }; ddc: i2c@31c { diff --git a/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts b/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts index 56adf28..3c21137 100644 --- a/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts +++ b/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts @@ -118,12 +118,52 @@ aconnect@702c { status = "okay"; - dma@702e2000 { + dma-controller@702e2000 { status = "okay"; }; interrupt-controller@702f9000 { status =
[PATCH v4 15/23] ASoC: soc-core: Identify 'no_pcm' DAI links for DPCM
PCM devices are created for dai links with 'no-pcm' flag as '0'. Such DAI links have CPU component which implement pcm_construct() and pcm_destruct() callbacks. Based on this, current patch exposes a helper function to identify such components and populate 'no_pcm' flag for DPCM DAI link. This helps to have BE<->BE component links where PCM devices need not be created for CPU components involved in the links. Signed-off-by: Sameer Pujar --- include/sound/soc.h | 2 ++ sound/soc/generic/simple-card.c | 3 +++ sound/soc/soc-core.c| 25 + 3 files changed, 30 insertions(+) diff --git a/include/sound/soc.h b/include/sound/soc.h index 33acead..1e0376f 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -397,6 +397,7 @@ struct snd_soc_dai_driver; struct snd_soc_dai_link; struct snd_soc_component; struct snd_soc_component_driver; +struct snd_soc_dai_link_component; struct soc_enum; struct snd_soc_jack; struct snd_soc_jack_zone; @@ -437,6 +438,7 @@ int snd_soc_add_component(struct device *dev, const struct snd_soc_component_driver *component_driver, struct snd_soc_dai_driver *dai_drv, int num_dai); +bool soc_component_is_pcm(struct snd_soc_dai_link_component *dlc); int snd_soc_register_component(struct device *dev, const struct snd_soc_component_driver *component_driver, struct snd_soc_dai_driver *dai_drv, int num_dai); diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 62f2978..f19030b 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -188,6 +188,9 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, if (ret) goto out_put_node; + if (!soc_component_is_pcm(cpus)) + dai_link->no_pcm = 1; + ret = asoc_simple_parse_clk_cpu(dev, np, dai_link, dai); if (ret < 0) goto out_put_node; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 9041a03..d2a47c3 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -259,6 +259,31 @@ static inline void snd_soc_debugfs_exit(void) #endif +bool soc_component_is_pcm(struct snd_soc_dai_link_component *dlc) +{ + struct snd_soc_component *component; + struct snd_soc_dai *dai; + + for_each_component(component) { + if (!component->driver) + continue; + + for_each_component_dais(component, dai) { + if (!dai->name || !dlc->dai_name) + continue; + + if (strcmp(dai->name, dlc->dai_name)) + continue; + + if (component->driver->pcm_construct) + return true; + } + } + + return false; +} +EXPORT_SYMBOL_GPL(soc_component_is_pcm); + static int snd_soc_rtd_add_component(struct snd_soc_pcm_runtime *rtd, struct snd_soc_component *component) { -- 2.7.4
[PATCH v4 14/23] ASoC: soc-core: Probe auxiliary component before others
A router component can be added as an auxiliary device to the sound card to help with audio routing across multiple components. DPCM dai links use CPU<->Dummy or Dummy<->Codec style of links in simple-card driver and hence do not have required DAI connections by default. Usually machine driver can do the necessary mapping. But if there is a crossbar switch HW which can connect multiple components, it is expected to provide required user space configurability via MUX controls. In such a case the crossbar can be represented as an independent component and can be added as an auxiliary device. The exposed routing interfaces can be used by other components in the system, thus probing it first can avoid probe failures. Signed-off-by: Sameer Pujar --- sound/soc/soc-core.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 8faca60..9041a03 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1850,19 +1850,19 @@ static int snd_soc_bind_card(struct snd_soc_card *card) if (ret < 0) goto probe_end; - /* probe all components used by DAI links on this card */ - ret = soc_probe_link_components(card); + /* probe auxiliary components */ + ret = soc_probe_aux_devices(card); if (ret < 0) { dev_err(card->dev, - "ASoC: failed to instantiate card %d\n", ret); + "ASoC: failed to probe aux component %d\n", ret); goto probe_end; } - /* probe auxiliary components */ - ret = soc_probe_aux_devices(card); + /* probe all components used by DAI links on this card */ + ret = soc_probe_link_components(card); if (ret < 0) { dev_err(card->dev, - "ASoC: failed to probe aux component %d\n", ret); + "ASoC: failed to instantiate card %d\n", ret); goto probe_end; } -- 2.7.4
[PATCH v4 19/23] arm64: defconfig: Build AHUB component drivers
This patch enables following configs: +CONFIG_TEGRA_ACONNECT=m +CONFIG_SND_SOC_TEGRA=m +CONFIG_SND_SOC_TEGRA210_AHUB=m +CONFIG_SND_SOC_TEGRA210_DMIC=m +CONFIG_SND_SOC_TEGRA210_I2S=m +CONFIG_SND_SOC_TEGRA186_DSPK=m +CONFIG_SND_SOC_TEGRA210_ADMAIF=m This patch helps to register AHUB and its clients (I2S, DMIC, DSPK, ADMAIF) with ASoC core. Since AHUB is child of ACONNECT, config TEGRA_ACONNECT is enabled as well. Signed-off-by: Sameer Pujar --- arch/arm64/configs/defconfig | 7 +++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index ae76fae..a8c0f77 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -218,6 +218,7 @@ CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y CONFIG_HISILICON_LPC=y CONFIG_SIMPLE_PM_BUS=y CONFIG_FSL_MC_BUS=y +CONFIG_TEGRA_ACONNECT=m CONFIG_MTD=y CONFIG_MTD_BLOCK=y CONFIG_MTD_CFI=y @@ -664,6 +665,12 @@ CONFIG_SND_SOC_RK3399_GRU_SOUND=m CONFIG_SND_SOC_SAMSUNG=y CONFIG_SND_SOC_RCAR=m CONFIG_SND_SUN4I_SPDIF=m +CONFIG_SND_SOC_TEGRA=m +CONFIG_SND_SOC_TEGRA210_AHUB=m +CONFIG_SND_SOC_TEGRA210_DMIC=m +CONFIG_SND_SOC_TEGRA210_I2S=m +CONFIG_SND_SOC_TEGRA186_DSPK=m +CONFIG_SND_SOC_TEGRA210_ADMAIF=m CONFIG_SND_SOC_AK4613=m CONFIG_SND_SOC_ES7134=m CONFIG_SND_SOC_ES7241=m -- 2.7.4
[PATCH v4 20/23] arm64: defconfig: Enable CONFIG_TEGRA210_ADMA
This commit builds ADMA driver which can be used on Tegra210 and later platforms to transfer audio data to/from AHUB (Audio Hub). Signed-off-by: Sameer Pujar --- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index a8c0f77..599ed07 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -784,6 +784,7 @@ CONFIG_MV_XOR_V2=y CONFIG_OWL_DMA=y CONFIG_PL330_DMA=y CONFIG_TEGRA20_APB_DMA=y +CONFIG_TEGRA210_ADMA=m CONFIG_QCOM_BAM_DMA=y CONFIG_QCOM_HIDMA_MGMT=y CONFIG_QCOM_HIDMA=y -- 2.7.4
[PATCH v4 18/23] ASoC: simple-card: Add support for component chaining
The simple-card driver supports both normal and DPCM DAI links. The sound cards requiring DPCM DAI link support use DPCM_SELECTABLE flag and DAI links are treated as DPCM links depending on the number of child nodes in a given DAI link. There is another requirement where multiple ASoC components need to be connected together in a chained fashion in a component model. This patch sets 'component_chaining' flag for such sound cards where FE<->BE and multiple BE<->BE component connections is required. Hence support for such sound cards is added under 'simple-cc-audio-card' compatible. All DAI links under this are treated as DPCM links and links can have empty Codec list since components are chainied via router controls. Signed-off-by: Sameer Pujar --- include/sound/simple_card.h | 5 + sound/soc/generic/simple-card.c | 35 --- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/include/sound/simple_card.h b/include/sound/simple_card.h index d264e54..79019d0 100644 --- a/include/sound/simple_card.h +++ b/include/sound/simple_card.h @@ -23,4 +23,9 @@ struct asoc_simple_card_info { struct asoc_simple_dai codec_dai; }; +struct asoc_simple_soc_data { + bool dpcm_selectable; + bool component_chaining; +}; + #endif /* __SIMPLE_CARD_H */ diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index f19030b..758c612 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -16,8 +16,6 @@ #include #include -#define DPCM_SELECTABLE 1 - #define DAI"sound-dai" #define CELL "#sound-dai-cells" #define PREFIX "simple-audio-card," @@ -386,10 +384,11 @@ static int simple_for_each_link(struct asoc_simple_priv *priv, struct device_node *np, struct link_info *li, bool is_top)) { + struct snd_soc_card *card = simple_priv_to_card(priv); struct device *dev = simple_priv_to_dev(priv); struct device_node *top = dev->of_node; struct device_node *node; - uintptr_t dpcm_selectable = (uintptr_t)of_device_get_match_data(dev); + const struct asoc_simple_soc_data *data = of_device_get_match_data(dev); bool is_top = 0; int ret = 0; @@ -411,10 +410,13 @@ static int simple_for_each_link(struct asoc_simple_priv *priv, /* get codec */ codec = of_get_child_by_name(node, is_top ? PREFIX "codec" : "codec"); - if (!codec) { + + /* Codec list can be empty for component<->component chain */ + if (!codec && !card->component_chaining) { ret = -ENODEV; goto error; } + /* get platform */ plat = of_get_child_by_name(node, is_top ? PREFIX "plat" : "plat"); @@ -432,9 +434,10 @@ static int simple_for_each_link(struct asoc_simple_priv *priv, * It is DPCM * if it has many CPUs, * or has convert-xxx property +* or if component_chaining is used */ - if (dpcm_selectable && - (num > 2 || + if (data && data->dpcm_selectable && + (num > 2 || data->component_chaining || adata.convert_rate || adata.convert_channels)) ret = func_dpcm(priv, np, li, is_top); /* else normal sound */ @@ -654,6 +657,7 @@ static int asoc_simple_probe(struct platform_device *pdev) struct asoc_simple_priv *priv; struct device *dev = >dev; struct device_node *np = dev->of_node; + const struct asoc_simple_soc_data *data; struct snd_soc_card *card; struct link_info li; int ret; @@ -668,6 +672,11 @@ static int asoc_simple_probe(struct platform_device *pdev) card->dev = dev; card->probe = simple_soc_probe; + data = of_device_get_match_data(dev); + + if (data) + card->component_chaining = data->component_chaining; + memset(, 0, sizeof(li)); simple_get_dais_count(priv, ); if (!li.link || !li.dais) @@ -757,10 +766,22 @@ static int asoc_simple_remove(struct platform_device *pdev) return asoc_simple_clean_reference(card); } +static const struct asoc_simple_soc_data scu_card_data = { + .dpcm_selectable = true, +}; + +/* Component chaining with DPCM */ +static const struct asoc_simple_soc_data cc_card_data = { + .dpcm_selectable = true, + .component_chaining = true, +}; + static const struct of_device_id simple_of_match[] = { { .compatible = "simple-audio-card", }, {
[PATCH v4 07/23] ASoC: tegra: Add Tegra210 based ADMAIF driver
ADMAIF is the interface between ADMA and AHUB. Each ADMA channel that sends/receives data to/from AHUB must intreface through an ADMAIF channel. ADMA channel sending data to AHUB pairs with an ADMAIF Tx channel and similarly ADMA channel receiving data from AHUB pairs with an ADMAIF Rx channel. Buffer size is configurable for each ADMAIF channel, but currently SW uses default values. This patch registers ADMAIF driver with ASoC framework. The component driver exposes DAPM widgets, routes and kcontrols for the device. The DAI driver exposes ADMAIF interfaces, which can be used to connect different components in the ASoC layer. Makefile and Kconfig support is added to allow to build the driver. The ADMAIF device can be enabled in the DT via "nvidia,tegra210-admaif" compatible binding. Tegra PCM driver is updated to expose required PCM interfaces and snd_pcm_ops callbacks. Signed-off-by: Sameer Pujar --- sound/soc/tegra/Kconfig | 12 + sound/soc/tegra/Makefile | 2 + sound/soc/tegra/tegra210_admaif.c | 845 ++ sound/soc/tegra/tegra210_admaif.h | 162 sound/soc/tegra/tegra_pcm.c | 235 ++- sound/soc/tegra/tegra_pcm.h | 21 +- 6 files changed, 1275 insertions(+), 2 deletions(-) create mode 100644 sound/soc/tegra/tegra210_admaif.c create mode 100644 sound/soc/tegra/tegra210_admaif.h diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig index 63d5ae9..0a05992 100644 --- a/sound/soc/tegra/Kconfig +++ b/sound/soc/tegra/Kconfig @@ -106,6 +106,18 @@ config SND_SOC_TEGRA186_DSPK the desired 1-bit output via Delta Sigma Modulation (DSM). Say Y or M if you want to add support for Tegra186 DSPK module. +config SND_SOC_TEGRA210_ADMAIF + tristate "Tegra210 ADMAIF module" + depends on SND_SOC_TEGRA + help + Config to enable ADMAIF which is the interface between ADMA and + Audio Hub (AHUB). Each ADMA channel that sends/receives data to/ + from AHUB must interface through an ADMAIF channel. ADMA channel + sending data to AHUB pairs with an ADMAIF Tx channel, where as + ADMA channel receiving data from AHUB pairs with an ADMAIF Rx + channel. Buffer size is configurable for each ADMAIIF channel. + Say Y or M if you want to add support for Tegra210 ADMAIF module. + config SND_SOC_TEGRA_RT5640 tristate "SoC Audio support for Tegra boards using an RT5640 codec" depends on SND_SOC_TEGRA && I2C && GPIOLIB diff --git a/sound/soc/tegra/Makefile b/sound/soc/tegra/Makefile index 336c4c7..60040a0 100644 --- a/sound/soc/tegra/Makefile +++ b/sound/soc/tegra/Makefile @@ -12,6 +12,7 @@ snd-soc-tegra210-ahub-objs := tegra210_ahub.o snd-soc-tegra210-dmic-objs := tegra210_dmic.o snd-soc-tegra210-i2s-objs := tegra210_i2s.o snd-soc-tegra186-dspk-objs := tegra186_dspk.o +snd-soc-tegra210-admaif-objs := tegra210_admaif.o obj-$(CONFIG_SND_SOC_TEGRA) += snd-soc-tegra-pcm.o obj-$(CONFIG_SND_SOC_TEGRA) += snd-soc-tegra-utils.o @@ -25,6 +26,7 @@ obj-$(CONFIG_SND_SOC_TEGRA210_DMIC) += snd-soc-tegra210-dmic.o obj-$(CONFIG_SND_SOC_TEGRA210_AHUB) += snd-soc-tegra210-ahub.o obj-$(CONFIG_SND_SOC_TEGRA210_I2S) += snd-soc-tegra210-i2s.o obj-$(CONFIG_SND_SOC_TEGRA186_DSPK) += snd-soc-tegra186-dspk.o +obj-$(CONFIG_SND_SOC_TEGRA210_ADMAIF) += snd-soc-tegra210-admaif.o # Tegra machine Support snd-soc-tegra-rt5640-objs := tegra_rt5640.o diff --git a/sound/soc/tegra/tegra210_admaif.c b/sound/soc/tegra/tegra210_admaif.c new file mode 100644 index 000..a8cfacc --- /dev/null +++ b/sound/soc/tegra/tegra210_admaif.c @@ -0,0 +1,845 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// tegra210_admaif.c - Tegra ADMAIF driver +// +// Copyright (c) 2020 NVIDIA CORPORATION. All rights reserved. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tegra210_admaif.h" +#include "tegra_cif.h" +#include "tegra_pcm.h" + +#define CH_REG(offset, reg, id) \ + ((offset) + (reg) + (TEGRA_ADMAIF_CHANNEL_REG_STRIDE * (id))) + +#define CH_TX_REG(reg, id) CH_REG(admaif->soc_data->tx_base, reg, id) + +#define CH_RX_REG(reg, id) CH_REG(admaif->soc_data->rx_base, reg, id) + +#define REG_DEFAULTS(id, rx_ctrl, tx_ctrl, tx_base, rx_base) \ + { CH_REG(rx_base, TEGRA_ADMAIF_RX_INT_MASK, id), 0x0001 }, \ + { CH_REG(rx_base, TEGRA_ADMAIF_CH_ACIF_RX_CTRL, id), 0x7700 }, \ + { CH_REG(rx_base, TEGRA_ADMAIF_RX_FIFO_CTRL, id), rx_ctrl }, \ + { CH_REG(tx_base, TEGRA_ADMAIF_TX_INT_MASK, id), 0x0001 }, \ + { CH_REG(tx_base, TEGRA_ADMAIF_CH_ACIF_TX_CTRL, id), 0x7700 }, \ + { CH_REG(tx_base, TEGRA_ADMAIF_TX_FIFO_CTRL, id), tx_ctrl } + +#define ADMAIF_REG_DEFAULTS(id, chip) \ + REG_DEFAULTS((id) - 1,
[PATCH v4 09/23] ASoC: simple-card: Use of_node and DAI names for DAI link names
For multiple instances of components, using DAI name alone for DAI links is causing conflicts. Components can define multiple DAIs and hence using just a device name won't help either. Thus DT device node reference and DAI names are used to uniquely represent DAI link names. Signed-off-by: Sameer Pujar --- sound/soc/generic/simple-card.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 55e9f88..0f443c0 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -170,7 +170,8 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, goto out_put_node; ret = asoc_simple_set_dailink_name(dev, dai_link, - "fe.%s", + "fe.%pOFP.%s", + cpus->of_node, cpus->dai_name); if (ret < 0) goto out_put_node; @@ -203,7 +204,8 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, goto out_put_node; ret = asoc_simple_set_dailink_name(dev, dai_link, - "be.%s", + "be.%pOFP.%s", + codecs->of_node, codecs->dai_name); if (ret < 0) goto out_put_node; -- 2.7.4
[PATCH v1] mm:free unused pages in kmalloc_order
Environment using the slub allocator, 1G memory in my ARM32. kmalloc(1024, GFP_HIGHUSER) can allocate memory normally, kmalloc(64*1024, GFP_HIGHUSER) will cause a memory leak, because alloc_pages returns highmem physical pages, but it cannot be directly converted into a virtual address and return NULL, the pages has not been released. Usually driver developers will not use the GFP_HIGHUSER flag to allocate memory in kmalloc, but I think this memory leak is not perfect, it is best to be fixed. This is the first time I have posted a patch, there may be something wrong. Signed-off-by: Long Li --- mm/slab_common.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index a143a8c8f874..d2c53b980ab3 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -819,8 +819,12 @@ void *kmalloc_order(size_t size, gfp_t flags, unsigned int order) page = alloc_pages(flags, order); if (likely(page)) { ret = page_address(page); - mod_node_page_state(page_pgdat(page), NR_SLAB_UNRECLAIMABLE_B, - PAGE_SIZE << order); + if (ret) + mod_node_page_state(page_pgdat(page), + NR_SLAB_UNRECLAIMABLE_B, + PAGE_SIZE << order); + else + __free_pages(page, order); } ret = kasan_kmalloc_large(ret, size, flags); /* As ret might get tagged, call kmemleak hook after KASAN. */ -- 2.17.1
[PATCH v4 12/23] ASoC: simple-card: Support DPCM DAI link with multiple Codecs
The simple-card driver supports multiple CPU and single Codec entries for DPCM DAI links. In some cases it is required to have multiple CPU/Codecs. Currently parsing logic for DPCM link loops over all children of DAI link but assumes that there is a single Codec entry. When DAI link has multiple Codecs it considers only the first Codec entry and remaining Codecs are wrongly treated as CPU. This happens because first Codec is used as reference for parsing all other child nodes. This is fixed by using string comparisons of child node names instead of node pointer reference in simple_dai_link_of_dpcm(). So All CPU get parsed in first run and all Codecs in subsequent run. After this simple_dai_link_of_dpcm() does not required 'codec' argument and hence is removed. Signed-off-by: Sameer Pujar --- sound/soc/generic/simple-card.c | 16 +--- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 02d6295..15c4388 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -116,7 +116,6 @@ static void simple_parse_mclk_fs(struct device_node *top, static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, struct device_node *np, - struct device_node *codec, struct link_info *li, bool is_top) { @@ -137,8 +136,13 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, * Codec |return|Pass * np */ - if (li->cpu == (np == codec)) - return 0; + if (li->cpu) { + if (!strcmp(np->name, "codec")) + return 0; + } else { + if (!strcmp(np->name, "cpu")) + return 0; + } dev_dbg(dev, "link_of DPCM (%pOF)\n", np); @@ -354,7 +358,6 @@ static int simple_for_each_link(struct asoc_simple_priv *priv, struct link_info *li, bool is_top), int (*func_dpcm)(struct asoc_simple_priv *priv, struct device_node *np, -struct device_node *codec, struct link_info *li, bool is_top)) { struct device *dev = simple_priv_to_dev(priv); @@ -407,7 +410,7 @@ static int simple_for_each_link(struct asoc_simple_priv *priv, if (dpcm_selectable && (num > 2 || adata.convert_rate || adata.convert_channels)) - ret = func_dpcm(priv, np, codec, li, is_top); + ret = func_dpcm(priv, np, li, is_top); /* else normal sound */ else ret = func_noml(priv, np, codec, li, is_top); @@ -527,12 +530,11 @@ static int simple_count_noml(struct asoc_simple_priv *priv, static int simple_count_dpcm(struct asoc_simple_priv *priv, struct device_node *np, -struct device_node *codec, struct link_info *li, bool is_top) { li->dais++; /* CPU or Codec */ li->link++; /* CPU-dummy or dummy-Codec */ - if (np == codec) + if (!strcmp(np->name, "codec")) li->conf++; return 0; -- 2.7.4
[PATCH v4 04/23] ASoC: tegra: Add Tegra210 based I2S driver
The Inter-IC Sound (I2S) controller implements full-duplex, bi-directional and single direction point to point serial interface. It can interface with I2S compatible devices. Tegra I2S controller can operate as both master and slave. This patch registers I2S controller with ASoC framework. The component driver exposes DAPM widgets, routes and kcontrols for the device. The DAI driver exposes I2S interfaces, which can be used to connect different components in the ASoC layer. Makefile and Kconfig support is added to allow to build the driver. The I2S devices can be enabled in the DT via "nvidia,tegra210-i2s" compatible binding. Signed-off-by: Sameer Pujar --- sound/soc/tegra/Kconfig| 10 + sound/soc/tegra/Makefile | 2 + sound/soc/tegra/tegra210_i2s.c | 780 + sound/soc/tegra/tegra210_i2s.h | 126 +++ 4 files changed, 918 insertions(+) create mode 100644 sound/soc/tegra/tegra210_i2s.c create mode 100644 sound/soc/tegra/tegra210_i2s.h diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig index 2bde1e6..157fa7a 100644 --- a/sound/soc/tegra/Kconfig +++ b/sound/soc/tegra/Kconfig @@ -73,6 +73,16 @@ config SND_SOC_TEGRA210_DMIC PDM receiver. Say Y or M if you want to add support for Tegra210 DMIC module. +config SND_SOC_TEGRA210_I2S +tristate "Tegra210 I2S module" +depends on SND_SOC_TEGRA +help + Config to enable the Inter-IC Sound (I2S) Controller which + implements full-duplex and bidirectional and single direction + point-to-point serial interfaces. It can interface with I2S + compatible devices. + Say Y or M if you want to add support for Tegra210 I2S module. + config SND_SOC_TEGRA_RT5640 tristate "SoC Audio support for Tegra boards using an RT5640 codec" depends on SND_SOC_TEGRA && I2C && GPIOLIB diff --git a/sound/soc/tegra/Makefile b/sound/soc/tegra/Makefile index f0690cf..e30f6a3 100644 --- a/sound/soc/tegra/Makefile +++ b/sound/soc/tegra/Makefile @@ -9,6 +9,7 @@ snd-soc-tegra20-spdif-objs := tegra20_spdif.o snd-soc-tegra30-ahub-objs := tegra30_ahub.o snd-soc-tegra30-i2s-objs := tegra30_i2s.o snd-soc-tegra210-dmic-objs := tegra210_dmic.o +snd-soc-tegra210-i2s-objs := tegra210_i2s.o obj-$(CONFIG_SND_SOC_TEGRA) += snd-soc-tegra-pcm.o obj-$(CONFIG_SND_SOC_TEGRA) += snd-soc-tegra-utils.o @@ -19,6 +20,7 @@ obj-$(CONFIG_SND_SOC_TEGRA20_SPDIF) += snd-soc-tegra20-spdif.o obj-$(CONFIG_SND_SOC_TEGRA30_AHUB) += snd-soc-tegra30-ahub.o obj-$(CONFIG_SND_SOC_TEGRA30_I2S) += snd-soc-tegra30-i2s.o obj-$(CONFIG_SND_SOC_TEGRA210_DMIC) += snd-soc-tegra210-dmic.o +obj-$(CONFIG_SND_SOC_TEGRA210_I2S) += snd-soc-tegra210-i2s.o # Tegra machine Support snd-soc-tegra-rt5640-objs := tegra_rt5640.o diff --git a/sound/soc/tegra/tegra210_i2s.c b/sound/soc/tegra/tegra210_i2s.c new file mode 100644 index 000..a48124c --- /dev/null +++ b/sound/soc/tegra/tegra210_i2s.c @@ -0,0 +1,780 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// tegra210_i2s.c - Tegra210 I2S driver +// +// Copyright (c) 2020 NVIDIA CORPORATION. All rights reserved. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tegra210_i2s.h" +#include "tegra_cif.h" + +static const struct reg_default tegra210_i2s_reg_defaults[] = { + { TEGRA210_I2S_RX_INT_MASK, 0x0003 }, + { TEGRA210_I2S_RX_CIF_CTRL, 0x7700 }, + { TEGRA210_I2S_TX_INT_MASK, 0x0003 }, + { TEGRA210_I2S_TX_CIF_CTRL, 0x7700 }, + { TEGRA210_I2S_CG, 0x1 }, + { TEGRA210_I2S_TIMING, 0x001f }, + { TEGRA210_I2S_ENABLE, 0x1 }, + /* +* Below update does not have any effect on Tegra186 and Tegra194. +* On Tegra210, I2S4 has "i2s4a" and "i2s4b" pins and below update +* is required to select i2s4b for it to be functional for I2S +* operation. +*/ + { TEGRA210_I2S_CYA, 0x1 }, +}; + +static void tegra210_i2s_set_slot_ctrl(struct regmap *regmap, + unsigned int total_slots, + unsigned int tx_slot_mask, + unsigned int rx_slot_mask) +{ + regmap_write(regmap, TEGRA210_I2S_SLOT_CTRL, total_slots - 1); + regmap_write(regmap, TEGRA210_I2S_TX_SLOT_CTRL, tx_slot_mask); + regmap_write(regmap, TEGRA210_I2S_RX_SLOT_CTRL, rx_slot_mask); +} + +static int tegra210_i2s_set_clock_rate(struct device *dev, + unsigned int clock_rate) +{ + struct tegra210_i2s *i2s = dev_get_drvdata(dev); + unsigned int val; + int err; + + regmap_read(i2s->regmap, TEGRA210_I2S_CTRL, ); + + /* No need to set rates if I2S is being operated in slave */ + if (!(val & I2S_CTRL_MASTER_EN)) + return 0; + + err = clk_set_rate(i2s->clk_i2s, clock_rate); + if (err) { +
[PATCH v4 06/23] ASoC: tegra: Add Tegra186 based DSPK driver
The Digital Speaker Controller (DSPK) converts the multi-bit Pulse Code Modulation (PCM) audio input to oversampled 1-bit Pulse Density Modulation (PDM) output. From the signal flow perpsective, the DSPK can be viewed as a PDM transmitter that up-samples the input to the desired sampling rate by interpolation then converts the oversampled PCM input to the desired 1-bit output via Delta Sigma Modulation (DSM). This patch registers DSPK component with ASoC framework. The component driver exposes DAPM widgets, routes and kcontrols for the device. The DAI driver exposes DSPK interfaces, which can be used to connect different components in the ASoC layer. Makefile and Kconfig support is added to allow to build the driver. The DSPK devices can be enabled in the DT via "nvidia,tegra186-dspk" compatible binding. This driver can be used on Tegra194 chip as well. Signed-off-by: Sameer Pujar --- sound/soc/tegra/Kconfig | 13 ++ sound/soc/tegra/Makefile| 2 + sound/soc/tegra/tegra186_dspk.c | 427 sound/soc/tegra/tegra186_dspk.h | 70 +++ 4 files changed, 512 insertions(+) create mode 100644 sound/soc/tegra/tegra186_dspk.c create mode 100644 sound/soc/tegra/tegra186_dspk.h diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig index 3166d03..63d5ae9 100644 --- a/sound/soc/tegra/Kconfig +++ b/sound/soc/tegra/Kconfig @@ -93,6 +93,19 @@ config SND_SOC_TEGRA210_I2S compatible devices. Say Y or M if you want to add support for Tegra210 I2S module. +config SND_SOC_TEGRA186_DSPK + tristate "Tegra186 DSPK module" + depends on SND_SOC_TEGRA + help + Config to enable the Digital Speaker Controller (DSPK) which + converts the multi-bit Pulse Code Modulation (PCM) audio input to + oversampled 1-bit Pulse Density Modulation (PDM) output. From the + signal flow perspective DSPK can be viewed as a PDM transmitter + that up-samples the input to the desired sampling rate by + interpolation and then converts the oversampled PCM input to + the desired 1-bit output via Delta Sigma Modulation (DSM). + Say Y or M if you want to add support for Tegra186 DSPK module. + config SND_SOC_TEGRA_RT5640 tristate "SoC Audio support for Tegra boards using an RT5640 codec" depends on SND_SOC_TEGRA && I2C && GPIOLIB diff --git a/sound/soc/tegra/Makefile b/sound/soc/tegra/Makefile index b01d88e..336c4c7 100644 --- a/sound/soc/tegra/Makefile +++ b/sound/soc/tegra/Makefile @@ -11,6 +11,7 @@ snd-soc-tegra30-i2s-objs := tegra30_i2s.o snd-soc-tegra210-ahub-objs := tegra210_ahub.o snd-soc-tegra210-dmic-objs := tegra210_dmic.o snd-soc-tegra210-i2s-objs := tegra210_i2s.o +snd-soc-tegra186-dspk-objs := tegra186_dspk.o obj-$(CONFIG_SND_SOC_TEGRA) += snd-soc-tegra-pcm.o obj-$(CONFIG_SND_SOC_TEGRA) += snd-soc-tegra-utils.o @@ -23,6 +24,7 @@ obj-$(CONFIG_SND_SOC_TEGRA30_I2S) += snd-soc-tegra30-i2s.o obj-$(CONFIG_SND_SOC_TEGRA210_DMIC) += snd-soc-tegra210-dmic.o obj-$(CONFIG_SND_SOC_TEGRA210_AHUB) += snd-soc-tegra210-ahub.o obj-$(CONFIG_SND_SOC_TEGRA210_I2S) += snd-soc-tegra210-i2s.o +obj-$(CONFIG_SND_SOC_TEGRA186_DSPK) += snd-soc-tegra186-dspk.o # Tegra machine Support snd-soc-tegra-rt5640-objs := tegra_rt5640.o diff --git a/sound/soc/tegra/tegra186_dspk.c b/sound/soc/tegra/tegra186_dspk.c new file mode 100644 index 000..d74aec8 --- /dev/null +++ b/sound/soc/tegra/tegra186_dspk.c @@ -0,0 +1,427 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// tegra186_dspk.c - Tegra186 DSPK driver +// +// Copyright (c) 2020 NVIDIA CORPORATION. All rights reserved. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tegra186_dspk.h" +#include "tegra_cif.h" + +static const struct reg_default tegra186_dspk_reg_defaults[] = { + { TEGRA186_DSPK_RX_INT_MASK, 0x0007 }, + { TEGRA186_DSPK_RX_CIF_CTRL, 0x7700 }, + { TEGRA186_DSPK_CG, 0x0001 }, + { TEGRA186_DSPK_CORE_CTRL, 0x0310 }, + { TEGRA186_DSPK_CODEC_CTRL, 0x0300 }, +}; + +static int tegra186_dspk_get_control(struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct tegra186_dspk *dspk = snd_soc_component_get_drvdata(codec); + + if (strstr(kcontrol->id.name, "FIFO Threshold")) + ucontrol->value.integer.value[0] = dspk->rx_fifo_th; + else if (strstr(kcontrol->id.name, "OSR Value")) + ucontrol->value.integer.value[0] = dspk->osr_val; + else if (strstr(kcontrol->id.name, "LR Polarity Select")) + ucontrol->value.integer.value[0] = dspk->lrsel; + else if (strstr(kcontrol->id.name, "Channel Select")) + ucontrol->value.integer.value[0] = dspk->ch_sel; +
[PATCH v4 13/23] ASoC: simple-card: DPCM DAI link direction as per DAI capability
The soc_new_pcm() fails for DAI link having DAI which supports a single stream direction of either PLAYBACK or CAPTURE. For example it fails for Microphone which can support CAPTURE stream only. This happens because simple-card driver by default populates both stream directions. This can be fixed by populating directions based on DAI capability. For 'CPU<->Dummy' DAI links CPU is used to setup the direction and similarly Codec is used for 'Dummy<->Codec' DAI links. Signed-off-by: Sameer Pujar --- sound/soc/generic/simple-card.c | 27 +-- sound/soc/soc-dai.c | 1 + 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 15c4388..62f2978 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -114,6 +114,23 @@ static void simple_parse_mclk_fs(struct device_node *top, of_node_put(node); } +static int simple_parse_dpcm_dir(const struct snd_soc_dai_link_component *dlc, +struct snd_soc_dai_link *dai_link) +{ + struct snd_soc_dai *dai = snd_soc_find_dai(dlc); + + if (!dai) + return -EINVAL; + + dai_link->dpcm_playback = + snd_soc_dai_stream_valid(dai, SNDRV_PCM_STREAM_PLAYBACK); + + dai_link->dpcm_capture = + snd_soc_dai_stream_valid(dai, SNDRV_PCM_STREAM_CAPTURE); + + return 0; +} + static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, struct device_node *np, struct link_info *li, @@ -183,6 +200,10 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, goto out_put_node; asoc_simple_canonicalize_cpu(dai_link, is_single_links); + + ret = simple_parse_dpcm_dir(cpus, dai_link); + if (ret < 0) + goto out_put_node; } else { struct snd_soc_codec_conf *cconf; @@ -223,6 +244,10 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, "prefix"); snd_soc_of_parse_node_prefix(np, cconf, codecs->of_node, "prefix"); + + ret = simple_parse_dpcm_dir(codecs, dai_link); + if (ret < 0) + goto out_put_node; } simple_parse_convert(dev, np, _props->adata); @@ -239,8 +264,6 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, if (ret < 0) goto out_put_node; - dai_link->dpcm_playback = 1; - dai_link->dpcm_capture = 1; dai_link->ops = _ops; dai_link->init = asoc_simple_dai_init; diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c index b05e18b..bd4465f 100644 --- a/sound/soc/soc-dai.c +++ b/sound/soc/soc-dai.c @@ -390,6 +390,7 @@ bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int dir) /* If the codec specifies any channels at all, it supports the stream */ return stream->channels_min; } +EXPORT_SYMBOL_GPL(snd_soc_dai_stream_valid); void snd_soc_dai_action(struct snd_soc_dai *dai, int stream, int action) -- 2.7.4
[PATCH v4 11/23] ASoC: simple-card: Loop over all children for 'mclk-fs'
CPU/Codec in DPCM DAI links are connected as CPU<->Dummy and Dummy<->Codec. Though mostly CPU won't use/require 'mclk-fs' property, looping over 'np' (current child node in a DAI link) can help in cases where multiple Codecs are defined. This further helps to get rid of 'codec' argument from simple_dai_link_of_dpcm() function, which gets called for DPCM links. Signed-off-by: Sameer Pujar --- sound/soc/generic/simple-card.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 39cdc71..02d6295 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -107,7 +107,9 @@ static void simple_parse_mclk_fs(struct device_node *top, snprintf(prop, sizeof(prop), "%smclk-fs", prefix); of_property_read_u32(node, prop, >mclk_fs); of_property_read_u32(cpu, prop, >mclk_fs); - of_property_read_u32(codec, prop, >mclk_fs); + + if (cpu != codec) + of_property_read_u32(codec, prop, >mclk_fs); of_node_put(node); } @@ -220,7 +222,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, } simple_parse_convert(dev, np, _props->adata); - simple_parse_mclk_fs(top, np, codec, dai_props, prefix); + simple_parse_mclk_fs(top, np, np, dai_props, prefix); asoc_simple_canonicalize_platform(dai_link); -- 2.7.4
[PATCH v4 05/23] ASoC: tegra: Add Tegra210 based AHUB driver
The Audio Hub (AHUB) comprises a collection of hardware accelerators for audio pre/post-processing and a programmable full crossbar (XBAR) for routing audio data across these accelerators in time and in parallel. AHUB supports multiple interfaces to I2S, DSPK, DMIC etc., XBAR is a switch used to configure or modify audio routing between HW accelerators present inside AHUB. This patch registers AHUB component with ASoC framework. The component driver exposes DAPM widgets, routes and kcontrols for the device. The DAI driver exposes AHUB interfaces, which can be used to connect different components in the ASoC layer. Currently the driver takes care of XBAR programming to allow audio data flow through various clients of the AHUB. Makefile and Kconfig support is added to allow to build the driver. The AHUB component can be enabled in the DT via below compatible bindings. - "nvidia,tegra210-ahub" for Tegra210 - "nvidia,tegra186-ahub" for Tegra186 and Tegra194 Signed-off-by: Sameer Pujar --- sound/soc/tegra/Kconfig | 10 + sound/soc/tegra/Makefile| 2 + sound/soc/tegra/tegra210_ahub.c | 578 sound/soc/tegra/tegra210_ahub.h | 100 +++ 4 files changed, 690 insertions(+) create mode 100644 sound/soc/tegra/tegra210_ahub.c create mode 100644 sound/soc/tegra/tegra210_ahub.h diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig index 157fa7a..3166d03 100644 --- a/sound/soc/tegra/Kconfig +++ b/sound/soc/tegra/Kconfig @@ -62,6 +62,16 @@ config SND_SOC_TEGRA30_I2S Tegra30 I2S interface. You will also need to select the individual machine drivers to support below. +config SND_SOC_TEGRA210_AHUB + tristate "Tegra210 AHUB module" + depends on SND_SOC_TEGRA + help + Config to enable Audio Hub (AHUB) module, which comprises of a + switch called Audio Crossbar (AXBAR) used to configure or modify + the audio routing path between various HW accelerators present in + AHUB. + Say Y or M if you want to add support for Tegra210 AHUB module. + config SND_SOC_TEGRA210_DMIC tristate "Tegra210 DMIC module" depends on SND_SOC_TEGRA diff --git a/sound/soc/tegra/Makefile b/sound/soc/tegra/Makefile index e30f6a3..b01d88e 100644 --- a/sound/soc/tegra/Makefile +++ b/sound/soc/tegra/Makefile @@ -8,6 +8,7 @@ snd-soc-tegra20-i2s-objs := tegra20_i2s.o snd-soc-tegra20-spdif-objs := tegra20_spdif.o snd-soc-tegra30-ahub-objs := tegra30_ahub.o snd-soc-tegra30-i2s-objs := tegra30_i2s.o +snd-soc-tegra210-ahub-objs := tegra210_ahub.o snd-soc-tegra210-dmic-objs := tegra210_dmic.o snd-soc-tegra210-i2s-objs := tegra210_i2s.o @@ -20,6 +21,7 @@ obj-$(CONFIG_SND_SOC_TEGRA20_SPDIF) += snd-soc-tegra20-spdif.o obj-$(CONFIG_SND_SOC_TEGRA30_AHUB) += snd-soc-tegra30-ahub.o obj-$(CONFIG_SND_SOC_TEGRA30_I2S) += snd-soc-tegra30-i2s.o obj-$(CONFIG_SND_SOC_TEGRA210_DMIC) += snd-soc-tegra210-dmic.o +obj-$(CONFIG_SND_SOC_TEGRA210_AHUB) += snd-soc-tegra210-ahub.o obj-$(CONFIG_SND_SOC_TEGRA210_I2S) += snd-soc-tegra210-i2s.o # Tegra machine Support diff --git a/sound/soc/tegra/tegra210_ahub.c b/sound/soc/tegra/tegra210_ahub.c new file mode 100644 index 000..93bd23f --- /dev/null +++ b/sound/soc/tegra/tegra210_ahub.c @@ -0,0 +1,578 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// tegra210_ahub.c - Tegra210 AHUB driver +// +// Copyright (c) 2020 NVIDIA CORPORATION. All rights reserved. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "tegra210_ahub.h" + +static int tegra_ahub_get_value_enum(struct snd_kcontrol *kctl, +struct snd_ctl_elem_value *uctl) +{ + struct snd_soc_component *cmpnt = snd_soc_dapm_kcontrol_component(kctl); + struct tegra_ahub *ahub = snd_soc_component_get_drvdata(cmpnt); + struct soc_enum *e = (struct soc_enum *)kctl->private_value; + unsigned int reg, i, bit_pos = 0; + + /* +* Find the bit position of current MUX input. +* If nothing is set, position would be 0 and it corresponds to 'None'. +*/ + for (i = 0; i < ahub->soc_data->reg_count; i++) { + unsigned int reg_val; + + reg = e->reg + (TEGRA210_XBAR_PART1_RX * i); + reg_val = snd_soc_component_read(cmpnt, reg); + reg_val &= ahub->soc_data->mask[i]; + + if (reg_val) { + bit_pos = ffs(reg_val) + + (8 * cmpnt->val_bytes * i); + break; + } + } + + /* Find index related to the item in array *_ahub_mux_texts[] */ + for (i = 0; i < e->items; i++) { + if (bit_pos == e->values[i]) { + uctl->value.enumerated.item[0] = i; + break; + } + } + + return 0; +} + +static int tegra_ahub_put_value_enum(struct
[PATCH v4 10/23] ASoC: simple-card: Wrong daifmt for CPU end of DPCM DAI link
Consider following DPCM DAI link for example: simple-audio-card,dai-link@xxx { format = "i2s"; bitclock-master=<>; frame-master=<>; cpu1: cpu@0 { ... }; codec@0 { ... }; ... }; In above case CPU is expected to be configured as a master and Codec as a slave device. But both CPU/Codec are being configured as slave devices. This happens because asoc_simple_parse_daifmt() uses Codec reference and sets up the 'dai_link->dai_fmt' accordingly while parsing both CPU and Codec. Though populating 'non_legacy_dai_naming' flag as true for CPU component can address above issue in simple cases, but with multiple CPU/Codecs with DPCM DAI link it becomes tricky because right now the first Codec in the DAI link is used as reference. This is fixed by passing current DAI link child node reference to asoc_simple_parse_daifmt(). It parses a CPU/Codec node independently and sets daifmt as per 'bitcloclk/frame-master' property. Signed-off-by: Sameer Pujar --- sound/soc/generic/simple-card.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 0f443c0..39cdc71 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -228,7 +228,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, if (ret) goto out_put_node; - ret = asoc_simple_parse_daifmt(dev, node, codec, + ret = asoc_simple_parse_daifmt(dev, node, np, prefix, _link->dai_fmt); if (ret < 0) goto out_put_node; -- 2.7.4
[PATCH v4 08/23] ASoC: soc-core: Fix component name_prefix parsing
The "prefix" can be defined in DAI link node or it can be specified as part of the component node itself. Currently "sound-name-prefix" defined in a component is not taking effect. Actually the property is not getting parsed. It can be fixed by parsing "sound-name-prefix" property whenever "prefix" is missing in DAI link Codec node. Signed-off-by: Sameer Pujar --- sound/soc/soc-core.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index adedadc..8faca60 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -,8 +,10 @@ static void soc_set_name_prefix(struct snd_soc_card *card, struct snd_soc_codec_conf *map = >codec_conf[i]; if (snd_soc_is_matching_component(>dlc, component)) { - component->name_prefix = map->name_prefix; - return; + if (map->name_prefix) { + component->name_prefix = map->name_prefix; + return; + } } } -- 2.7.4
[PATCH v4 00/23] Add support for Tegra210 Audio
Overview Audio Processing Engine (APE) comprises of Audio DMA (ADMA) and Audio Hub (AHUB) unit. AHUB is a collection of hardware accelerators for audio pre-processing and post-processing. It also includes a programmable full crossbar for routing audio data across these accelerators. This series exposes some of these below mentioned HW devices as ASoC components for Tegra platforms from Tegra210 onwards. * ADMAIF : The interface between ADMA and AHUB * XBAR : Crossbar for routing audio samples across various modules * I2S: Inter-IC Sound Controller * DMIC : Digital Microphone * DSPK : Digital Speaker Following is the summary of current series. * Add YAML DT binding documentation for above mentioned modules. * Helper function for ACIF programming is exposed for Tegra210 and later. * Add ASoC driver components for each of the above modules. * Add DT entries for above components for Tegra210, Tegra186 and Tegra194. * Enable these components for Jetson Nano/TX1/TX2/Xavier * Enhance simple-card DPCM driver to suit Tegra Audio applications with few changes in core. * To begin with, enable sound card support for Tegra210 based platforms like Jetson Nano/TX1. Sound card support for platforms based on Tegra186 and later will be subsequently added which can re-use all of the above components. Changelog = v3 -> v4 * [1/23] "ASoC: dt-bindings: tegra: Add DT bindings for Tegra210" - Removed multiple examples and retained one example per doc - Fixed as per inputs on the previous series - Tested bindings with 'make dt_binding_check/dtbs_check' * [2/23] "ASoC: tegra: Add support for CIF programming" - No change * Common changes (for patch [3/10] to [7/10]) - Mixer control overrides, for PCM parameters (rate, channel, bits), in each driver are dropped. - Updated routing as per DPCM usage - Minor changes related to formatting * New changes (patch [8/23] to [18/23] and patch [23/23]) - Based on discussions in following threads DPCM is used for Tegra Audio. https://lkml.org/lkml/2020/2/20/91 https://lkml.org/lkml/2020/4/30/519 - The simple-card driver is used for Tegra Audio and accordingly some enhancements are made in simple-card and core drivers. - Patch [8/23] to [18/23] are related to simple-card and core changes. - Patch [23/23] adds sound card support to realize complete audio path. This is based on simple-card driver with proposed enhancements. - Re-ordered patches depending on above v2 -> v3 * [1/10] "dt-bindings: sound: tegra: add DT binding for AHUB - Updated licence - Removed redundancy w.r.t items/const/enum - Added constraints wherever needed with "pattern" property * [2/10] "ASoC: tegra: add support for CIF programming" - Removed tegra_cif.c - Instead added inline helper function in tegra_cif.h * common changes (for patch [3/10] to [7/10]) - Replace LATE system calls with Normal sleep - Remove explicit RPM suspend in driver remove() call - Use devm_kzalloc() instead of devm_kcalloc() for single element - Replace 'ret' with 'err' for better reading - Consistent error printing style across drivers - Minor formating fixes * [8/10] "arm64: tegra: add AHUB components for few Tegra chips" - no change * [9/10] "arm64: tegra: enable AHUB modules for few Tegra chips" - no change * [10/10] "arm64: defconfig: enable AHUB components for Tegra210 and later" (New patch) - Enables ACONNECT and AHUB components. With this AHUB and components are registered with ASoC core. v1 -> v2 * [1/9] "dt-bindings: sound: tegra: add DT binding for AHUB" - no changes * [2/9] "ASoC: tegra: add support for CIF programming" - removed CIF programming changes for legacy chips. - this patch now exposes helper function for CIF programming, which can be used on Tegra210 later. - later tegra_cif.c can be extended for legacy chips as well. - updated commit message accordingly * [3/9] "ASoC: tegra: add Tegra210 based DMIC driver" - removed unnecessary initialization of 'ret' in probe() * [4/9] "ASoC: tegra: add Tegra210 based I2S driver" - removed unnecessary initialization of 'ret' in probe() - fixed indentation - added consistent bracing for if-else clauses - updated 'rx_fifo_th' type to 'unsigned int' - used BIT() macro for defines like '1 << {x}' in tegra210_i2s.h * [5/9] "ASoC: tegra: add Tegra210 based AHUB driver" - used of_device_get_match_data() to get 'soc_data' and removed explicit of_match_device() - used devm_platform_ioremap_resource() and removed explicit platform_get_resource() - fixed indentation for devm_snd_soc_register_component() - updated commit message - updated commit message to reflect compatible binding for Tegra186 and Tegra194. * [6/9] "ASoC: tegra: add Tegra186 based DSPK driver" - removed unnecessary initialization of 'ret' in
[PATCH v4 03/23] ASoC: tegra: Add Tegra210 based DMIC driver
The Digital MIC (DMIC) Controller is used to interface with Pulse Density Modulation (PDM) input devices. The DMIC controller implements a converter to convert PDM signals to Pulse Code Modulation (PCM) signals. From signal flow perspective, the DMIC can be viewed as a PDM receiver. This patch registers DMIC component with ASoC framework. The component driver exposes DAPM widgets, routes and kcontrols for the device. The DAI driver exposes DMIC interfaces, which can be used to connect different components in the ASoC layer. Makefile and Kconfig support is added to allow to build the driver. The DMIC devices can be enabled in the DT via "nvidia,tegra210-dmic" compatible string. This driver can be used for Tegra186 and Tegra194 chips as well. Signed-off-by: Sameer Pujar --- sound/soc/tegra/Kconfig | 11 + sound/soc/tegra/Makefile| 2 + sound/soc/tegra/tegra210_dmic.c | 440 sound/soc/tegra/tegra210_dmic.h | 82 4 files changed, 535 insertions(+) create mode 100644 sound/soc/tegra/tegra210_dmic.c create mode 100644 sound/soc/tegra/tegra210_dmic.h diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig index addadc8..2bde1e6 100644 --- a/sound/soc/tegra/Kconfig +++ b/sound/soc/tegra/Kconfig @@ -62,6 +62,17 @@ config SND_SOC_TEGRA30_I2S Tegra30 I2S interface. You will also need to select the individual machine drivers to support below. +config SND_SOC_TEGRA210_DMIC +tristate "Tegra210 DMIC module" +depends on SND_SOC_TEGRA +help + Config to enable the Digital MIC (DMIC) controller which is used + to interface with Pulse Density Modulation (PDM) input devices. + The DMIC controller implements a converter to convert PDM signals + to Pulse Code Modulation (PCM) signals. This can be viewed as a + PDM receiver. + Say Y or M if you want to add support for Tegra210 DMIC module. + config SND_SOC_TEGRA_RT5640 tristate "SoC Audio support for Tegra boards using an RT5640 codec" depends on SND_SOC_TEGRA && I2C && GPIOLIB diff --git a/sound/soc/tegra/Makefile b/sound/soc/tegra/Makefile index c84f183..f0690cf 100644 --- a/sound/soc/tegra/Makefile +++ b/sound/soc/tegra/Makefile @@ -8,6 +8,7 @@ snd-soc-tegra20-i2s-objs := tegra20_i2s.o snd-soc-tegra20-spdif-objs := tegra20_spdif.o snd-soc-tegra30-ahub-objs := tegra30_ahub.o snd-soc-tegra30-i2s-objs := tegra30_i2s.o +snd-soc-tegra210-dmic-objs := tegra210_dmic.o obj-$(CONFIG_SND_SOC_TEGRA) += snd-soc-tegra-pcm.o obj-$(CONFIG_SND_SOC_TEGRA) += snd-soc-tegra-utils.o @@ -17,6 +18,7 @@ obj-$(CONFIG_SND_SOC_TEGRA20_I2S) += snd-soc-tegra20-i2s.o obj-$(CONFIG_SND_SOC_TEGRA20_SPDIF) += snd-soc-tegra20-spdif.o obj-$(CONFIG_SND_SOC_TEGRA30_AHUB) += snd-soc-tegra30-ahub.o obj-$(CONFIG_SND_SOC_TEGRA30_I2S) += snd-soc-tegra30-i2s.o +obj-$(CONFIG_SND_SOC_TEGRA210_DMIC) += snd-soc-tegra210-dmic.o # Tegra machine Support snd-soc-tegra-rt5640-objs := tegra_rt5640.o diff --git a/sound/soc/tegra/tegra210_dmic.c b/sound/soc/tegra/tegra210_dmic.c new file mode 100644 index 000..15761cb --- /dev/null +++ b/sound/soc/tegra/tegra210_dmic.c @@ -0,0 +1,440 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// tegra210_dmic.c - Tegra210 DMIC driver +// +// Copyright (c) 2020 NVIDIA CORPORATION. All rights reserved. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tegra210_dmic.h" +#include "tegra_cif.h" + +static const struct reg_default tegra210_dmic_reg_defaults[] = { + { TEGRA210_DMIC_TX_INT_MASK, 0x0001 }, + { TEGRA210_DMIC_TX_CIF_CTRL, 0x7700 }, + { TEGRA210_DMIC_CG, 0x1 }, + { TEGRA210_DMIC_CTRL, 0x0301 }, + /* Below enables all filters - DCR, LP and SC */ + { TEGRA210_DMIC_DBG_CTRL, 0xe }, + /* Below as per latest POR value */ + { TEGRA210_DMIC_DCR_BIQUAD_0_COEF_4, 0x0 }, + /* LP filter is configured for pass through and used to apply gain */ + { TEGRA210_DMIC_LP_BIQUAD_0_COEF_0, 0x0080 }, + { TEGRA210_DMIC_LP_BIQUAD_0_COEF_1, 0x0 }, + { TEGRA210_DMIC_LP_BIQUAD_0_COEF_2, 0x0 }, + { TEGRA210_DMIC_LP_BIQUAD_0_COEF_3, 0x0 }, + { TEGRA210_DMIC_LP_BIQUAD_0_COEF_4, 0x0 }, + { TEGRA210_DMIC_LP_BIQUAD_1_COEF_0, 0x0080 }, + { TEGRA210_DMIC_LP_BIQUAD_1_COEF_1, 0x0 }, + { TEGRA210_DMIC_LP_BIQUAD_1_COEF_2, 0x0 }, + { TEGRA210_DMIC_LP_BIQUAD_1_COEF_3, 0x0 }, + { TEGRA210_DMIC_LP_BIQUAD_1_COEF_4, 0x0 }, +}; + +static int tegra210_dmic_runtime_suspend(struct device *dev) +{ + struct tegra210_dmic *dmic = dev_get_drvdata(dev); + + regcache_cache_only(dmic->regmap, true); + regcache_mark_dirty(dmic->regmap); + + clk_disable_unprepare(dmic->clk_dmic); + + return 0; +} + +static int tegra210_dmic_runtime_resume(struct device *dev) +{ + struct tegra210_dmic
[PATCH v4 01/23] ASoC: dt-bindings: tegra: Add DT bindings for Tegra210
This patch adds YAML schema for DT binding of AHUB and few of its following components. These devices will be registered as ASoC components and binding will be used on Tegra210 and later chips. * ADMAIF * I2S * DMIC * DSPK Signed-off-by: Sameer Pujar --- .../bindings/sound/nvidia,tegra186-dspk.yaml | 88 + .../bindings/sound/nvidia,tegra210-admaif.yaml | 116 + .../bindings/sound/nvidia,tegra210-ahub.yaml | 144 + .../bindings/sound/nvidia,tegra210-dmic.yaml | 88 + .../bindings/sound/nvidia,tegra210-i2s.yaml| 106 +++ 5 files changed, 542 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml create mode 100644 Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml create mode 100644 Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml create mode 100644 Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml create mode 100644 Documentation/devicetree/bindings/sound/nvidia,tegra210-i2s.yaml diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml b/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml new file mode 100644 index 000..13a9570 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml @@ -0,0 +1,88 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/nvidia,tegra186-dspk.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Tegra186 DSPK Controller Device Tree Bindings + +description: | + The Digital Speaker Controller (DSPK) can be viewed as a Pulse + Density Modulation (PDM) transmitter that up-samples the input to + the desired sampling rate by interpolation and then converts the + over sampled Pulse Code Modulation (PCM) input to the desired 1-bit + output via Delta Sigma Modulation (DSM). + +maintainers: + - Jon Hunter + - Sameer Pujar + +properties: + $nodename: +pattern: "^dspk@[0-9a-f]*$" + + compatible: +oneOf: + - const: nvidia,tegra186-dspk + - items: + - const: nvidia,tegra194-dspk + - const: nvidia,tegra186-dspk + + reg: +maxItems: 1 + + clocks: +maxItems: 1 + + clock-names: +const: dspk + + assigned-clocks: +maxItems: 1 + + assigned-clock-parents: +maxItems: 1 + + assigned-clock-rates: +maxItems: 1 + + "#sound-dai-cells": +const: 1 + + sound-name-prefix: +pattern: "^DSPK[1-9]$" +allOf: + - $ref: /schemas/types.yaml#/definitions/string +description: + Used as prefix for sink/source names of the component. Must be a + unique string among multiple instances of the same component. + The name can be "DSPK1" or "DSPKx", where x depends on the maximum + available instances on a Tegra SoC. + +required: + - compatible + - reg + - clocks + - clock-names + - assigned-clocks + - assigned-clock-parents + - "#sound-dai-cells" + - sound-name-prefix + +examples: + - | +#include + +dspk@2905000 { +compatible = "nvidia,tegra186-dspk"; +reg = <0x2905000 0x100>; +clocks = < TEGRA186_CLK_DSPK1>; +clock-names = "dspk"; +assigned-clocks = < TEGRA186_CLK_DSPK1>; +assigned-clock-parents = < TEGRA186_CLK_PLL_A_OUT0>; +assigned-clock-rates = <12288000>; +#sound-dai-cells = <1>; +sound-name-prefix = "DSPK1"; +}; + +... diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml b/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml new file mode 100644 index 000..aab60cc --- /dev/null +++ b/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml @@ -0,0 +1,116 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/nvidia,tegra210-admaif.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Tegra210 ADMAIF Device Tree Bindings + +description: | + ADMAIF is the interface between ADMA and AHUB. Each ADMA channel + that sends/receives data to/from AHUB must interface through an + ADMAIF channel. ADMA channel sending data to AHUB pairs with ADMAIF + Tx channel and ADMA channel receiving data from AHUB pairs with + ADMAIF Rx channel. + +maintainers: + - Jon Hunter + - Sameer Pujar + +properties: + $nodename: +pattern: "^admaif@[0-9a-f]*$" + + compatible: +oneOf: + - enum: + - nvidia,tegra210-admaif + - nvidia,tegra186-admaif + - items: + - const: nvidia,tegra194-admaif + - const: nvidia,tegra186-admaif + + reg: +maxItems: 1 + + dmas: true + + dma-names: true + + "#sound-dai-cells": +const: 1 + +if: + properties: +compatible: + contains: +const: nvidia,tegra210-admaif + +then: + properties: +dmas: + description: +
[PATCH v4 02/23] ASoC: tegra: Add support for CIF programming
Audio Client Interface (CIF) is a proprietary interface employed to route audio samples through Audio Hub (AHUB) components by inter connecting the various modules. This patch exports an inline function tegra_set_cif() which can be used, for now, to program CIF on Tegra210 and later Tegra generations. Later it can be extended to include helpers for legacy chips as well. Signed-off-by: Sameer Pujar Reviewed-by: Jon Hunter Reviewed-by: Dmitry Osipenko --- sound/soc/tegra/tegra_cif.h | 65 + 1 file changed, 65 insertions(+) create mode 100644 sound/soc/tegra/tegra_cif.h diff --git a/sound/soc/tegra/tegra_cif.h b/sound/soc/tegra/tegra_cif.h new file mode 100644 index 000..7cca806 --- /dev/null +++ b/sound/soc/tegra/tegra_cif.h @@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * tegra_cif.h - TEGRA Audio CIF Programming + * + * Copyright (c) 2020 NVIDIA CORPORATION. All rights reserved. + * + */ + +#ifndef __TEGRA_CIF_H__ +#define __TEGRA_CIF_H__ + +#include + +#define TEGRA_ACIF_CTRL_FIFO_TH_SHIFT 24 +#define TEGRA_ACIF_CTRL_AUDIO_CH_SHIFT 20 +#define TEGRA_ACIF_CTRL_CLIENT_CH_SHIFT16 +#define TEGRA_ACIF_CTRL_AUDIO_BITS_SHIFT 12 +#define TEGRA_ACIF_CTRL_CLIENT_BITS_SHIFT 8 +#define TEGRA_ACIF_CTRL_EXPAND_SHIFT 6 +#define TEGRA_ACIF_CTRL_STEREO_CONV_SHIFT 4 +#define TEGRA_ACIF_CTRL_REPLICATE_SHIFT3 +#define TEGRA_ACIF_CTRL_TRUNCATE_SHIFT 1 +#define TEGRA_ACIF_CTRL_MONO_CONV_SHIFT0 + +/* AUDIO/CLIENT_BITS values */ +#define TEGRA_ACIF_BITS_8 1 +#define TEGRA_ACIF_BITS_16 3 +#define TEGRA_ACIF_BITS_24 5 +#define TEGRA_ACIF_BITS_32 7 + +#define TEGRA_ACIF_UPDATE_MASK 0x3ffb + +struct tegra_cif_conf { + unsigned int threshold; + unsigned int audio_ch; + unsigned int client_ch; + unsigned int audio_bits; + unsigned int client_bits; + unsigned int expand; + unsigned int stereo_conv; + unsigned int replicate; + unsigned int truncate; + unsigned int mono_conv; +}; + +static inline void tegra_set_cif(struct regmap *regmap, unsigned int reg, +struct tegra_cif_conf *conf) +{ + unsigned int value; + + value = (conf->threshold << TEGRA_ACIF_CTRL_FIFO_TH_SHIFT) | + ((conf->audio_ch - 1) << TEGRA_ACIF_CTRL_AUDIO_CH_SHIFT) | + ((conf->client_ch - 1) << TEGRA_ACIF_CTRL_CLIENT_CH_SHIFT) | + (conf->audio_bits << TEGRA_ACIF_CTRL_AUDIO_BITS_SHIFT) | + (conf->client_bits << TEGRA_ACIF_CTRL_CLIENT_BITS_SHIFT) | + (conf->expand << TEGRA_ACIF_CTRL_EXPAND_SHIFT) | + (conf->stereo_conv << TEGRA_ACIF_CTRL_STEREO_CONV_SHIFT) | + (conf->replicate << TEGRA_ACIF_CTRL_REPLICATE_SHIFT) | + (conf->truncate << TEGRA_ACIF_CTRL_TRUNCATE_SHIFT) | + (conf->mono_conv << TEGRA_ACIF_CTRL_MONO_CONV_SHIFT); + + regmap_update_bits(regmap, reg, TEGRA_ACIF_UPDATE_MASK, value); +} + +#endif -- 2.7.4
[PATCH] fbtft-bus.c: Removing that prohibited space before ')'
fbtft-bus.c: fixing ERROR: space prohibited before that close parenthesis ')' by removing that space and ',' in line 65 and 67. Signed-off-by: B K Karthik --- drivers/staging/fbtft/fbtft-bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/fbtft/fbtft-bus.c b/drivers/staging/fbtft/fbtft-bus.c index 63c65dd67b17..847cbfbbd766 100644 --- a/drivers/staging/fbtft/fbtft-bus.c +++ b/drivers/staging/fbtft/fbtft-bus.c @@ -62,9 +62,9 @@ out: \ } \ EXPORT_SYMBOL(func); -define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8, ) +define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8) define_fbtft_write_reg(fbtft_write_reg16_bus8, __be16, u16, cpu_to_be16) -define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16, ) +define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16) void fbtft_write_reg8_bus9(struct fbtft_par *par, int len, ...) { -- 2.20.1 signature.asc Description: PGP signature
[PATCH] fbtft-bus.c:
fbtft-bus.c: fixing ERROR: space prohibited before that close parenthesis ')' by removing that space and ',' in line 65 and 67. Signed-off-by: B K Karthik --- drivers/staging/fbtft/fbtft-bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/fbtft/fbtft-bus.c b/drivers/staging/fbtft/fbtft-bus.c index 63c65dd67b17..847cbfbbd766 100644 --- a/drivers/staging/fbtft/fbtft-bus.c +++ b/drivers/staging/fbtft/fbtft-bus.c @@ -62,9 +62,9 @@ out: \ } \ EXPORT_SYMBOL(func); -define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8, ) +define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8) define_fbtft_write_reg(fbtft_write_reg16_bus8, __be16, u16, cpu_to_be16) -define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16, ) +define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16) void fbtft_write_reg8_bus9(struct fbtft_par *par, int len, ...) { -- 2.20.1 signature.asc Description: PGP signature
Re: [RESEND, v11 2/2] mtd: rawnand: Add NAND controller support on Intel LGM SoC
Hi Miquel, Thank you very much for the review comments and your time... On 26/6/2020 3:09 pm, Miquel Raynal wrote: Hello, "Ramuthevar,Vadivel MuruganX" wrote on Tue, 16 Jun 2020 17:33:32 +0800: From: Ramuthevar Vadivel Murugan This patch adds the new IP of Nand Flash Controller(NFC) support on Intel's Lightning Mountain(LGM) SoC. DMA is used for burst data transfer operation, also DMA HW supports aligned 32bit memory address and aligned data access by default. DMA burst of 8 supported. Data register used to support the read/write operation from/to device. NAND controller driver implements ->exec_op() to replace legacy hooks, these specific call-back method to execute NAND operations. Signed-off-by: Ramuthevar Vadivel Murugan --- [...] +static int ebu_nand_write_page_hwecc(struct nand_chip *chip, const u8 *buf, +int oob_required, int page) +{ + struct mtd_info *mtd = nand_to_mtd(chip); + struct ebu_nand_controller *ebu_host = nand_get_controller_data(chip); + void __iomem *int_sta = ebu_host->hsnand + HSNAND_INT_STA; + int ret, val, x; + u32 reg; + + ebu_nand_trigger(ebu_host, page, NAND_CMD_SEQIN); + + ret = ebu_dma_start(ebu_host, DMA_MEM_TO_DEV, buf, mtd->writesize); + if (ret) + return ret; + + if (oob_required) { + reg = (chip->oob_poi[3] << 24) | (chip->oob_poi[2] << 16) | + (chip->oob_poi[1] << 8) | chip->oob_poi[0]; + + writel(reg, ebu_host->hsnand + HSNAND_CMSG_0); + + reg = (chip->oob_poi[7] << 24) | (chip->oob_poi[6] << 16) | + (chip->oob_poi[5] << 8) | chip->oob_poi[4]; + + writel(reg, ebu_host->hsnand + HSNAND_CMSG_1); + } + + ret = readl_poll_timeout_atomic(int_sta, val, + !(val & HSNAND_INT_STA_WR_C), 10, 1000); + if (ret) + return -EIO; + + x = readl(ebu_host->hsnand + HSNAND_CTL); + x &= ~HSNAND_CTL_GO; + writel(x, ebu_host->hsnand + HSNAND_CTL); + + return 0; +} + +static const u8 ecc_strength[] = { 1, 1, 4, 8, 24, 32, 40, 60, }; + +static int ebu_nand_attach_chip(struct nand_chip *chip) +{ + struct mtd_info *mtd = nand_to_mtd(chip); + struct ebu_nand_controller *ebu_host = nand_get_controller_data(chip); + u32 eccsize, eccsteps, eccbytes, ecctotal, pagesize, pg_per_blk; + u32 eccstrength = chip->ecc.strength; + u32 writesize = mtd->writesize; + u32 blocksize = mtd->erasesize; + int start, val, i; + + if (chip->ecc.mode != NAND_ECC_HW) + return 0; + + /* Check whether eccsize is 0x0 or wrong. assign eccsize = 512 if YES */ /* Default to an ECC size of 512 */ + if (!chip->ecc.size) + chip->ecc.size = 512; + eccsize = chip->ecc.size; + + switch (eccsize) { + case 512: + start = 1; + if (!eccstrength) + eccstrength = 4; + break; + case 1024: + start = 4; + if (!eccstrength) You might want to look at other drivers and check the ecc_strength_ds property. Sure, I will look and update accordingly. + eccstrength = 32; + break; + default: + return -EINVAL; + } + + i = round_up(start + 1, 4); + for (val = start; val < i; val++) { + if (eccstrength == ecc_strength[val]) + break; + } A comment to explain what is this would be nice. Also "i" is not meaningful at all. Well, Noted. + if (val == i) + return -EINVAL; + + if (eccstrength == 8) + eccbytes = 14; + else + eccbytes = DIV_ROUND_UP(eccstrength * fls(8 * eccsize), 8); Does this formula works for eccstrength == 8 too? Yes, it is working. + + eccsteps = writesize / eccsize; + ecctotal = eccsteps * eccbytes; + if ((ecctotal + 8) > mtd->oobsize) + return -ERANGE; + + chip->ecc.total = ecctotal; + pagesize = fls(writesize >> 11); + if (pagesize > HSNAND_PARA0_PAGE_V8192) + return -ERANGE; + + pg_per_blk = fls((blocksize / writesize) >> 6) << 4; + if (pg_per_blk > HSNAND_PARA0_PIB_V256) + return -ERANGE; + + ebu_host->nd_para0 = pagesize | pg_per_blk | HSNAND_PARA0_BYP_EN_NP | +HSNAND_PARA0_BYP_DEC_NP | HSNAND_PARA0_ADEP_EN | +HSNAND_PARA0_TYPE_ONFI | (val << 29); + + mtd_set_ooblayout(mtd, _nand_ooblayout_ops); + chip->ecc.read_page = ebu_nand_read_page_hwecc; + chip->ecc.write_page = ebu_nand_write_page_hwecc; + + return 0; +} + +static int ebu_nand_exec_op(struct nand_chip *chip, + const struct nand_operation *op, bool check_only)
Re: [Patch] mm: Increase pagevec size on large system
On Sat, 27 Jun 2020 04:13:04 +0100 Matthew Wilcox wrote: > On Fri, Jun 26, 2020 at 02:23:03PM -0700, Tim Chen wrote: > > Enlarge the pagevec size to 31 to reduce LRU lock contention for > > large systems. > > > > The LRU lock contention is reduced from 8.9% of total CPU cycles > > to 2.2% of CPU cyles. And the pmbench throughput increases > > from 88.8 Mpages/sec to 95.1 Mpages/sec. > > The downside here is that pagevecs are often stored on the stack (eg > truncate_inode_pages_range()) as well as being used for the LRU list. > On a 64-bit system, this increases the stack usage from 128 to 256 bytes > for this array. > > I wonder if we could do something where we transform the ones on the > stack to DECLARE_STACK_PAGEVEC(pvec), and similarly DECLARE_LRU_PAGEVEC > the ones used for the LRUs. There's plenty of space in the header to > add an unsigned char sz, delete PAGEVEC_SIZE and make it an variable > length struct. > > Or maybe our stacks are now big enough that we just don't care. > What do you think? And I wonder how useful CONFIG_NR_CPUS is for making this decision. Presumably a lot of general-purpose kernel builds have CONFIG_NR_CPUS much larger than the actual number of CPUs. I can't think of much of a fix for this, apart from making it larger on all kernels, Is there a downside to this?
Re: mmotm 2020-06-25-20-36 uploaded (mm/memory-failure.c)
On Fri, 26 Jun 2020 15:09:08 -0700 Randy Dunlap wrote: > On 6/25/20 8:37 PM, a...@linux-foundation.org wrote: > > The mm-of-the-moment snapshot 2020-06-25-20-36 has been uploaded to > > > >http://www.ozlabs.org/~akpm/mmotm/ > > > > mmotm-readme.txt says > > > > README for mm-of-the-moment: > > > > http://www.ozlabs.org/~akpm/mmotm/ > > > > This is a snapshot of my -mm patch queue. Uploaded at random hopefully > > more than once a week. > > > > You will need quilt to apply these patches to the latest Linus release (5.x > > or 5.x-rcY). The series file is in broken-out.tar.gz and is duplicated in > > http://ozlabs.org/~akpm/mmotm/series > > > > when CONFIG_MIGRATION is not set/enabled: > > ../mm/memory-failure.c: In function ‘new_page’: > ../mm/memory-failure.c:1692:9: error: implicit declaration of function > ‘alloc_migration_target’; did you mean ‘alloc_migrate_target’? > [-Werror=implicit-function-declaration] > return alloc_migration_target(p, (unsigned long)); > ^~ > alloc_migrate_target > ../mm/memory-failure.c:1692:9: warning: return makes pointer from integer > without a cast [-Wint-conversion] > return alloc_migration_target(p, (unsigned long)); > ^~ Thanks. Appears to be due to Joonsoo Kim's "mm/migrate: make a standard migration target allocation function".
Re: KASAN: use-after-free Read in tipc_nl_node_dump_monitor_peer (2)
#syz test: https://github.com/congwang/linux.git net
ERROR: "min_low_pfn" undefined!
Hi Arnd, First bad commit (maybe != root cause): tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 1590a2e1c681b0991bd42c992cabfd380e0338f2 commit: 710ec38b0f633ab3e2581f07a73442d809e28ab0 mm: add dummy can_do_mlock() helper date: 9 months ago config: microblaze-randconfig-r026-20200624 (attached as .config) compiler: microblaze-linux-gcc (GCC) 9.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout 710ec38b0f633ab3e2581f07a73442d809e28ab0 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=microblaze If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): ERROR: "min_low_pfn" [drivers/block/aoe/aoe.ko] undefined! >> ERROR: "min_low_pfn" [drivers/scsi/qedf/qedf.ko] undefined! --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org .config.gz Description: application/gzip
[PATCH 2/2] vfio/type1: Update group->domain after aux attach and detach
Update group->domain whenever an aux-domain is attached to or detached from a mediated device. Without this change, iommu_get_domain_for_dev() will be broken for mdev devices. Fixes: 7bd50f0cd2fd5 ("vfio/type1: Add domain at(de)taching group helpers") Signed-off-by: Lu Baolu --- drivers/vfio/vfio_iommu_type1.c | 37 - 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 5e556ac9102a..e0d8802ce0c9 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -1634,10 +1634,28 @@ static int vfio_mdev_attach_domain(struct device *dev, void *data) iommu_device = vfio_mdev_get_iommu_device(dev); if (iommu_device) { - if (iommu_dev_feature_enabled(iommu_device, IOMMU_DEV_FEAT_AUX)) - return iommu_aux_attach_device(domain, iommu_device); - else + if (iommu_dev_feature_enabled(iommu_device, + IOMMU_DEV_FEAT_AUX)) { + struct iommu_group *group = iommu_group_get(dev); + int ret; + + if (!group) + return -EINVAL; + + if (iommu_group_get_domain(group)) { + iommu_group_put(group); + return -EBUSY; + } + + ret = iommu_aux_attach_device(domain, iommu_device); + if (!ret) + iommu_group_set_domain(group, domain); + + iommu_group_put(group); + return ret; + } else { return iommu_attach_device(domain, iommu_device); + } } return -EINVAL; @@ -1650,10 +1668,19 @@ static int vfio_mdev_detach_domain(struct device *dev, void *data) iommu_device = vfio_mdev_get_iommu_device(dev); if (iommu_device) { - if (iommu_dev_feature_enabled(iommu_device, IOMMU_DEV_FEAT_AUX)) + if (iommu_dev_feature_enabled(iommu_device, + IOMMU_DEV_FEAT_AUX)) { + struct iommu_group *group; + iommu_aux_detach_device(domain, iommu_device); - else + group = iommu_group_get(dev); + if (group) { + iommu_group_set_domain(group, NULL); + iommu_group_put(group); + } + } else { iommu_detach_device(domain, iommu_device); + } } return 0; -- 2.17.1
[PATCH 1/2] iommu: Add iommu_group_get/set_domain()
The hardware assistant vfio mediated device is a use case of iommu aux-domain. The interactions between vfio/mdev and iommu during mdev creation and passthr are: - Create a group for mdev with iommu_group_alloc(); - Add the device to the group with group = iommu_group_alloc(); if (IS_ERR(group)) return PTR_ERR(group); ret = iommu_group_add_device(group, >dev); if (!ret) dev_info(>dev, "MDEV: group_id = %d\n", iommu_group_id(group)); - Allocate an aux-domain iommu_domain_alloc() - Attach the aux-domain to the physical device from which the mdev is created. iommu_aux_attach_device() In the whole process, an iommu group was allocated for the mdev and an iommu domain was attached to the group, but the group->domain leaves NULL. As the result, iommu_get_domain_for_dev() doesn't work anymore. This adds iommu_group_get/set_domain() so that group->domain could be managed whenever a domain is attached or detached through the aux-domain api's. Fixes: 7bd50f0cd2fd5 ("vfio/type1: Add domain at(de)taching group helpers") Signed-off-by: Lu Baolu --- drivers/iommu/iommu.c | 28 include/linux/iommu.h | 14 ++ 2 files changed, 42 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index d43120eb1dc5..e2b665303d70 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -715,6 +715,34 @@ int iommu_group_set_name(struct iommu_group *group, const char *name) } EXPORT_SYMBOL_GPL(iommu_group_set_name); +/** + * iommu_group_get_domain - get domain of a group + * @group: the group + * + * This is called to get the domain of a group. + */ +struct iommu_domain *iommu_group_get_domain(struct iommu_group *group) +{ + return group->domain; +} +EXPORT_SYMBOL_GPL(iommu_group_get_domain); + +/** + * iommu_group_set_domain - set domain for a group + * @group: the group + * @domain: iommu domain + * + * This is called to set the domain for a group. In aux-domain case, a domain + * might attach or detach to an iommu group through the aux-domain apis, but + * the group->domain doesn't get a chance to be updated there. + */ +void iommu_group_set_domain(struct iommu_group *group, + struct iommu_domain *domain) +{ + group->domain = domain; +} +EXPORT_SYMBOL_GPL(iommu_group_set_domain); + static int iommu_create_device_direct_mappings(struct iommu_group *group, struct device *dev) { diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 5f0b7859d2eb..ff88d548a870 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -496,6 +496,9 @@ extern void iommu_group_set_iommudata(struct iommu_group *group, void *iommu_data, void (*release)(void *iommu_data)); extern int iommu_group_set_name(struct iommu_group *group, const char *name); +extern struct iommu_domain *iommu_group_get_domain(struct iommu_group *group); +extern void iommu_group_set_domain(struct iommu_group *group, + struct iommu_domain *domain); extern int iommu_group_add_device(struct iommu_group *group, struct device *dev); extern void iommu_group_remove_device(struct device *dev); @@ -840,6 +843,17 @@ static inline int iommu_group_set_name(struct iommu_group *group, return -ENODEV; } +static inline +struct iommu_domain *iommu_group_get_domain(struct iommu_group *group) +{ + return NULL; +} + +static inline void iommu_group_set_domain(struct iommu_group *group, + struct iommu_domain *domain) +{ +} + static inline int iommu_group_add_device(struct iommu_group *group, struct device *dev) { -- 2.17.1
Re: [Patch] mm: Increase pagevec size on large system
On Fri, Jun 26, 2020 at 02:23:03PM -0700, Tim Chen wrote: > Enlarge the pagevec size to 31 to reduce LRU lock contention for > large systems. > > The LRU lock contention is reduced from 8.9% of total CPU cycles > to 2.2% of CPU cyles. And the pmbench throughput increases > from 88.8 Mpages/sec to 95.1 Mpages/sec. The downside here is that pagevecs are often stored on the stack (eg truncate_inode_pages_range()) as well as being used for the LRU list. On a 64-bit system, this increases the stack usage from 128 to 256 bytes for this array. I wonder if we could do something where we transform the ones on the stack to DECLARE_STACK_PAGEVEC(pvec), and similarly DECLARE_LRU_PAGEVEC the ones used for the LRUs. There's plenty of space in the header to add an unsigned char sz, delete PAGEVEC_SIZE and make it an variable length struct. Or maybe our stacks are now big enough that we just don't care. What do you think?
Re: [PATCH -next] scsi: ufs: ufs-exynos: Fix build warning
On Thu, 25 Jun 2020 21:14:05 +0530, Alim Akhtar wrote: > While building for x86_64 allmodconfig, below warning reported > > WARNING: modpost: missing MODULE_LICENSE() in drivers/scsi/ufs/ufs-exynos.o > > Add the missing license/author/description tags. Applied to 5.9/scsi-queue, thanks! [1/1] scsi: ufs: ufs-exynos: Fix build warning https://git.kernel.org/mkp/scsi/c/6c9b3b2aa2df -- Martin K. Petersen Oracle Linux Engineering
Re: [PATCH 1/1] scsi: storvsc: fix spelling mistake
On Wed, 24 Jun 2020 15:56:00 +0200, Flavio Suligoi wrote: > Fix typo: "trigerred" --> "triggered" Applied to 5.9/scsi-queue, thanks! [1/1] scsi: storvsc: Fix spelling mistake https://git.kernel.org/mkp/scsi/c/fbca7a04dbd8 -- Martin K. Petersen Oracle Linux Engineering
Re: [PATCH v2] scsi: ufs: Disable WriteBooster capability in non-supported UFS device
On Thu, 25 Jun 2020 11:04:30 +0800, Stanley Chu wrote: > If UFS device is not qualified to enter the detection of WriteBooster > probing by disallowed UFS version or device quirks, then WriteBooster > capability in host shall be disabled to prevent any WriteBooster > operations in the future. Applied to 5.9/scsi-queue, thanks! [1/1] scsi: ufs: Disable WriteBooster capability for non-supported UFS devices https://git.kernel.org/mkp/scsi/c/a7f1e69d4974 -- Martin K. Petersen Oracle Linux Engineering
Re: [PATCH] scsi: cumana_2: Fix different dev_id between 'request_irq()' and 'free_irq()'
On Thu, 25 Jun 2020 22:47:30 +0200, Christophe JAILLET wrote: > The dev_id used in 'request_irq()' and 'free_irq()' should match. > Use 'info' in both cases. Applied to 5.9/scsi-queue, thanks! [1/1] scsi: cumana_2: Fix different dev_id between request_irq() and free_irq() https://git.kernel.org/mkp/scsi/c/040ab9c4fd00 -- Martin K. Petersen Oracle Linux Engineering
Re: [PATCH 12/26] mm/nds32: Use general page fault accounting
Peter Xu 於 2020年6月27日 週六 上午6:31寫道: > > Use the general page fault accounting by passing regs into handle_mm_fault(). > It naturally solve the issue of multiple page fault accounting when page fault > retry happened. > > Fix PERF_COUNT_SW_PAGE_FAULTS perf event manually for page fault retries, by > moving it before taking mmap_sem. > > CC: Nick Hu > CC: Greentime Hu > CC: Vincent Chen > Signed-off-by: Peter Xu > --- > arch/nds32/mm/fault.c | 19 +++ > 1 file changed, 3 insertions(+), 16 deletions(-) > > diff --git a/arch/nds32/mm/fault.c b/arch/nds32/mm/fault.c > index 22527129025c..e730623c 100644 > --- a/arch/nds32/mm/fault.c > +++ b/arch/nds32/mm/fault.c > @@ -122,6 +122,8 @@ void do_page_fault(unsigned long entry, unsigned long > addr, > if (unlikely(faulthandler_disabled() || !mm)) > goto no_context; > > + perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr); > + > /* > * As per x86, we may deadlock here. However, since the kernel only > * validly references user space from well defined areas of the code, > @@ -207,7 +209,7 @@ void do_page_fault(unsigned long entry, unsigned long > addr, > * the fault. > */ > > - fault = handle_mm_fault(vma, addr, flags, NULL); > + fault = handle_mm_fault(vma, addr, flags, regs); > > /* > * If we need to retry but a fatal signal is pending, handle the > @@ -229,22 +231,7 @@ void do_page_fault(unsigned long entry, unsigned long > addr, > goto bad_area; > } > > - /* > -* Major/minor page fault accounting is only done on the initial > -* attempt. If we go through a retry, it is extremely likely that the > -* page will be found in page cache at that point. > -*/ > - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr); > if (flags & FAULT_FLAG_ALLOW_RETRY) { > - if (fault & VM_FAULT_MAJOR) { > - tsk->maj_flt++; > - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, > - 1, regs, addr); > - } else { > - tsk->min_flt++; > - perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, > - 1, regs, addr); > - } > if (fault & VM_FAULT_RETRY) { > flags |= FAULT_FLAG_TRIED; > Hi Peter, Thank you. Acked-by: Greentime Hu
KASAN: use-after-free Read in tipc_nl_node_dump_monitor_peer (2)
Hello, syzbot found the following crash on: HEAD commit:4a21185c Merge git://git.kernel.org/pub/scm/linux/kernel/g.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=1364f2e510 kernel config: https://syzkaller.appspot.com/x/.config?x=20c907630cbdbe5 dashboard link: https://syzkaller.appspot.com/bug?extid=c96e4dfb32f8987fdeed compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1680223910 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1410b22310 IMPORTANT: if you fix the bug, please add the following tag to the commit: Reported-by: syzbot+c96e4dfb32f8987fd...@syzkaller.appspotmail.com == BUG: KASAN: use-after-free in nla_len include/net/netlink.h:1135 [inline] BUG: KASAN: use-after-free in nla_parse_nested_deprecated include/net/netlink.h:1218 [inline] BUG: KASAN: use-after-free in tipc_nl_node_dump_monitor_peer+0x566/0x590 net/tipc/node.c:2788 Read of size 2 at addr 8880a4b0a814 by task syz-executor823/6893 CPU: 0 PID: 6893 Comm: syz-executor823 Not tainted 5.8.0-rc2-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1f0/0x31e lib/dump_stack.c:118 print_address_description+0x66/0x5a0 mm/kasan/report.c:383 __kasan_report mm/kasan/report.c:513 [inline] kasan_report+0x132/0x1d0 mm/kasan/report.c:530 nla_len include/net/netlink.h:1135 [inline] nla_parse_nested_deprecated include/net/netlink.h:1218 [inline] tipc_nl_node_dump_monitor_peer+0x566/0x590 net/tipc/node.c:2788 genl_lock_dumpit+0x86/0xa0 net/netlink/genetlink.c:575 netlink_dump+0x4be/0x10d0 net/netlink/af_netlink.c:2245 __netlink_dump_start+0x538/0x700 net/netlink/af_netlink.c:2353 genl_family_rcv_msg_dumpit net/netlink/genetlink.c:638 [inline] genl_family_rcv_msg net/netlink/genetlink.c:733 [inline] genl_rcv_msg+0xb03/0xe00 net/netlink/genetlink.c:753 netlink_rcv_skb+0x190/0x3a0 net/netlink/af_netlink.c:2469 genl_rcv+0x24/0x40 net/netlink/genetlink.c:764 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline] netlink_unicast+0x786/0x940 net/netlink/af_netlink.c:1329 netlink_sendmsg+0xa57/0xd70 net/netlink/af_netlink.c:1918 sock_sendmsg_nosec net/socket.c:652 [inline] sock_sendmsg net/socket.c:672 [inline] sys_sendmsg+0x519/0x800 net/socket.c:2352 ___sys_sendmsg net/socket.c:2406 [inline] __sys_sendmsg+0x2b1/0x360 net/socket.c:2439 do_syscall_64+0x73/0xe0 arch/x86/entry/common.c:359 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x4452a9 Code: Bad RIP value. RSP: 002b:7fff822c3fa8 EFLAGS: 0246 ORIG_RAX: 002e RAX: ffda RBX: RCX: 004452a9 RDX: RSI: 20c0 RDI: 0003 RBP: 000134d3 R08: 004002e0 R09: 004002e0 R10: R11: 0246 R12: 00402440 R13: 004024d0 R14: R15: Allocated by task 6892: save_stack mm/kasan/common.c:48 [inline] set_track mm/kasan/common.c:56 [inline] __kasan_kmalloc+0x103/0x140 mm/kasan/common.c:494 __kmalloc_reserve net/core/skbuff.c:142 [inline] __alloc_skb+0xde/0x4f0 net/core/skbuff.c:210 alloc_skb include/linux/skbuff.h:1083 [inline] netlink_alloc_large_skb net/netlink/af_netlink.c:1175 [inline] netlink_sendmsg+0x7b2/0xd70 net/netlink/af_netlink.c:1893 sock_sendmsg_nosec net/socket.c:652 [inline] sock_sendmsg net/socket.c:672 [inline] sys_sendmsg+0x519/0x800 net/socket.c:2352 ___sys_sendmsg net/socket.c:2406 [inline] __sys_sendmsg+0x2b1/0x360 net/socket.c:2439 do_syscall_64+0x73/0xe0 arch/x86/entry/common.c:359 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 6892: save_stack mm/kasan/common.c:48 [inline] set_track mm/kasan/common.c:56 [inline] kasan_set_free_info mm/kasan/common.c:316 [inline] __kasan_slab_free+0x114/0x170 mm/kasan/common.c:455 __cache_free mm/slab.c:3426 [inline] kfree+0x10a/0x220 mm/slab.c:3757 skb_release_all net/core/skbuff.c:664 [inline] __kfree_skb+0x56/0x1c0 net/core/skbuff.c:678 netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline] netlink_unicast+0x78e/0x940 net/netlink/af_netlink.c:1329 netlink_sendmsg+0xa57/0xd70 net/netlink/af_netlink.c:1918 sock_sendmsg_nosec net/socket.c:652 [inline] sock_sendmsg net/socket.c:672 [inline] sys_sendmsg+0x519/0x800 net/socket.c:2352 ___sys_sendmsg net/socket.c:2406 [inline] __sys_sendmsg+0x2b1/0x360 net/socket.c:2439 do_syscall_64+0x73/0xe0 arch/x86/entry/common.c:359 entry_SYSCALL_64_after_hwframe+0x44/0xa9 The buggy address belongs to the object at 8880a4b0a800 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 20 bytes inside of 512-byte region [8880a4b0a800,
Re: [PATCH] RDMA/cma: Execute rdma_cm destruction from a handler properly
Hi Jason, I love your patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v5.8-rc2 next-20200626] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Jason-Gunthorpe/RDMA-cma-Execute-rdma_cm-destruction-from-a-handler-properly/20200627-084914 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 1590a2e1c681b0991bd42c992cabfd380e0338f2 config: mips-allyesconfig (attached as .config) compiler: mips-linux-gcc (GCC) 9.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): drivers/infiniband/core/cma.c: In function 'cma_send_device_removal_put': >> drivers/infiniband/core/cma.c:4787:3: error: implicit declaration of >> function 'spin_unlock_irqsave'; did you mean 'spin_lock_irqsave'? >> [-Werror=implicit-function-declaration] 4787 | spin_unlock_irqsave(_priv->lock, flags); | ^~~ | spin_lock_irqsave >> drivers/infiniband/core/cma.c:4789:3: error: implicit declaration of >> function 'cm_id_put'; did you mean 'cma_id_put'? >> [-Werror=implicit-function-declaration] 4789 | cm_id_put(id_priv); | ^ | cma_id_put drivers/infiniband/core/cma.c: In function 'cma_process_remove': drivers/infiniband/core/cma.c:4813:6: warning: unused variable 'ret' [-Wunused-variable] 4813 | int ret; | ^~~ cc1: some warnings being treated as errors vim +4787 drivers/infiniband/core/cma.c 4775 4776 static void cma_send_device_removal_put(struct rdma_id_private *id_priv) 4777 { 4778 struct rdma_cm_event event = { .event = RDMA_CM_EVENT_DEVICE_REMOVAL }; 4779 enum rdma_cm_state state; 4780 unsigned long flags; 4781 4782 /* Record that we want to remove the device */ 4783 mutex_lock(_priv->handler_mutex); 4784 spin_lock_irqsave(_priv->lock, flags); 4785 state = id_priv->state; 4786 if (state == RDMA_CM_DESTROYING || state == RDMA_CM_DEVICE_REMOVAL) { > 4787 spin_unlock_irqsave(_priv->lock, flags); 4788 mutex_unlock(_priv->handler_mutex); > 4789 cm_id_put(id_priv); 4790 return; 4791 } 4792 id_priv->state = RDMA_CM_DEVICE_REMOVAL; 4793 spin_unlock_irqsave(_priv->lock, flags); 4794 4795 if (cma_cm_event_handler(id_priv, )) { 4796 mutex_unlock(_priv->handler_mutex); 4797 cm_id_put(id_priv); 4798 trace_cm_id_destroy(id_priv); 4799 _destroy_id(id_priv, state); 4800 return; 4801 } 4802 mutex_unlock(_priv->handler_mutex); 4803 4804 /* The thread that assigns state does the cancel */ 4805 cma_cancel_operation(id_priv, state); 4806 4807 cm_id_put(id_priv); 4808 } 4809 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org .config.gz Description: application/gzip
Re: [PATCH v4] drm/mediatek: check plane visibility in atomic_update
Hi, Hsin-Yi: Hsin-Yi Wang 於 2020年6月22日 週一 下午11:57寫道: > > Disable the plane if it's not visible. Otherwise mtk_ovl_layer_config() > would proceed with invalid plane and we may see vblank timeout. > Applied to mediatek-drm-next [1], thanks. [1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next Regards, Chun-Kuang. > Fixes: 119f5173628a ("drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.") > Signed-off-by: Hsin-Yi Wang > Reviewed-by: Chun-Kuang Hu > Reviewed-by: Tomasz Figa > --- > v4: fix commit message > v3: Address comment > v2: Add fixes tag > --- > drivers/gpu/drm/mediatek/mtk_drm_plane.c | 25 ++-- > 1 file changed, 15 insertions(+), 10 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c > b/drivers/gpu/drm/mediatek/mtk_drm_plane.c > index c2bd683a87c8..92141a19681b 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c > @@ -164,6 +164,16 @@ static int mtk_plane_atomic_check(struct drm_plane > *plane, >true, true); > } > > +static void mtk_plane_atomic_disable(struct drm_plane *plane, > +struct drm_plane_state *old_state) > +{ > + struct mtk_plane_state *state = to_mtk_plane_state(plane->state); > + > + state->pending.enable = false; > + wmb(); /* Make sure the above parameter is set before update */ > + state->pending.dirty = true; > +} > + > static void mtk_plane_atomic_update(struct drm_plane *plane, > struct drm_plane_state *old_state) > { > @@ -178,6 +188,11 @@ static void mtk_plane_atomic_update(struct drm_plane > *plane, > if (!crtc || WARN_ON(!fb)) > return; > > + if (!plane->state->visible) { > + mtk_plane_atomic_disable(plane, old_state); > + return; > + } > + > gem = fb->obj[0]; > mtk_gem = to_mtk_gem_obj(gem); > addr = mtk_gem->dma_addr; > @@ -200,16 +215,6 @@ static void mtk_plane_atomic_update(struct drm_plane > *plane, > state->pending.dirty = true; > } > > -static void mtk_plane_atomic_disable(struct drm_plane *plane, > -struct drm_plane_state *old_state) > -{ > - struct mtk_plane_state *state = to_mtk_plane_state(plane->state); > - > - state->pending.enable = false; > - wmb(); /* Make sure the above parameter is set before update */ > - state->pending.dirty = true; > -} > - > static const struct drm_plane_helper_funcs mtk_plane_helper_funcs = { > .prepare_fb = drm_gem_fb_prepare_fb, > .atomic_check = mtk_plane_atomic_check, > -- > 2.27.0.111.gc72c7da667-goog >
Re: linux-next: Fixes tag needs some work in the block tree
On 6/26/20 7:56 PM, Konstantin Ryabitsev wrote: > On Fri, Jun 26, 2020 at 07:32:15PM -0600, Jens Axboe wrote: >> On 6/26/20 5:07 PM, Stephen Rothwell wrote: >>> Hi all, >>> >>> In commit >>> >>> cd664b0e35cb ("io_uring: fix hanging iopoll in case of -EAGAIN") >>> >>> Fixes tag >>> >>> Fixes: bbde017a32b3 ("io_uring: add memory barrier to synchronize >>> >>> has these problem(s): >>> >>> - Subject has leading but no trailing parentheses >>> - Subject has leading but no trailing quotes >>> >>> Please do not split Fixes tags over more than one line. >> >> Gah, that's b4 messing it up. I've actually seen this before, but >> I caught it. If you look at the actual commit, this is what the b4 >> output ends up being for the fixes line: >> >> [snip] >> io_kiocb's result and iopoll_completed") >> >> Fixes: bbde017a32b3 ("io_uring: add memory barrier to synchronize >> >> even though it's correct in the email. I'm guessing some issue having to >> do with the longer line? > > Yeah, I'll try to see if there's something I can do here, but it's going > to be largely guesswork. Here's the original email: > > https://lore.kernel.org/lkml/22111b29e298f5f606130fcf4307bda99dbec089.1593077359.git.asml.sile...@gmail.com/raw > > The Fixes: footer really does get split into two. It's not that hard to > add logic just for the Fixes tag (since it conveniently follows a set > pattern), but finding a universal fix for split footers will be more > difficult. Right, but that's what git format-patch does when the line is long. Do we have other tags where that's a concern? If not, then the fix should be solid I think. > I'll see what I can do. Thanks! -- Jens Axboe
Re: [PATCH net-next v2 5/5] hinic: add support to get eeprom information
On 2020/6/24 6:02, Jakub Kicinski wrote: > On Tue, 23 Jun 2020 22:24:09 +0800 Luo bin wrote: >> +int hinic_get_sfp_type(struct hinic_hwdev *hwdev, u8 *data0, u8 *data1) >> +{ >> +u8 sfp_data[STD_SFP_INFO_MAX_SIZE]; >> +u16 len; >> +int err; >> + >> +if (!hwdev || !data0 || !data1) >> +return -EINVAL; > > No need to check these, callers are correct. We don't do defensive > programming in the kernel. > Will fix. Thank you for your review. >> +return 0; > > double space Will fix. Thank you for your review.
Re: linux-next: Fixes tag needs some work in the block tree
On Fri, Jun 26, 2020 at 07:32:15PM -0600, Jens Axboe wrote: > On 6/26/20 5:07 PM, Stephen Rothwell wrote: > > Hi all, > > > > In commit > > > > cd664b0e35cb ("io_uring: fix hanging iopoll in case of -EAGAIN") > > > > Fixes tag > > > > Fixes: bbde017a32b3 ("io_uring: add memory barrier to synchronize > > > > has these problem(s): > > > > - Subject has leading but no trailing parentheses > > - Subject has leading but no trailing quotes > > > > Please do not split Fixes tags over more than one line. > > Gah, that's b4 messing it up. I've actually seen this before, but > I caught it. If you look at the actual commit, this is what the b4 > output ends up being for the fixes line: > > [snip] > io_kiocb's result and iopoll_completed") > > Fixes: bbde017a32b3 ("io_uring: add memory barrier to synchronize > > even though it's correct in the email. I'm guessing some issue having to > do with the longer line? Yeah, I'll try to see if there's something I can do here, but it's going to be largely guesswork. Here's the original email: https://lore.kernel.org/lkml/22111b29e298f5f606130fcf4307bda99dbec089.1593077359.git.asml.sile...@gmail.com/raw The Fixes: footer really does get split into two. It's not that hard to add logic just for the Fixes tag (since it conveniently follows a set pattern), but finding a universal fix for split footers will be more difficult. I'll see what I can do. -K
Re: [PATCH] io_uring: fix function args for !CONFIG_NET
On 6/26/20 5:32 PM, Randy Dunlap wrote: > From: Randy Dunlap > > Fix build errors when CONFIG_NET is not set/enabled: > > ../fs/io_uring.c:5472:10: error: too many arguments to function ‘io_sendmsg’ > ../fs/io_uring.c:5474:10: error: too many arguments to function ‘io_send’ > ../fs/io_uring.c:5484:10: error: too many arguments to function ‘io_recvmsg’ > ../fs/io_uring.c:5486:10: error: too many arguments to function ‘io_recv’ > ../fs/io_uring.c:5510:9: error: too many arguments to function ‘io_accept’ > ../fs/io_uring.c:5518:9: error: too many arguments to function ‘io_connect’ Thanks Randy, applied. -- Jens Axboe
Re: [PATCH v2 3/5] irqchip: Allow QCOM_PDC to be loadable as a permanent module
On Fri, Jun 26, 2020 at 12:42 AM Stephen Boyd wrote: > > Quoting John Stultz (2020-06-24 17:10:37) > > diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c > > index 6ae9e1f0819d..3fee8b655da1 100644 > > --- a/drivers/irqchip/qcom-pdc.c > > +++ b/drivers/irqchip/qcom-pdc.c > > @@ -430,4 +432,33 @@ static int qcom_pdc_init(struct device_node *node, > > struct device_node *parent) > > return ret; > > } > > > > +#ifdef MODULE > > +static int qcom_pdc_probe(struct platform_device *pdev) > > +{ > > + struct device_node *np = pdev->dev.of_node; > > + struct device_node *parent = of_irq_find_parent(np); > > + > > + return qcom_pdc_init(np, parent); > > +} > > + > > +static const struct of_device_id qcom_pdc_match_table[] = { > > + { .compatible = "qcom,pdc" }, > > + {} > > +}; > > +MODULE_DEVICE_TABLE(of, qcom_pdc_match_table); > > + > > +static struct platform_driver qcom_pdc_driver = { > > + .probe = qcom_pdc_probe, > > + .driver = { > > + .name = "qcom-pdc", > > + .of_match_table = qcom_pdc_match_table, > > + .suppress_bind_attrs = true, > > + }, > > +}; > > +module_platform_driver(qcom_pdc_driver); > > +#else > > IRQCHIP_DECLARE(qcom_pdc, "qcom,pdc", qcom_pdc_init); > > Is there any reason to use IRQCHIP_DECLARE if this can work as a > platform device driver? > Hey! Thanks so much for the review! Mostly it was done this way to minimize the change in the non-module case. But if you'd rather avoid the #ifdefery I'll respin it without. thanks -john
Re: linux-next: Fixes tag needs some work in the block tree
On 6/26/20 5:07 PM, Stephen Rothwell wrote: > Hi all, > > In commit > > cd664b0e35cb ("io_uring: fix hanging iopoll in case of -EAGAIN") > > Fixes tag > > Fixes: bbde017a32b3 ("io_uring: add memory barrier to synchronize > > has these problem(s): > > - Subject has leading but no trailing parentheses > - Subject has leading but no trailing quotes > > Please do not split Fixes tags over more than one line. Gah, that's b4 messing it up. I've actually seen this before, but I caught it. If you look at the actual commit, this is what the b4 output ends up being for the fixes line: [snip] io_kiocb's result and iopoll_completed") Fixes: bbde017a32b3 ("io_uring: add memory barrier to synchronize even though it's correct in the email. I'm guessing some issue having to do with the longer line? CC Konstantin. -- Jens Axboe
Re: [PATCH net-next v2 1/5] hinic: add support to set and get pause params
On 2020/6/24 5:54, Jakub Kicinski wrote: > On Tue, 23 Jun 2020 22:24:05 +0800 Luo bin wrote: >> diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c >> b/drivers/net/ethernet/huawei/hinic/hinic_main.c >> index e9e6f4c9309a..e69edb01fd9b 100644 >> --- a/drivers/net/ethernet/huawei/hinic/hinic_main.c >> +++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c >> @@ -467,6 +467,7 @@ int hinic_open(struct net_device *netdev) >> if (ret) >> netif_warn(nic_dev, drv, netdev, >> "Failed to revert port state\n"); >> + > > Unrelated chunk, please drop. > Will undo this.Thanks. >> err_port_state: >> free_rxqs(nic_dev); >> if (nic_dev->flags & HINIC_RSS_ENABLE) { >> @@ -887,6 +888,26 @@ static void netdev_features_init(struct net_device >> *netdev) >> netdev->features = netdev->hw_features | NETIF_F_HW_VLAN_CTAG_FILTER; >> } >> >> +static void hinic_refresh_nic_cfg(struct hinic_dev *nic_dev) >> +{ >> +struct hinic_nic_cfg *nic_cfg = _dev->hwdev->func_to_io.nic_cfg; >> +struct hinic_pause_config pause_info = {0}; >> +struct hinic_port_cap port_cap = {0}; >> + >> +if (hinic_port_get_cap(nic_dev, _cap)) >> +return; >> + >> +mutex_lock(_cfg->cfg_mutex); >> +if (nic_cfg->pause_set || !port_cap.autoneg_state) { >> +nic_cfg->auto_neg = port_cap.autoneg_state; >> +pause_info.auto_neg = nic_cfg->auto_neg; >> +pause_info.rx_pause = nic_cfg->rx_pause; >> +pause_info.tx_pause = nic_cfg->tx_pause; >> +hinic_set_hw_pause_info(nic_dev->hwdev, _info); >> +} >> +mutex_unlock(_cfg->cfg_mutex); >> +} >> + >> /** >> * link_status_event_handler - link event handler >> * @handle: nic device for the handler >> @@ -918,6 +939,9 @@ static void link_status_event_handler(void *handle, void >> *buf_in, u16 in_size, >> >> up(_dev->mgmt_lock); >> >> +if (!HINIC_IS_VF(nic_dev->hwdev->hwif)) >> +hinic_refresh_nic_cfg(nic_dev); >> + >> netif_info(nic_dev, drv, nic_dev->netdev, "HINIC_Link is UP\n"); >> } else { >> down(_dev->mgmt_lock); >> @@ -950,26 +974,38 @@ static int set_features(struct hinic_dev *nic_dev, >> u32 csum_en = HINIC_RX_CSUM_OFFLOAD_EN; >> int err = 0; >> >> -if (changed & NETIF_F_TSO) >> +if (changed & NETIF_F_TSO) { >> err = hinic_port_set_tso(nic_dev, (features & NETIF_F_TSO) ? >> HINIC_TSO_ENABLE : HINIC_TSO_DISABLE); >> +if (err) >> +return err; >> +} >> >> -if (changed & NETIF_F_RXCSUM) >> +if (changed & NETIF_F_RXCSUM) { >> err = hinic_set_rx_csum_offload(nic_dev, csum_en); >> +if (err) >> +return err; >> +} >> >> if (changed & NETIF_F_LRO) { >> err = hinic_set_rx_lro_state(nic_dev, >> !!(features & NETIF_F_LRO), >> HINIC_LRO_RX_TIMER_DEFAULT, >> HINIC_LRO_MAX_WQE_NUM_DEFAULT); >> +if (err) >> +return err; >> } >> >> -if (changed & NETIF_F_HW_VLAN_CTAG_RX) >> +if (changed & NETIF_F_HW_VLAN_CTAG_RX) { >> err = hinic_set_rx_vlan_offload(nic_dev, >> !!(features & >> NETIF_F_HW_VLAN_CTAG_RX)); >> +if (err) >> +return err; >> +} > > I missed this on v1, but this looks broken, multiple features may be > changed at the same time. If user requests RXCSUM and LRO to be changed > and LRO change fails the RXCSUM will be left in a different state than > dev->features indicates. > You're right. Will fix. Thank you. >> -return err; >> +/* enable pause and disable pfc by default */ >> +return hinic_dcb_set_pfc(nic_dev->hwdev, 0, 0); > > Why do you disable PFC every time features are changed? > It can be optimized. Thanks. >> +int hinic_dcb_set_pfc(struct hinic_hwdev *hwdev, u8 pfc_en, u8 pfc_bitmap) > > This is only ever called with 0, 0 as parameters. > . > This function will be called with other parameters before long to support DCB. So I intend not to modify it.
[PATCH 0/3] ring-buffer: Restructure ftrace ring buffer time keeping to allow accurate nested timing
I completed some thorough testing on these patches now, and have injected trace_printk()s (in a way to allow it to safely recurse) to force various data races and then examined the trace to make sure that everything it did was exactly what I expect it to do, or in cases where it did something surprising, I found that it was still a legitimate case! ;-) I found a few bugs along the way, but it all still very much matches the original design. The bugs were more in the implementation. But now that I feel I have those all straighten out, I'm much more confident in this code (famous last words!). Although I did do a lot of custom testing (with all the injecting of trace_printk()s), I have only run these through my standard smoke tests and have not yet run these through my main test suite (13 hour run time). But will do that when I have other non related patches ready to go with it. But for now, these are very close to my finished product. Feel free to try to poke holes in this as well. Special thanks to Mathieu Desnoyers for his annoying critique (and I mean that in a very positive way!). If it wasn't for his comments, I would have missed fixing a small design flaw (the switch back to delta time instead of keeping with the full time stamp). It turned out that that path had other issues, and without removing that path, I would not have been able to add the last patch of this series. Cheers. -- Steve Steven Rostedt (VMware) (3): ring-buffer: Have nested events still record running time stamp ring-buffer: Incorporate absolute timestamp into add_timestamp logic ring-buffer: Add rb_time_t 64 bit operations for speeding up 32 bit kernel/trace/ring_buffer.c | 503 - 1 file changed, 406 insertions(+), 97 deletions(-)
[PATCH 1/3] ring-buffer: Have nested events still record running time stamp
From: "Steven Rostedt (VMware)" Up until now, if an event is interrupted while it is recorded by an interrupt, and that interrupt records events, the time of those events will all be the same. This is because events only record the delta of the time since the previous event (or beginning of a page), and to handle updating the time keeping for that of nested events is extremely racy. After years of thinking about this and several failed attempts, I finally have a solution to solve this puzzle. The problem is that you need to atomically calculate the delta and then update the time stamp you made the delta from, as well as then record it into the buffer, all this while at any time an interrupt can come in and do the same thing. This is easy to solve with heavy weight atomics, but that would be detrimental to the performance of the ring buffer. The current state of affairs sacrificed the time deltas for nested events for performance. The reason for previous failed attempts at solving this puzzle was because I was trying to completely avoid slow atomic operations like cmpxchg. I final came to the conclusion to always avoid cmpxchg is not possible, which is why those previous attempts always failed. But it is possible to pick one path (the most common case) and avoid cmpxchg in that path, which is the "fast path". The most common case is that an event will not be interrupted and have other events added into it. An event can detect if it has interrupted another event, and for these cases we can make it the slow path and use the heavy operations like cmpxchg. One more player was added to the game that made this possible, and that is the "absolute timestamp" (by Tom Zanussi) that allows us to inject a full 59 bit time stamp. (Of course this breaks if a machine is running for more than 18 years without a reboot!). There's barrier() placements around for being paranoid, even when they are not needed because of other atomic functions near by. But those should not hurt, as if they are not needed, they basically become a nop. Note, this also makes the race window much smaller, which means there are less slow paths to slow down the performance. Here's the design of this solution: All this is per cpu, and only needs to worry about nested events (not parallel events). The players: write_tail: The index in the buffer where new events can be written to. It is incremented via local_add() to reserve space for a new event. before_stamp: A time stamp set by all events before reserving space. write_stamp: A time stamp updated by events after it has successfully reserved space. next_write: A copy of "write_tail" used to help with races. /* Save the current position of write */ [A]w = local_read(write_tail); barrier(); /* Read both before and write stamps before touching anything */ before = READ_ONCE(before_stamp); after = local_read(write_stamp); barrier(); /* * If before and after are the same, then this event is not * interrupting a time update. If it is, then reserve space for adding * a full time stamp (this can turn into a time extend which is * just an extended time delta but fill up the extra space). */ if (after != before) abs = true; ts = clock(); /* Now update the before_stamp (everyone does this!) */ [B]WRITE_ONCE(before_stamp, ts); /* Read the current next_write and update it to what we want write * to be after we reserve space. */ next = READ_ONCE(next_write); WRITE_ONCE(next_write, w + len); /* Now reserve space on the buffer */ [C]write = local_add_return(len, write_tail); /* Set tail to be were this event's data is */ tail = write - len; if (w == tail) { /* Nothing interrupted this between A and C */ [D]local_set(write_stamp, ts); barrier(); [E]save_before = READ_ONCE(before_stamp); if (!abs) { /* This did not interrupt a time update */ delta = ts - after; } else { delta = ts; /* The full time stamp will be in use */ } if (ts != save_before) { /* slow path - Was interrupted between C and E */ /* The update to write_stamp could have overwritten the update to * it by the interrupting event, but before and after should be * the same for all completed top events */ after = local_read(write_stamp); if (save_before > after) local_cmpxchg(write_stamp, after, save_before); } } else { /* slow path - Interrupted between A and C */ after =
[PATCH 2/3] ring-buffer: Incorporate absolute timestamp into add_timestamp logic
From: "Steven Rostedt (VMware)" Instead of calling out the absolute test for each time to check if the ring buffer wants absolute time stamps for all its recording, incorporate it with the add_timestamp field and turn it into flags for faster processing between wanting a absolute tag and needing to force one. Signed-off-by: Steven Rostedt (VMware) --- kernel/trace/ring_buffer.c | 42 +- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 4f13ae38b8f8..986ddc8eba93 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -422,13 +422,15 @@ struct rb_event_info { /* * Used for the add_timestamp * NONE - * NORMAL - may be for either time extend or absolute + * EXTEND - wants a time extend + * ABSOLUTE - the buffer requests all events to have absolute time stamps * FORCE - force a full time stamp. */ enum { - RB_ADD_STAMP_NONE, - RB_ADD_STAMP_NORMAL, - RB_ADD_STAMP_FORCE + RB_ADD_STAMP_NONE = 0, + RB_ADD_STAMP_EXTEND = BIT(1), + RB_ADD_STAMP_ABSOLUTE = BIT(2), + RB_ADD_STAMP_FORCE = BIT(3) }; /* * Used for which event context the event is in. @@ -2435,8 +2437,8 @@ rb_update_event(struct ring_buffer_per_cpu *cpu_buffer, * add it to the start of the reserved space. */ if (unlikely(info->add_timestamp)) { - bool abs = info->add_timestamp == RB_ADD_STAMP_FORCE || - ring_buffer_time_stamp_abs(cpu_buffer->buffer); + bool abs = info->add_timestamp & + (RB_ADD_STAMP_FORCE | RB_ADD_STAMP_ABSOLUTE); event = rb_add_time_stamp(event, abs ? info->delta : delta, abs); length -= RB_LEN_TIME_EXTEND; @@ -2885,8 +2887,8 @@ int ring_buffer_unlock_commit(struct trace_buffer *buffer, EXPORT_SYMBOL_GPL(ring_buffer_unlock_commit); static noinline void -rb_handle_timestamp(struct ring_buffer_per_cpu *cpu_buffer, - struct rb_event_info *info) +rb_check_timestamp(struct ring_buffer_per_cpu *cpu_buffer, + struct rb_event_info *info) { WARN_ONCE(info->delta > (1ULL << 59), KERN_WARNING "Delta way too big! %llu ts=%llu write stamp = %llu\n%s", @@ -2898,7 +2900,6 @@ rb_handle_timestamp(struct ring_buffer_per_cpu *cpu_buffer, "please switch to the trace global clock:\n" " echo global > /sys/kernel/debug/tracing/trace_clock\n" "or add trace_clock=global to the kernel command line\n"); - info->add_timestamp = RB_ADD_STAMP_NORMAL; } static struct ring_buffer_event * @@ -2908,8 +2909,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer, struct ring_buffer_event *event; struct buffer_page *tail_page; unsigned long tail, write, w, next; - u64 delta, before, after; - bool abs = false; + u64 before, after; /* Don't let the compiler play games with cpu_buffer->tail_page */ tail_page = info->tail_page = READ_ONCE(cpu_buffer->tail_page); @@ -2923,20 +2923,23 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer, if (ring_buffer_time_stamp_abs(cpu_buffer->buffer)) { info->delta = info->ts; - abs = true; + info->add_timestamp = RB_ADD_STAMP_ABSOLUTE; } else { info->delta = info->ts - after; } - if (unlikely(test_time_stamp(info->delta))) - rb_handle_timestamp(cpu_buffer, info); + if (unlikely(test_time_stamp(info->delta))) { + rb_check_timestamp(cpu_buffer, info); + info->add_timestamp |= RB_ADD_STAMP_EXTEND; + } /* * If interrupting an event time update, we may need an absolute timestamp. * Don't bother if this is the start of a new page (w == 0). */ if (unlikely(before != after && w)) - info->add_timestamp = RB_ADD_STAMP_FORCE; + info->add_timestamp |= RB_ADD_STAMP_FORCE | RB_ADD_STAMP_EXTEND; + /* * If the time delta since the last event is too big to * hold in the time field of the event, then we append a @@ -2976,7 +2979,8 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer, /*D*/ local64_set(_buffer->write_stamp, info->ts); barrier(); /*E*/ save_before = local64_read(_buffer->before_stamp); - if (likely(info->add_timestamp != RB_ADD_STAMP_FORCE)) + if (likely(!(info->add_timestamp & +(RB_ADD_STAMP_FORCE | RB_ADD_STAMP_ABSOLUTE /* This did not interrupt any time update */ info->delta = info->ts - after; else @@ -3019,15 +3023,15 @@ __rb_reserve_next(struct
[PATCH 3/3] ring-buffer: Add rb_time_t 64 bit operations for speeding up 32 bit
From: "Steven Rostedt (VMware)" After a discussion with the new time algorithm to have nested events still have proper time keeping but required using local64_t atomic operations. Mathieu was concerned about the performance this would have on 32 bit machines, as in most cases, atomic 64 bit operations on them can be expensive. As the ring buffer's timing needs do not require full features of local64_t, a wrapper is made to implement a new rb_time_t operation that uses two longs on 32 bit machines but still uses the local64_t operations on 64 bit machines. There's a switch that can be made in the file to force 64 bit to use the 32 bit version just for testing purposes. All reads do not need to succeed if a read happened while the stamp being read is in the process of being updated. The requirement is that all reads must succed that were done by an interrupting event (where this event was interrupted by another event that did the write). Or if the event itself did the write first. That is: rb_time_set(t, x) followed by rb_time_read(t) will always succeed (even if it gets interrupted by another event that writes to t. The result of the read will be either the previous set, or a set performed by an interrupting event. If the read is done by an event that interrupted another event that was in the process of setting the time stamp, and no other event came along to write to that time stamp, it will fail and the rb_time_read() will return that it failed (the value to read will be undefined). A set will always write to the time stamp and return with a valid time stamp, such that any read after it will be valid. A cmpxchg may fail if it interrupted an event that was in the process of updating the time stamp just like the reads do. Other than that, it will act like a normal cmpxchg. The way this works is that the rb_time_t is made of of three fields. A cnt, that gets updated atomically everyting a modification is made. A top that represents the most significant 30 bits of the time, and a bottom to represent the least significant 30 bits of the time. Notice, that the time values is only 60 bits long (where the ring buffer only uses 59 bits, which gives us 18 years of nanoseconds!). The top two bits of both the top and bottom is a 2 bit counter that gets set by the value of the least two significant bits of the cnt. A read of the top and the bottom where both the top and bottom have the same most significant top 2 bits, are considered a match and a valid 60 bit number can be created from it. If they do not match, then the number is considered invalid, and this must only happen if an event interrupted another event in the midst of updating the time stamp. This is only used for 32 bits machines as 64 bit machines can get better performance out of the local64_t. This has been tested heavily by forcing 64 bit to use this logic. Link: https://lore.kernel.org/r/20200625225345.18cf5...@oasis.local.home Inspired-by: Mathieu Desnoyers Signed-off-by: Steven Rostedt (VMware) --- kernel/trace/ring_buffer.c | 260 + 1 file changed, 237 insertions(+), 23 deletions(-) diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 986ddc8eba93..c2c0d25ea004 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -449,6 +449,27 @@ enum { RB_CTX_MAX }; +#if BITS_PER_LONG == 32 +#define RB_TIME_32 +#endif + +/* To test on 64 bit machines */ +//#define RB_TIME_32 + +#ifdef RB_TIME_32 + +struct rb_time_struct { + local_t cnt; + local_t top; + local_t bottom; +}; +#else +struct rb_time_struct { + local64_t time; +}; +#endif +typedef struct rb_time_struct rb_time_t; + /* * head_page == tail_page && head == tail then buffer is empty. */ @@ -485,8 +506,8 @@ struct ring_buffer_per_cpu { unsigned long read; unsigned long read_bytes; unsigned long next_write; - local64_t write_stamp; - local64_t before_stamp; + rb_time_t write_stamp; + rb_time_t before_stamp; u64 read_stamp; /* ring buffer pages to update, > 0 to add, < 0 to remove */ longnr_pages_to_update; @@ -529,6 +550,189 @@ struct ring_buffer_iter { int missed_events; }; +#ifdef RB_TIME_32 + +/* + * On 32 bit machines, local64_t is very expensive. As the ring + * buffer doesn't need all the features of a true 64 bit atomic, + * on 32 bit, it uses these functions (64 still uses local64_t). + * + * For the ring buffer, 64 bit required operations for the time is + * the following: + * + * - Only need 59 bits (uses 60 to make it even). + * - Reads may fail if it interrupted a modification of the time stamp. + * It will succeed if it
RE: Re: [v1,net-next 3/4] net: qos: police action add index for tc flower offloading
Hi Jamal, > -Original Message- > From: Jamal Hadi Salim > Sent: 2020年6月26日 21:28 > To: Po Liu ; da...@davemloft.net; linux- > ker...@vger.kernel.org; net...@vger.kernel.org; ido...@idosch.org > Cc: j...@resnulli.us; vinicius.go...@intel.com; v...@buslov.dev; Claudiu > Manoil ; Vladimir Oltean > ; Alexandru Marginean > ; michael.c...@broadcom.com; > vis...@chelsio.com; sae...@mellanox.com; l...@kernel.org; > j...@mellanox.com; ido...@mellanox.com; > alexandre.bell...@bootlin.com; unglinuxdri...@microchip.com; > k...@kernel.org; xiyou.wangc...@gmail.com; > simon.hor...@netronome.com; pa...@netfilter.org; > mo...@mellanox.com; m-kariche...@ti.com; > andre.gue...@linux.intel.com; step...@networkplumber.org; Edward > Cree > Subject: Re: [v1,net-next 3/4] net: qos: police action add index for tc > flower offloading > > On 2020-06-24 8:34 p.m., Po Liu wrote: > > > > > >> -Original Message- > > >> That is the point i was trying to get to. Basically: > >> You have a counter table which is referenced by "index" > >> You also have a meter/policer table which is referenced by "index". > > > > They should be one same group and same meaning. > > > > Didnt follow. You mean the index is the same for both the stat and policer? Sorry, just ignore this reply line, hardware has this police index counter, but wasn't use in this tc command, just focus on below psfp_streamfilter_counters. I thought you thought in this way. > > >> > >> For policers, they maintain their own stats. So when i say: > >> tc ... flower ... action police ... index 5 The index referred to is > >> in the policer table > >> > > > > Sure. Means police with No. 5 entry. > > > >> But for other actions, example when i say: > >> tc ... flower ... action drop index 10 > > > > Still the question, does gact action drop could bind with index? It > doesn't meanful. > > > > Depends on your hardware. From this discussion i am trying to understand > where the constraint is for your case. > Whether it is your h/w or the TSN spec. > For a sample counting which is flexible see here: > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fp4.o > rg%2Fp4-spec%2Fdocs%2FPSA.html%23sec- > countersdata=02%7C01%7Cpo.liu%40nxp.com%7C02dc8f3f60714afd > 3dab08d819d4c66e%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C1%7 > C637287748941041353sdata=9%2FS%2BAMbHV09H5VrJMwdEeiSPzg > 4w%2FmW5FxQr4ecuze4%3Dreserved=0 > > That concept is not specific to P4 but rather to newer flow-based > hardware. > > More context: > The assumption these days is we can have a _lot_ of flows with a lot of > actions. > Then you want to be able to collect the stats separately, possibly one > counter entry for each action of interest. > Why is this important?f For analytics uses cases, when you are retrieving > the stats you want to reduce the amount of data being retrieved. Typically > these stats are polled every X seconds. > For starters, you dont dump filters (which in your case seems to be the > only way to get the stats). > In current tc, you dump the actions. But that could be improved so you > can just dump the stats. The mapping of stats index to actions is known to > the entity doing the dump. > > Does that make sense? > > >> The index is in the counter/stats table. > >> It is not exactly "10" in hardware, the driver magically hides it > >> from the user - so it could be hw counter index 1234 > > > > Not exactly. Current flower offloading stats means get the chain index > for that flow filter. The other actions should bind to that chain index. > > > > So if i read correctly: You have an index per filter pointing to the counter > table. > Is this something _you_ decided to do in software or is it how the > hardware works? (note i referred to this as "legacy ACL" approach earlier. > It worked like that in old hardware because the main use case was to have > one action on a match (drop/accept kind). It is the hardware works and all registers according to the IEEE802.1Qci spec. > > >Like IEEE802.1Qci, what I am doing is bind gate action to filter > chain(mandatory). And also police action as optional. > > I cant seem to find this spec online. Is it freely available? Maybe need a register count on http://www.ieee802.org/ > Also, if i understand you correctly you are saying according to this spec > you can only have the following type of policy: > tc .. filter match-spec-here .. \ > action gate gate-action-attributes \ > action police ... > > That "action gate" MUST always be present but "action police" is optional? Yes. That is what I trying to do: map stream gate to gate action and flow metering entry to action police. And a flow filter to a stream filter entry. Each stream filter entry in hardware bind with stream filter entry. > > > There is stream counter table which summary the counters pass gate > action entry and police action entry for that chain index(there is a bit > different if two chain sharing same action list). > > One chain counter
Re: KASAN: use-after-free Read in addr_handler (2)
On Sun, Jun 14, 2020 at 04:53:21PM +0800, Hillf Danton wrote: > > Wed, 10 Jun 2020 10:02:11 -0700 > > syzbot found the following crash on: > > > > HEAD commit:7ae77150 Merge tag 'powerpc-5.8-1' of git://git.kernel.org.. > > git tree: upstream > > console output: https://syzkaller.appspot.com/x/log.txt?x=16c0d3a610 > > kernel config: https://syzkaller.appspot.com/x/.config?x=d195fe572fb15312 > > dashboard link: https://syzkaller.appspot.com/bug?extid=a929647172775e335941 > > compiler: gcc (GCC) 9.0.0 20181231 (experimental) > > > > Unfortunately, I don't have any reproducer for this crash yet. > > > > IMPORTANT: if you fix the bug, please add the following tag to the commit: > > Reported-by: syzbot+a929647172775e335...@syzkaller.appspotmail.com > > > > == > > BUG: KASAN: use-after-free in __mutex_lock_common > > kernel/locking/mutex.c:938 [inline] > > BUG: KASAN: use-after-free in __mutex_lock+0x1033/0x13c0 > > kernel/locking/mutex.c:1103 > > Read of size 8 at addr 888088ec33b0 by task kworker/u4:5/14014 > > > > CPU: 1 PID: 14014 Comm: kworker/u4:5 Not tainted 5.7.0-syzkaller #0 > > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS > > Google 01/01/2011 > > Workqueue: ib_addr process_one_req > > Call Trace: > > __dump_stack lib/dump_stack.c:77 [inline] > > dump_stack+0x188/0x20d lib/dump_stack.c:118 > > print_address_description.constprop.0.cold+0xd3/0x413 mm/kasan/report.c:383 > > __kasan_report mm/kasan/report.c:513 [inline] > > kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530 > > __mutex_lock_common kernel/locking/mutex.c:938 [inline] > > __mutex_lock+0x1033/0x13c0 kernel/locking/mutex.c:1103 > > addr_handler+0xa0/0x340 drivers/infiniband/core/cma.c:3100 > > process_one_req+0xfa/0x680 drivers/infiniband/core/addr.c:643 > > process_one_work+0x965/0x16a0 kernel/workqueue.c:2268 > > worker_thread+0x96/0xe20 kernel/workqueue.c:2414 > > kthread+0x388/0x470 kernel/kthread.c:268 > > ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:351 > > > > Allocated by task 31499: > > save_stack+0x1b/0x40 mm/kasan/common.c:48 > > set_track mm/kasan/common.c:56 [inline] > > __kasan_kmalloc mm/kasan/common.c:494 [inline] > > __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:467 > > kmem_cache_alloc_trace+0x153/0x7d0 mm/slab.c:3551 > > kmalloc include/linux/slab.h:555 [inline] > > kzalloc include/linux/slab.h:669 [inline] > > __rdma_create_id+0x5b/0x850 drivers/infiniband/core/cma.c:861 > > ucma_create_id+0x1d1/0x590 drivers/infiniband/core/ucma.c:503 > > ucma_write+0x285/0x350 drivers/infiniband/core/ucma.c:1729 > > __vfs_write+0x76/0x100 fs/read_write.c:495 > > vfs_write+0x268/0x5d0 fs/read_write.c:559 > > ksys_write+0x1ee/0x250 fs/read_write.c:612 > > do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295 > > entry_SYSCALL_64_after_hwframe+0x49/0xb3 > > > > Freed by task 31496: > > save_stack+0x1b/0x40 mm/kasan/common.c:48 > > set_track mm/kasan/common.c:56 [inline] > > kasan_set_free_info mm/kasan/common.c:316 [inline] > > __kasan_slab_free+0xf7/0x140 mm/kasan/common.c:455 > > __cache_free mm/slab.c:3426 [inline] > > kfree+0x109/0x2b0 mm/slab.c:3757 > > ucma_close+0x111/0x300 drivers/infiniband/core/ucma.c:1807 > > __fput+0x33e/0x880 fs/file_table.c:281 > > task_work_run+0xf4/0x1b0 kernel/task_work.c:123 > > tracehook_notify_resume include/linux/tracehook.h:188 [inline] > > exit_to_usermode_loop+0x2fa/0x360 arch/x86/entry/common.c:165 > > prepare_exit_to_usermode arch/x86/entry/common.c:196 [inline] > > syscall_return_slowpath arch/x86/entry/common.c:279 [inline] > > do_syscall_64+0x6b1/0x7d0 arch/x86/entry/common.c:305 > > entry_SYSCALL_64_after_hwframe+0x49/0xb3 > > > > The buggy address belongs to the object at 888088ec3000 > > which belongs to the cache kmalloc-2k of size 2048 > > The buggy address is located 944 bytes inside of > > 2048-byte region [888088ec3000, 888088ec3800) > > The buggy address belongs to the page: > > page:ea000223b0c0 refcount:1 mapcount:0 mapping: > > index:0x0 > > flags: 0xfffe000200(slab) > > raw: 00fffe000200 ea000299f588 ea000263d0c8 8880aa000e00 > > raw: 888088ec3000 00010001 > > page dumped because: kasan: bad access detected > > > > Memory state around the buggy address: > > 888088ec3280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > > 888088ec3300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > > >888088ec3380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > > ^ > > 888088ec3400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > > 888088ec3480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > > == > > Add extra grab to id_priv to make addr_handler() safe. > It may also fix what's >
Re: [PATCH v3 bpf-next 4/4] selftests/bpf: add bpf_iter test with bpf_get_task_stack()
On 6/26/20 5:26 PM, Song Liu wrote: The new test is similar to other bpf_iter tests. It would be great if you can show some results from bpf_iter_task_stack.c dump. Signed-off-by: Song Liu --- .../selftests/bpf/prog_tests/bpf_iter.c | 17 ++ .../selftests/bpf/progs/bpf_iter_task_stack.c | 53 +++ 2 files changed, 70 insertions(+) create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c index 1e2e0fced6e81..fed42755416db 100644 --- a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c +++ b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c @@ -5,6 +5,7 @@ #include "bpf_iter_netlink.skel.h" #include "bpf_iter_bpf_map.skel.h" #include "bpf_iter_task.skel.h" +#include "bpf_iter_task_stack.skel.h" #include "bpf_iter_task_file.skel.h" #include "bpf_iter_tcp4.skel.h" #include "bpf_iter_tcp6.skel.h" @@ -110,6 +111,20 @@ static void test_task(void) bpf_iter_task__destroy(skel); } +static void test_task_stack(void) +{ + struct bpf_iter_task_stack *skel; + + skel = bpf_iter_task_stack__open_and_load(); + if (CHECK(!skel, "bpf_iter_task_stack__open_and_load", + "skeleton open_and_load failed\n")) + return; + + do_dummy_read(skel->progs.dump_task_stack); + + bpf_iter_task_stack__destroy(skel); +} + static void test_task_file(void) { struct bpf_iter_task_file *skel; @@ -452,6 +467,8 @@ void test_bpf_iter(void) test_bpf_map(); if (test__start_subtest("task")) test_task(); + if (test__start_subtest("task_stack")) + test_task_stack(); if (test__start_subtest("task_file")) test_task_file(); if (test__start_subtest("tcp4")) diff --git a/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c b/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c new file mode 100644 index 0..39b21df17c3ee --- /dev/null +++ b/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2020 Facebook */ +/* "undefine" structs in vmlinux.h, because we "override" them below */ +#define bpf_iter_meta bpf_iter_meta___not_used +#define bpf_iter__task bpf_iter__task___not_used +#include "vmlinux.h" +#undef bpf_iter_meta +#undef bpf_iter__task +#include +#include + +char _license[] SEC("license") = "GPL"; + +struct bpf_iter_meta { + struct seq_file *seq; + __u64 session_id; + __u64 seq_num; +} __attribute__((preserve_access_index)); + +struct bpf_iter__task { + struct bpf_iter_meta *meta; + struct task_struct *task; +} __attribute__((preserve_access_index)); Please take a look at bpf_iter_task.c. The above code can be simplified as #include "bpf_iter.h" #include #include + +#define MAX_STACK_TRACE_DEPTH 64 +unsigned long entries[MAX_STACK_TRACE_DEPTH]; +#define SIZE_OF_ULONG (sizeof(unsigned long)) + +SEC("iter/task") +int dump_task_stack(struct bpf_iter__task *ctx) +{ + struct seq_file *seq = ctx->meta->seq; + struct task_struct *task = ctx->task; + long i, retlen; + + if (task == (void *)0) + return 0; + + retlen = bpf_get_task_stack(task, entries, + MAX_STACK_TRACE_DEPTH * SIZE_OF_ULONG, 0); + if (retlen < 0) + return 0; + + BPF_SEQ_PRINTF(seq, "pid: %8u num_entries: %8u\n", task->pid, + retlen / SIZE_OF_ULONG); + for (i = 0; i < MAX_STACK_TRACE_DEPTH; i++) { + if (retlen > i * SIZE_OF_ULONG) + BPF_SEQ_PRINTF(seq, "[<0>] %pB\n", (void *)entries[i]); + } + BPF_SEQ_PRINTF(seq, "\n"); + + return 0; +}
Compensation,
Attention Beneficiary!!! We have actually been authorized by the newly appointed United Nation’s Secretary-General, and the governing body of the UNITED NATION’S Monetary Unit, to investigate the unnecessary delay on your compensation payment, recommended and approved in your favor. During the course of our investigation, we discovered with dismay that your payment has been unnecessarily delayed by corrupt officials who are trying to divert your funds into their private accounts. To forestall this, security for your funds was organized in the form of your personal identification number (PIN) (Atm Card) and this will enable only you to have direct control over your funds in the (Atm Card). We will monitor this payment ourselves to avoid the hopeless situation created by the Officials. An irrevocable payment guarantee has been issued on your payment. However, we are happy to inform you that based on our recommendation/instructions, your complete compensation funds have been credited in your favor through (Atm Card). You are therefore advised to contact: Mrs. Syvie Riene, through her e-mail address: syvierien...@gmail.com contact her now for the release of your (Atm Card ) to you. As soon as you establish a contact with her, an Atm Card will be issued to you which you can use to withdraw your funds in any Atm machine in any part of the world, So if you like to receive your funds through this means you are advised to contact Mrs. Syvie Riene, Also be inform that the total amount in the Atm Card which you are to receive is USD$2,750,000.00. We expect your urgent response to this email to enable us to monitor this payment effectively, thereby, making contact with Mrs. Syvie Riene, as directed to avoid further delay. Regards Mr. Newton Williams
[PATCH v3 bpf-next 2/4] bpf: introduce helper bpf_get_task_stack()
Introduce helper bpf_get_task_stack(), which dumps stack trace of given task. This is different to bpf_get_stack(), which gets stack track of current task. One potential use case of bpf_get_task_stack() is to call it from bpf_iter__task and dump all /proc//stack to a seq_file. bpf_get_task_stack() uses stack_trace_save_tsk() instead of get_perf_callchain() for kernel stack. The benefit of this choice is that stack_trace_save_tsk() doesn't require changes in arch/. The downside of using stack_trace_save_tsk() is that stack_trace_save_tsk() dumps the stack trace to unsigned long array. For 32-bit systems, we need to translate it to u64 array. Acked-by: Andrii Nakryiko Signed-off-by: Song Liu --- include/linux/bpf.h| 1 + include/uapi/linux/bpf.h | 36 +++- kernel/bpf/stackmap.c | 75 -- kernel/bpf/verifier.c | 4 +- kernel/trace/bpf_trace.c | 2 + scripts/bpf_helpers_doc.py | 2 + tools/include/uapi/linux/bpf.h | 36 +++- 7 files changed, 150 insertions(+), 6 deletions(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 3d2ade703a357..0cd7f6884c5cd 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -1627,6 +1627,7 @@ extern const struct bpf_func_proto bpf_get_current_uid_gid_proto; extern const struct bpf_func_proto bpf_get_current_comm_proto; extern const struct bpf_func_proto bpf_get_stackid_proto; extern const struct bpf_func_proto bpf_get_stack_proto; +extern const struct bpf_func_proto bpf_get_task_stack_proto; extern const struct bpf_func_proto bpf_sock_map_update_proto; extern const struct bpf_func_proto bpf_sock_hash_update_proto; extern const struct bpf_func_proto bpf_get_current_cgroup_id_proto; diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 0cb8ec9488168..54106ea667211 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -3285,6 +3285,39 @@ union bpf_attr { * Dynamically cast a *sk* pointer to a *udp6_sock* pointer. * Return * *sk* if casting is valid, or NULL otherwise. + * + * long bpf_get_task_stack(struct task_struct *task, void *buf, u32 size, u64 flags) + * Description + * Return a user or a kernel stack in bpf program provided buffer. + * To achieve this, the helper needs *task*, which is a valid + * pointer to struct task_struct. To store the stacktrace, the + * bpf program provides *buf* with a nonnegative *size*. + * + * The last argument, *flags*, holds the number of stack frames to + * skip (from 0 to 255), masked with + * **BPF_F_SKIP_FIELD_MASK**. The next bits can be used to set + * the following flags: + * + * **BPF_F_USER_STACK** + * Collect a user space stack instead of a kernel stack. + * **BPF_F_USER_BUILD_ID** + * Collect buildid+offset instead of ips for user stack, + * only valid if **BPF_F_USER_STACK** is also specified. + * + * **bpf_get_task_stack**\ () can collect up to + * **PERF_MAX_STACK_DEPTH** both kernel and user frames, subject + * to sufficient large buffer size. Note that + * this limit can be controlled with the **sysctl** program, and + * that it should be manually increased in order to profile long + * user stacks (such as stacks for Java programs). To do so, use: + * + * :: + * + * # sysctl kernel.perf_event_max_stack= + * Return + * A non-negative value equal to or less than *size* on success, + * or a negative error in case of failure. + * */ #define __BPF_FUNC_MAPPER(FN) \ FN(unspec), \ @@ -3427,7 +3460,8 @@ union bpf_attr { FN(skc_to_tcp_sock),\ FN(skc_to_tcp_timewait_sock), \ FN(skc_to_tcp_request_sock),\ - FN(skc_to_udp6_sock), + FN(skc_to_udp6_sock), \ + FN(get_task_stack), /* integer value in 'imm' field of BPF_CALL instruction selects which helper * function eBPF program intends to call diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c index 27dc9b1b08a52..0ba66b29ef227 100644 --- a/kernel/bpf/stackmap.c +++ b/kernel/bpf/stackmap.c @@ -348,6 +348,40 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs, } } +static struct perf_callchain_entry * +get_callchain_entry_for_task(struct task_struct *task, u32 init_nr) +{ + struct perf_callchain_entry *entry; + int rctx; + + entry = get_callchain_entry(); + + if (!entry) + return NULL; + + entry->nr = init_nr + + stack_trace_save_tsk(task, (unsigned long *)(entry->ip + init_nr), +sysctl_perf_event_max_stack - init_nr, 0); + +
[PATCH v3 bpf-next 3/4] bpf: allow %pB in bpf_seq_printf() and bpf_trace_printk()
This makes it easy to dump stack trace in text. Acked-by: Yonghong Song Signed-off-by: Song Liu --- kernel/trace/bpf_trace.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 977ba3b6f6c64..1d874d8e4384b 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -376,7 +376,7 @@ static void bpf_trace_copy_string(char *buf, void *unsafe_ptr, char fmt_ptype, /* * Only limited trace_printk() conversion specifiers allowed: - * %d %i %u %x %ld %li %lu %lx %lld %lli %llu %llx %p %pks %pus %s + * %d %i %u %x %ld %li %lu %lx %lld %lli %llu %llx %p %pB %pks %pus %s */ BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1, u64, arg2, u64, arg3) @@ -420,6 +420,11 @@ BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1, goto fmt_str; } + if (fmt[i + 1] == 'B') { + i++; + goto fmt_next; + } + /* disallow any further format extensions */ if (fmt[i + 1] != 0 && !isspace(fmt[i + 1]) && @@ -636,7 +641,8 @@ BPF_CALL_5(bpf_seq_printf, struct seq_file *, m, char *, fmt, u32, fmt_size, if (fmt[i] == 'p') { if (fmt[i + 1] == 0 || fmt[i + 1] == 'K' || - fmt[i + 1] == 'x') { + fmt[i + 1] == 'x' || + fmt[i + 1] == 'B') { /* just kernel pointers */ params[fmt_cnt] = args[fmt_cnt]; fmt_cnt++; -- 2.24.1
[PATCH v3 bpf-next 1/4] perf: expose get/put_callchain_entry()
Sanitize and expose get/put_callchain_entry(). This would be used by bpf stack map. Suggested-by: Peter Zijlstra Signed-off-by: Song Liu --- include/linux/perf_event.h | 2 ++ kernel/events/callchain.c | 13 ++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index b4bb32082342c..00ab5efa38334 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -1244,6 +1244,8 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user, extern struct perf_callchain_entry *perf_callchain(struct perf_event *event, struct pt_regs *regs); extern int get_callchain_buffers(int max_stack); extern void put_callchain_buffers(void); +extern struct perf_callchain_entry *get_callchain_entry(int *rctx); +extern void put_callchain_entry(int rctx); extern int sysctl_perf_event_max_stack; extern int sysctl_perf_event_max_contexts_per_stack; diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c index 334d48b16c36d..c6ce894e4ce94 100644 --- a/kernel/events/callchain.c +++ b/kernel/events/callchain.c @@ -149,7 +149,7 @@ void put_callchain_buffers(void) } } -static struct perf_callchain_entry *get_callchain_entry(int *rctx) +struct perf_callchain_entry *get_callchain_entry(int *rctx) { int cpu; struct callchain_cpus_entries *entries; @@ -159,8 +159,10 @@ static struct perf_callchain_entry *get_callchain_entry(int *rctx) return NULL; entries = rcu_dereference(callchain_cpus_entries); - if (!entries) + if (!entries) { + put_recursion_context(this_cpu_ptr(callchain_recursion), *rctx); return NULL; + } cpu = smp_processor_id(); @@ -168,7 +170,7 @@ static struct perf_callchain_entry *get_callchain_entry(int *rctx) (*rctx * perf_callchain_entry__sizeof())); } -static void +void put_callchain_entry(int rctx) { put_recursion_context(this_cpu_ptr(callchain_recursion), rctx); @@ -183,11 +185,8 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user, int rctx; entry = get_callchain_entry(); - if (rctx == -1) - return NULL; - if (!entry) - goto exit_put; + return NULL; ctx.entry = entry; ctx.max_stack = max_stack; -- 2.24.1
[PATCH v3 bpf-next 4/4] selftests/bpf: add bpf_iter test with bpf_get_task_stack()
The new test is similar to other bpf_iter tests. Signed-off-by: Song Liu --- .../selftests/bpf/prog_tests/bpf_iter.c | 17 ++ .../selftests/bpf/progs/bpf_iter_task_stack.c | 53 +++ 2 files changed, 70 insertions(+) create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c index 1e2e0fced6e81..fed42755416db 100644 --- a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c +++ b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c @@ -5,6 +5,7 @@ #include "bpf_iter_netlink.skel.h" #include "bpf_iter_bpf_map.skel.h" #include "bpf_iter_task.skel.h" +#include "bpf_iter_task_stack.skel.h" #include "bpf_iter_task_file.skel.h" #include "bpf_iter_tcp4.skel.h" #include "bpf_iter_tcp6.skel.h" @@ -110,6 +111,20 @@ static void test_task(void) bpf_iter_task__destroy(skel); } +static void test_task_stack(void) +{ + struct bpf_iter_task_stack *skel; + + skel = bpf_iter_task_stack__open_and_load(); + if (CHECK(!skel, "bpf_iter_task_stack__open_and_load", + "skeleton open_and_load failed\n")) + return; + + do_dummy_read(skel->progs.dump_task_stack); + + bpf_iter_task_stack__destroy(skel); +} + static void test_task_file(void) { struct bpf_iter_task_file *skel; @@ -452,6 +467,8 @@ void test_bpf_iter(void) test_bpf_map(); if (test__start_subtest("task")) test_task(); + if (test__start_subtest("task_stack")) + test_task_stack(); if (test__start_subtest("task_file")) test_task_file(); if (test__start_subtest("tcp4")) diff --git a/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c b/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c new file mode 100644 index 0..39b21df17c3ee --- /dev/null +++ b/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2020 Facebook */ +/* "undefine" structs in vmlinux.h, because we "override" them below */ +#define bpf_iter_meta bpf_iter_meta___not_used +#define bpf_iter__task bpf_iter__task___not_used +#include "vmlinux.h" +#undef bpf_iter_meta +#undef bpf_iter__task +#include +#include + +char _license[] SEC("license") = "GPL"; + +struct bpf_iter_meta { + struct seq_file *seq; + __u64 session_id; + __u64 seq_num; +} __attribute__((preserve_access_index)); + +struct bpf_iter__task { + struct bpf_iter_meta *meta; + struct task_struct *task; +} __attribute__((preserve_access_index)); + +#define MAX_STACK_TRACE_DEPTH 64 +unsigned long entries[MAX_STACK_TRACE_DEPTH]; +#define SIZE_OF_ULONG (sizeof(unsigned long)) + +SEC("iter/task") +int dump_task_stack(struct bpf_iter__task *ctx) +{ + struct seq_file *seq = ctx->meta->seq; + struct task_struct *task = ctx->task; + long i, retlen; + + if (task == (void *)0) + return 0; + + retlen = bpf_get_task_stack(task, entries, + MAX_STACK_TRACE_DEPTH * SIZE_OF_ULONG, 0); + if (retlen < 0) + return 0; + + BPF_SEQ_PRINTF(seq, "pid: %8u num_entries: %8u\n", task->pid, + retlen / SIZE_OF_ULONG); + for (i = 0; i < MAX_STACK_TRACE_DEPTH; i++) { + if (retlen > i * SIZE_OF_ULONG) + BPF_SEQ_PRINTF(seq, "[<0>] %pB\n", (void *)entries[i]); + } + BPF_SEQ_PRINTF(seq, "\n"); + + return 0; +} -- 2.24.1
[PATCH v3 bpf-next 1/4] perf: expose get/put_chain_entry()
Sanitize and expose get/put_chain_entry(). This would be used by bpf stack map. Suggested-by: Peter Zijlstra Signed-off-by: Song Liu --- include/linux/perf_event.h | 2 ++ kernel/events/callchain.c | 13 ++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index b4bb32082342c..00ab5efa38334 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -1244,6 +1244,8 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user, extern struct perf_callchain_entry *perf_callchain(struct perf_event *event, struct pt_regs *regs); extern int get_callchain_buffers(int max_stack); extern void put_callchain_buffers(void); +extern struct perf_callchain_entry *get_callchain_entry(int *rctx); +extern void put_callchain_entry(int rctx); extern int sysctl_perf_event_max_stack; extern int sysctl_perf_event_max_contexts_per_stack; diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c index 334d48b16c36d..c6ce894e4ce94 100644 --- a/kernel/events/callchain.c +++ b/kernel/events/callchain.c @@ -149,7 +149,7 @@ void put_callchain_buffers(void) } } -static struct perf_callchain_entry *get_callchain_entry(int *rctx) +struct perf_callchain_entry *get_callchain_entry(int *rctx) { int cpu; struct callchain_cpus_entries *entries; @@ -159,8 +159,10 @@ static struct perf_callchain_entry *get_callchain_entry(int *rctx) return NULL; entries = rcu_dereference(callchain_cpus_entries); - if (!entries) + if (!entries) { + put_recursion_context(this_cpu_ptr(callchain_recursion), *rctx); return NULL; + } cpu = smp_processor_id(); @@ -168,7 +170,7 @@ static struct perf_callchain_entry *get_callchain_entry(int *rctx) (*rctx * perf_callchain_entry__sizeof())); } -static void +void put_callchain_entry(int rctx) { put_recursion_context(this_cpu_ptr(callchain_recursion), rctx); @@ -183,11 +185,8 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user, int rctx; entry = get_callchain_entry(); - if (rctx == -1) - return NULL; - if (!entry) - goto exit_put; + return NULL; ctx.entry = entry; ctx.max_stack = max_stack; -- 2.24.1
[PATCH v3 bpf-next 0/4] bpf: introduce bpf_get_task_stack()
This set introduces a new helper bpf_get_task_stack(). The primary use case is to dump all /proc/*/stack to seq_file via bpf_iter__task. A few different approaches have been explored and compared: 1. A simple wrapper around stack_trace_save_tsk(), as v1 [1]. This approach introduces new syntax, which is different to existing helper bpf_get_stack(). Therefore, this is not ideal. 2. Extend get_perf_callchain() to support "task" as argument. This approach reuses most of bpf_get_stack(). However, extending get_perf_callchain() requires non-trivial changes to architecture specific code. Which is error prone. 3. Current (v2) approach, leverages most of existing bpf_get_stack(), and uses stack_trace_save_tsk() to handle architecture specific logic. [1] https://lore.kernel.org/netdev/20200623070802.2310018-1-songliubrav...@fb.com/ Changes v2 => v3: 1. Rebase on top of bpf-next. (Yonghong) 2. Sanitize get_callchain_entry(). (Peter) 3. Use has_callchain_buf for bpf_get_task_stack. (Andrii) 4. Other small clean up. (Yonghong, Andrii). Changes v1 => v2: 1. Reuse most of bpf_get_stack() logic. (Andrii) 2. Fix unsigned long vs. u64 mismatch for 32-bit systems. (Yonghong) 3. Add %pB support in bpf_trace_printk(). (Daniel) 4. Fix buffer size to bytes. Song Liu (4): perf: expose get/put_callchain_entry() bpf: introduce helper bpf_get_task_stack() bpf: allow %pB in bpf_seq_printf() and bpf_trace_printk() selftests/bpf: add bpf_iter test with bpf_get_task_stack() include/linux/bpf.h | 1 + include/linux/perf_event.h| 2 + include/uapi/linux/bpf.h | 36 - kernel/bpf/stackmap.c | 75 ++- kernel/bpf/verifier.c | 4 +- kernel/events/callchain.c | 13 ++-- kernel/trace/bpf_trace.c | 12 ++- scripts/bpf_helpers_doc.py| 2 + tools/include/uapi/linux/bpf.h| 36 - .../selftests/bpf/prog_tests/bpf_iter.c | 17 + .../selftests/bpf/progs/bpf_iter_task_stack.c | 53 + 11 files changed, 236 insertions(+), 15 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c -- 2.24.1
Re: [RFC PATCH 01/10] DT bindings in plain text format
On Mon, Jun 22, 2020 at 11:32:43AM +0100, Lee Jones wrote: > On Sun, 21 Jun 2020, Jonathan Neuschäfer wrote: > > > For reference, here are the devicetree bindings in plaintext format. > > (Not for merge.) > > This would be better placed inside the relevant patch(es), rather than > in a separate non-mergeable extra/superfluous patch. Ok, I'll put it in the patch descriptions (as long as the plaintext DT bindings are relevant for review). Thanks, Jonathan Neuschäfer > > .../bindings/mfd/netronix,ntxec.txt | 58 +++ > > .../bindings/pwm/netronix,ntxec-pwm.txt | 27 + > > .../bindings/rtc/netronix,ntxec-rtc.txt | 17 ++ signature.asc Description: PGP signature
Re: [PATCH 2/2] staging: qlge: fix else after return or break
On Sat, 2020-06-27 at 07:57 +0800, Coiby Xu wrote: > On Thu, Jun 25, 2020 at 03:13:14PM -0700, Joe Perches wrote: > > On Fri, 2020-06-26 at 05:57 +0800, Coiby Xu wrote: > > > Remove unnecessary elses after return or break. > > > > unrelated trivia: [] > > looks like all of these could use netdev_err [] > should we also replace all pr_errs with netdev_err in > ql_dump_* functions? Ideally, anywhere a struct netdevice * is available, it should be used to output netdev_ in preference to pr_.
Re: [PATCH v2 bpf-next 2/4] bpf: introduce helper bpf_get_task_stak()
On Fri, Jun 26, 2020 at 4:47 PM Song Liu wrote: > > > > > On Jun 26, 2020, at 3:51 PM, Andrii Nakryiko > > wrote: > > > > On Fri, Jun 26, 2020 at 3:45 PM Song Liu wrote: > >> > >> > >> > >>> On Jun 26, 2020, at 1:17 PM, Andrii Nakryiko > >>> wrote: > >>> > >>> On Thu, Jun 25, 2020 at 5:14 PM Song Liu wrote: > > Introduce helper bpf_get_task_stack(), which dumps stack trace of given > task. This is different to bpf_get_stack(), which gets stack track of > current task. One potential use case of bpf_get_task_stack() is to call > it from bpf_iter__task and dump all /proc//stack to a seq_file. > > bpf_get_task_stack() uses stack_trace_save_tsk() instead of > get_perf_callchain() for kernel stack. The benefit of this choice is that > stack_trace_save_tsk() doesn't require changes in arch/. The downside of > using stack_trace_save_tsk() is that stack_trace_save_tsk() dumps the > stack trace to unsigned long array. For 32-bit systems, we need to > translate it to u64 array. > > Signed-off-by: Song Liu > --- > >>> > >>> Looks great, I just think that there are cases where user doesn't > >>> necessarily has valid task_struct pointer, just pid, so would be nice > >>> to not artificially restrict such cases by having extra helper. > >>> > >>> Acked-by: Andrii Nakryiko > >> > >> Thanks! > >> > >>> > include/linux/bpf.h| 1 + > include/uapi/linux/bpf.h | 35 ++- > kernel/bpf/stackmap.c | 79 -- > kernel/trace/bpf_trace.c | 2 + > scripts/bpf_helpers_doc.py | 2 + > tools/include/uapi/linux/bpf.h | 35 ++- > 6 files changed, 149 insertions(+), 5 deletions(-) > > >>> > >>> [...] > >>> > + /* stack_trace_save_tsk() works on unsigned long array, while > +* perf_callchain_entry uses u64 array. For 32-bit systems, it is > +* necessary to fix this mismatch. > +*/ > + if (__BITS_PER_LONG != 64) { > + unsigned long *from = (unsigned long *) entry->ip; > + u64 *to = entry->ip; > + int i; > + > + /* copy data from the end to avoid using extra buffer */ > + for (i = entry->nr - 1; i >= (int)init_nr; i--) > + to[i] = (u64)(from[i]); > >>> > >>> doing this forward would be just fine as well, no? First iteration > >>> will cast and overwrite low 32-bits, all the subsequent iterations > >>> won't even overlap. > >> > >> I think first iteration will write zeros to higher 32 bits, no? > > > > Oh, wait, I completely misread what this is doing. It up-converts from > > 32-bit to 64-bit, sorry. Yeah, ignore me on this :) > > > > But then I have another question. How do you know that entry->ip has > > enough space to keep the same number of 2x bigger entries? > > The buffer is sized for sysctl_perf_event_max_stack u64 numbers. > stack_trace_save_tsk() will put at most stack_trace_save_tsk unsigned > long in it (init_nr == 0). So the buffer is big enough. > Awesome, thanks for clarification! > Thanks, > Song
Re: [PATCH 2/2] staging: qlge: fix else after return or break
On Thu, Jun 25, 2020 at 03:13:14PM -0700, Joe Perches wrote: On Fri, 2020-06-26 at 05:57 +0800, Coiby Xu wrote: Remove unnecessary elses after return or break. unrelated trivia: diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c [] @@ -1391,12 +1391,11 @@ static void ql_dump_cam_entries(struct ql_adapter *qdev) pr_err("%s: Failed read of mac index register\n", __func__); return; - } else { - if (value[0]) - pr_err("%s: CAM index %d CAM Lookup Lower = 0x%.08x:%.08x, Output = 0x%.08x\n", - qdev->ndev->name, i, value[1], value[0], - value[2]); looks like all of these could use netdev_err netdev_err(qdev, "etc...", i, value[1], value[0], value[2]); etc... Should we also replace all pr_errs with netdev_err in ql_dump_* functions? I'm not sure how we will use ql_dump_*. For example, ql_dump_regs is not referred by any kernel source, so I guess it's for the sole purpose of debugging the driver by the developer. But one pr_err in ql_dump_routing_entries which is called by dl_dump_regs doesn't prints out the device name whereas the other does, void ql_dump_routing_entries(struct ql_adapter *qdev) { int i; u32 value; i = ql_sem_spinlock(qdev, SEM_RT_IDX_MASK); if (i) return; for (i = 0; i < 16; i++) { value = 0; if (ql_get_routing_reg(qdev, i, )) { pr_err("%s: Failed read of routing index register\n", __func__); break; } if (value) pr_err("%s: Routing Mask %d = 0x%.08x\n", qdev->ndev->name, i, value); } -- Best regards, Coiby
Re: [PATCH v2 bpf-next 2/4] bpf: introduce helper bpf_get_task_stak()
> On Jun 26, 2020, at 3:51 PM, Andrii Nakryiko > wrote: > > On Fri, Jun 26, 2020 at 3:45 PM Song Liu wrote: >> >> >> >>> On Jun 26, 2020, at 1:17 PM, Andrii Nakryiko >>> wrote: >>> >>> On Thu, Jun 25, 2020 at 5:14 PM Song Liu wrote: Introduce helper bpf_get_task_stack(), which dumps stack trace of given task. This is different to bpf_get_stack(), which gets stack track of current task. One potential use case of bpf_get_task_stack() is to call it from bpf_iter__task and dump all /proc//stack to a seq_file. bpf_get_task_stack() uses stack_trace_save_tsk() instead of get_perf_callchain() for kernel stack. The benefit of this choice is that stack_trace_save_tsk() doesn't require changes in arch/. The downside of using stack_trace_save_tsk() is that stack_trace_save_tsk() dumps the stack trace to unsigned long array. For 32-bit systems, we need to translate it to u64 array. Signed-off-by: Song Liu --- >>> >>> Looks great, I just think that there are cases where user doesn't >>> necessarily has valid task_struct pointer, just pid, so would be nice >>> to not artificially restrict such cases by having extra helper. >>> >>> Acked-by: Andrii Nakryiko >> >> Thanks! >> >>> include/linux/bpf.h| 1 + include/uapi/linux/bpf.h | 35 ++- kernel/bpf/stackmap.c | 79 -- kernel/trace/bpf_trace.c | 2 + scripts/bpf_helpers_doc.py | 2 + tools/include/uapi/linux/bpf.h | 35 ++- 6 files changed, 149 insertions(+), 5 deletions(-) >>> >>> [...] >>> + /* stack_trace_save_tsk() works on unsigned long array, while +* perf_callchain_entry uses u64 array. For 32-bit systems, it is +* necessary to fix this mismatch. +*/ + if (__BITS_PER_LONG != 64) { + unsigned long *from = (unsigned long *) entry->ip; + u64 *to = entry->ip; + int i; + + /* copy data from the end to avoid using extra buffer */ + for (i = entry->nr - 1; i >= (int)init_nr; i--) + to[i] = (u64)(from[i]); >>> >>> doing this forward would be just fine as well, no? First iteration >>> will cast and overwrite low 32-bits, all the subsequent iterations >>> won't even overlap. >> >> I think first iteration will write zeros to higher 32 bits, no? > > Oh, wait, I completely misread what this is doing. It up-converts from > 32-bit to 64-bit, sorry. Yeah, ignore me on this :) > > But then I have another question. How do you know that entry->ip has > enough space to keep the same number of 2x bigger entries? The buffer is sized for sysctl_perf_event_max_stack u64 numbers. stack_trace_save_tsk() will put at most stack_trace_save_tsk unsigned long in it (init_nr == 0). So the buffer is big enough. Thanks, Song
Re: [PATCH v2 bpf-next 4/4] selftests/bpf: add bpf_iter test with bpf_get_task_stack()
> On Jun 26, 2020, at 4:11 PM, Andrii Nakryiko > wrote: > > On Fri, Jun 26, 2020 at 4:05 PM Song Liu wrote: >> >> >> >>> On Jun 26, 2020, at 1:21 PM, Andrii Nakryiko >>> wrote: >>> >>> On Thu, Jun 25, 2020 at 5:15 PM Song Liu wrote: The new test is similar to other bpf_iter tests. Signed-off-by: Song Liu --- .../selftests/bpf/prog_tests/bpf_iter.c | 17 ++ .../selftests/bpf/progs/bpf_iter_task_stack.c | 60 +++ 2 files changed, 77 insertions(+) create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c index 87c29dde1cf96..baa83328f810d 100644 --- a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c +++ b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c @@ -5,6 +5,7 @@ #include "bpf_iter_netlink.skel.h" #include "bpf_iter_bpf_map.skel.h" #include "bpf_iter_task.skel.h" +#include "bpf_iter_task_stack.skel.h" #include "bpf_iter_task_file.skel.h" #include "bpf_iter_test_kern1.skel.h" #include "bpf_iter_test_kern2.skel.h" @@ -106,6 +107,20 @@ static void test_task(void) bpf_iter_task__destroy(skel); } +static void test_task_stack(void) +{ + struct bpf_iter_task_stack *skel; + + skel = bpf_iter_task_stack__open_and_load(); + if (CHECK(!skel, "bpf_iter_task_stack__open_and_load", + "skeleton open_and_load failed\n")) + return; + + do_dummy_read(skel->progs.dump_task_stack); + + bpf_iter_task_stack__destroy(skel); +} + static void test_task_file(void) { struct bpf_iter_task_file *skel; @@ -392,6 +407,8 @@ void test_bpf_iter(void) test_bpf_map(); if (test__start_subtest("task")) test_task(); + if (test__start_subtest("task_stack")) + test_task_stack(); if (test__start_subtest("task_file")) test_task_file(); if (test__start_subtest("anon")) diff --git a/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c b/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c new file mode 100644 index 0..83aca5b1a7965 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2020 Facebook */ +/* "undefine" structs in vmlinux.h, because we "override" them below */ +#define bpf_iter_meta bpf_iter_meta___not_used +#define bpf_iter__task bpf_iter__task___not_used +#include "vmlinux.h" +#undef bpf_iter_meta +#undef bpf_iter__task +#include +#include + +char _license[] SEC("license") = "GPL"; + +/* bpf_get_task_stack needs a stackmap to work */ >>> >>> no it doesn't anymore :) please drop >> >> We still need stack_map_alloc() to call get_callchain_buffers() in this >> case. Without an active stack map, get_callchain_buffers() may fail. > > Oh... um... is it possible to do it some other way? It's extremely > confusing dependency. Does bpf_get_stack() also require stackmap? > Aha, I thought bpf_get_stack() also requires stackmap, but it doesn't. The fix is in check_helper_call(). Let me do the same for bpf_get_task_stack(). Thanks, Song
[PATCH] io_uring: fix function args for !CONFIG_NET
From: Randy Dunlap Fix build errors when CONFIG_NET is not set/enabled: ../fs/io_uring.c:5472:10: error: too many arguments to function ‘io_sendmsg’ ../fs/io_uring.c:5474:10: error: too many arguments to function ‘io_send’ ../fs/io_uring.c:5484:10: error: too many arguments to function ‘io_recvmsg’ ../fs/io_uring.c:5486:10: error: too many arguments to function ‘io_recv’ ../fs/io_uring.c:5510:9: error: too many arguments to function ‘io_accept’ ../fs/io_uring.c:5518:9: error: too many arguments to function ‘io_connect’ Signed-off-by: Randy Dunlap Cc: Jens Axboe Cc: io-ur...@vger.kernel.org --- fs/io_uring.c | 18 -- 1 file changed, 12 insertions(+), 6 deletions(-) --- mmotm-2020-0625-2036.orig/fs/io_uring.c +++ mmotm-2020-0625-2036/fs/io_uring.c @@ -4315,12 +4315,14 @@ static int io_sendmsg_prep(struct io_kio return -EOPNOTSUPP; } -static int io_sendmsg(struct io_kiocb *req, bool force_nonblock) +static int io_sendmsg(struct io_kiocb *req, bool force_nonblock, + struct io_comp_state *cs) { return -EOPNOTSUPP; } -static int io_send(struct io_kiocb *req, bool force_nonblock) +static int io_send(struct io_kiocb *req, bool force_nonblock, + struct io_comp_state *cs) { return -EOPNOTSUPP; } @@ -4331,12 +4333,14 @@ static int io_recvmsg_prep(struct io_kio return -EOPNOTSUPP; } -static int io_recvmsg(struct io_kiocb *req, bool force_nonblock) +static int io_recvmsg(struct io_kiocb *req, bool force_nonblock, + struct io_comp_state *cs) { return -EOPNOTSUPP; } -static int io_recv(struct io_kiocb *req, bool force_nonblock) +static int io_recv(struct io_kiocb *req, bool force_nonblock, + struct io_comp_state *cs) { return -EOPNOTSUPP; } @@ -4346,7 +4350,8 @@ static int io_accept_prep(struct io_kioc return -EOPNOTSUPP; } -static int io_accept(struct io_kiocb *req, bool force_nonblock) +static int io_accept(struct io_kiocb *req, bool force_nonblock, +struct io_comp_state *cs) { return -EOPNOTSUPP; } @@ -4356,7 +4361,8 @@ static int io_connect_prep(struct io_kio return -EOPNOTSUPP; } -static int io_connect(struct io_kiocb *req, bool force_nonblock) +static int io_connect(struct io_kiocb *req, bool force_nonblock, + struct io_comp_state *cs) { return -EOPNOTSUPP; }
Re: [PATCH 0/2] sparc32: srmmu: improve type safety of __nocache_fix()
From: Mike Rapoport Date: Fri, 26 Jun 2020 21:17:13 +0300 > Any comments on this? Sorry I didn't see this in my patchwork queue, could you please just resubmit it to sparcli...@vger.kernel.org Thank you.
Re: record_printk_text tricks: was: [PATCH v3 3/3] printk: use the lockless ringbuffer
On 2020-06-25, Petr Mladek wrote: >> --- a/kernel/printk/printk.c >> +++ b/kernel/printk/printk.c >> @@ -1344,72 +1304,150 @@ static size_t print_prefix(const struct printk_log >> *msg, bool syslog, >> return len; >> } >> >> -static size_t msg_print_text(const struct printk_log *msg, bool syslog, >> - bool time, char *buf, size_t size) >> +static size_t record_print_text(struct printk_record *r, bool syslog, >> +bool time) >> { >> -const char *text = log_text(msg); >> -size_t text_size = msg->text_len; >> -size_t len = 0; >> +size_t text_len = r->info->text_len; >> +size_t buf_size = r->text_buf_size; >> +char *text = r->text_buf; >> char prefix[PREFIX_MAX]; >> -const size_t prefix_len = print_prefix(msg, syslog, time, prefix); >> +bool truncated = false; >> +size_t prefix_len; >> +size_t line_len; >> +size_t len = 0; >> +char *next; >> >> -do { >> -const char *next = memchr(text, '\n', text_size); >> -size_t text_len; >> +prefix_len = info_print_prefix(r->info, syslog, time, prefix); >> >> +/* >> + * Add the prefix for each line by shifting the rest of the text to >> + * make room for each prefix. If the buffer is not large enough for >> + * all the prefixes, then drop the trailing text and report the >> + * largest length that includes full lines with their prefixes. > > This should go up as the function description. > > Sigh, this function does (already did) many subltle decisions. We > should mention them in the description. My current understanding is > the following: > > /* > * Prepare the record for printing. The text is shifted in the given > * buffer to avoid a need for another one. The following operations > * are done: > * > * - Add prefix for each line. > * - Add the trailing newline that has been removed in vprintk_store(). > * - Drop truncated lines that do not longer fit into the buffer. > * > * Return: The length of the updated text, including the added > * prefixes, newline. The dropped line(s) are not counted. > */ OK. >> + * >> + * @text_len: bytes of unprocessed text >> + * @line_len: bytes of current line (newline _not_ included) >> + * @text: pointer to beginning of current line >> + * @len: number of bytes processed (size of r->text_buf done) > > Please, move this to the variable declaration. I find it more helpful to see these critical definitions directly above the loop. When I add them to the variable declarations, I find it really ugly and hard to reference. Maybe you could show me an example of what you want it to look like? >> + */ >> +for (;;) { >> +next = memchr(text, '\n', text_len); >> if (next) { >> -text_len = next - text; >> -next++; >> -text_size -= next - text; >> +line_len = next - text; >> } else { >> -text_len = text_size; >> +/* >> + * No newline. If the text was previously truncated, >> + * assume this line was truncated and do not include >> + * it. >> + */ > > The word "assume" is confusing. The last line _must_ have been truncated when > "truncated" is set. I would write: > > /* Drop incomplete truncated lines. */ OK. >> +if (truncated) >> +break; >> +line_len = text_len; >> } >> >> -if (buf) { >> -if (prefix_len + text_len + 1 >= size - len) >> +/* >> + * Ensure there is enough buffer available to shift this line >> + * (and add a newline at the end). >> + */ >> +if (len + prefix_len + line_len + 1 > buf_size) >> +break; >> + >> +/* >> + * Ensure there is enough buffer available to shift all >> + * remaining text (and add a newline at the end). If this >> + * test fails, then there must be a newline (i.e. >> + * text_len > line_len because the previous test succeeded). >> + */ >> +if (len + prefix_len + text_len + 1 > buf_size) { >> +/* >> + * Truncate @text_len so that there is enough space >> + * for a prefix. A newline will not be added because >> + * the last line of the text is now truncated and >> + * will not be included. >> + */ >> +text_len = (buf_size - len) - prefix_len; > > This is confusing. The check requires that one more character gets truncated. > And it should be perfectly fine to truncate '\n' from the previous > line. The final '\n' is always
Re: [PATCH v4 2/2] sched/uclamp: Protect uclamp fast path code with static key
On 26/06/20 13:38, Patrick Bellasi wrote: > On Thu, Jun 25, 2020 at 17:43:52 +0200, Qais Yousef > wrote... >> @@ -994,9 +1013,16 @@ static inline void uclamp_rq_dec_id(struct rq *rq, >> struct task_struct *p, >> lockdep_assert_held(>lock); >> >> bucket = _rq->bucket[uc_se->bucket_id]; >> -SCHED_WARN_ON(!bucket->tasks); >> -if (likely(bucket->tasks)) >> -bucket->tasks--; >> + >> +/* >> + * This could happen if sched_uclamp_used was enabled while the >> + * current task was running, hence we could end up with unbalanced call >> + * to uclamp_rq_dec_id(). >> + */ >> +if (unlikely(!bucket->tasks)) >> +return; >> + >> +bucket->tasks--; >> uc_se->active = false; > > In this chunk you are indeed changing the code. > > Are we sure there are not issues with patterns like: > > enqueue(taskA) > // uclamp gets enabled > enqueue(taskB) > dequeue(taskA) > // bucket->tasks is now 0 > dequeue(taskB) > > TaskB has been enqueued with with uclamp enabled, thus it > has got uc_se->active=True and enforced its clamp value at RQ level. > > But with your change above we don't reset that anymore. > Harumph indeed... > As per my previous proposal: why not just removing the SCHED_WARN_ON? > That's the only real problem in the code above, since now we are not > more granted to have balanced inc/dec. > The SCHED_WARN_ON is gone, were you thinking of something else?
Re: [PATCH v4 1/2] sched/uclamp: Fix initialization of struct uclamp_rq
On 26/06/20 13:32, Patrick Bellasi wrote: > On Thu, Jun 25, 2020 at 17:43:51 +0200, Qais Yousef > wrote... > >> struct uclamp_rq was zeroed out entirely in assumption that in the first >> call to uclamp_rq_inc() they'd be initialized correctly in accordance to >> default settings. > > Perhaps I was not clear in my previous comment: > >https://lore.kernel.org/lkml/87sgekorfq.derkl...@matbug.net/ > > when I did say: > >Does not this means the problem is more likely with >uclamp_rq_util_with(), which should be guarded? > > I did not mean that we have to guard the calls to that function but > instead that we should just make that function aware of uclamp being > opted in or not. > >> But when next patch introduces a static key to skip >> uclamp_rq_{inc,dec}() until userspace opts in to use uclamp, schedutil >> will fail to perform any frequency changes because the >> rq->uclamp[UCLAMP_MAX].value is zeroed at init and stays as such. Which >> means all rqs are capped to 0 by default. > > The initialization you wants to do here it's needed because with the > current approach you keep calling the same uclamp_rq_util_with() and > keep doing min/max aggregations even when uclamp is not opted in. > But this means also that we have min/max aggregation _when not really > required_. > >> Fix it by making sure we do proper initialization at init without >> relying on uclamp_rq_inc() doing it later. > > My proposal was as simple as: > > ---8<--- > static __always_inline > unsigned long uclamp_rq_util_with(struct rq *rq, unsigned long util, > struct task_struct *p) > { > unsigned long min_util = READ_ONCE(rq->uclamp[UCLAMP_MIN].value); > unsigned long max_util = READ_ONCE(rq->uclamp[UCLAMP_MAX].value); > > + if (!static_branch_unlikely(_uclamp_used)) > + return rt_task(p) ? uclamp_none(UCLAMP_MAX) : util > > if (p) { > min_util = max(min_util, uclamp_eff_value(p, UCLAMP_MIN)); > max_util = max(max_util, uclamp_eff_value(p, UCLAMP_MAX)); > } > > /* >* Since CPU's {min,max}_util clamps are MAX aggregated considering >* RUNNABLE tasks with _different_ clamps, we can end up with an >* inversion. Fix it now when the clamps are applied. >*/ > if (unlikely(min_util >= max_util)) > return min_util; > > return clamp(util, min_util, max_util); > } > ---8<--- > > Such small change is more self-contained IMHO and does not remove > an existing optimizations like this lazy RQ's initialization at first > usage. > > Moreover, it can folded in the following patch, with all the other > static keys shortcuts. I'd have to think some more over it, but I like this in that we wouldn't have to molest schedutil anymore.
Re: [PATCH v2 15/17] arm64: Remove custom IRQ stat accounting
On 26/06/20 12:58, Marc Zyngier wrote: > On 2020-06-25 19:26, Valentin Schneider wrote: >> On 24/06/20 20:58, Marc Zyngier wrote: >>> @@ -801,26 +802,15 @@ void show_ipi_list(struct seq_file *p, int prec) >>> unsigned int cpu, i; >>> >>> for (i = 0; i < NR_IPI; i++) { >>> + unsigned int irq = irq_desc_get_irq(ipi_desc[i]); >>> seq_printf(p, "%*s%u:%s", prec - 1, "IPI", i, >>> prec >= 4 ? " " : ""); >>> for_each_online_cpu(cpu) >>> - seq_printf(p, "%10u ", >>> - __get_irq_stat(cpu, ipi_irqs[i])); >>> + seq_printf(p, "%10u ", kstat_irqs_cpu(irq, cpu)); >>> seq_printf(p, " %s\n", ipi_types[i]); >> >> How attached are we to that custom IPI printout? AIUI we *could* give >> them >> a "prettier" name in request_percpu_irq() and let the standard procfs >> printout take the wheel. > > I wish. Unfortunately, /proc/interrupts is likely to be considered ABI, > and I'm really worried to change this (see what happened last time we > tried to update /proc/cpuinfo to be less braindead...). > Hmph, it's borderline here I think: we're not introducing a new field or format in the file, so any tool that can parse /proc/interrupts can parse the IPIs if they are formatted like the other "regular" interrupts. But then said tool could die in flames when not seeing the special IPI fields because sturdiness is overrated :( Oh well. > M.
[tip:x86/entry] BUILD SUCCESS 2c92d787cc9fad57d05c96bd117782183768258a
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/entry branch HEAD: 2c92d787cc9fad57d05c96bd117782183768258a Merge branch 'linus' into x86/entry, to resolve conflicts elapsed time: 722m configs tested: 97 configs skipped: 4 The following configs have been built successfully. More configs may be tested in the coming days. arm defconfig arm allyesconfig arm allmodconfig arm allnoconfig arm64allyesconfig arm64allmodconfig arm64 allnoconfig arm64 defconfig sh se7751_defconfig arm imx_v6_v7_defconfig armxcep_defconfig arm pxa255-idp_defconfig arm tango4_defconfig h8300allyesconfig arc defconfig armlart_defconfig m68k atari_defconfig armmini2440_defconfig arm pxa168_defconfig arm pxa_defconfig arm lpc18xx_defconfig mips ip27_defconfig arm eseries_pxa_defconfig mips loongson3_defconfig i386 alldefconfig nds32 allnoconfig sh se7724_defconfig mips loongson1b_defconfig pariscallnoconfig i386 allnoconfig i386 allyesconfig i386defconfig i386 debian-10.3 ia64 allmodconfig ia64defconfig ia64 allnoconfig ia64 allyesconfig m68k allmodconfig m68k allnoconfig m68k sun3_defconfig m68kdefconfig m68k allyesconfig nios2 defconfig nios2allyesconfig openriscdefconfig c6x allyesconfig c6x allnoconfig openrisc allyesconfig nds32 defconfig csky allyesconfig cskydefconfig alpha defconfig alphaallyesconfig xtensa allyesconfig h8300allmodconfig xtensa defconfig arc allyesconfig sh allmodconfig shallnoconfig microblazeallnoconfig mips allyesconfig mips allnoconfig mips allmodconfig parisc defconfig parisc allyesconfig parisc allmodconfig powerpc defconfig powerpc allyesconfig powerpc rhel-kconfig powerpc allmodconfig powerpc allnoconfig riscvallyesconfig riscv allnoconfig riscv defconfig riscvallmodconfig s390 allyesconfig s390 allnoconfig s390 allmodconfig s390defconfig sparcallyesconfig sparc defconfig sparc64 defconfig sparc64 allnoconfig sparc64 allyesconfig sparc64 allmodconfig um allmodconfig umallnoconfig um allyesconfig um defconfig x86_64 rhel-7.6 x86_64rhel-7.6-kselftests x86_64 rhel-8.3 x86_64 kexec x86_64 rhel x86_64 rhel-7.2-clear x86_64lkp x86_64 fedora-25 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org
[tip:master] BUILD SUCCESS 64c3af02c52e2f67b237d1848b0c27008b4f9158
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git master branch HEAD: 64c3af02c52e2f67b237d1848b0c27008b4f9158 Merge branch 'WIP.fixes' elapsed time: 722m configs tested: 97 configs skipped: 4 The following configs have been built successfully. More configs may be tested in the coming days. arm defconfig arm allyesconfig arm allmodconfig arm allnoconfig arm64allyesconfig arm64allmodconfig arm64 allnoconfig arm64 defconfig sh se7751_defconfig arm imx_v6_v7_defconfig armxcep_defconfig arm pxa255-idp_defconfig arm tango4_defconfig h8300allyesconfig arc defconfig armlart_defconfig m68k atari_defconfig armmini2440_defconfig arm pxa168_defconfig arm pxa_defconfig arm lpc18xx_defconfig mips ip27_defconfig arm eseries_pxa_defconfig mips loongson3_defconfig i386 alldefconfig nds32 allnoconfig sh se7724_defconfig mips loongson1b_defconfig pariscallnoconfig i386 allnoconfig i386 allyesconfig i386defconfig i386 debian-10.3 ia64 allmodconfig ia64defconfig ia64 allnoconfig ia64 allyesconfig m68k allmodconfig m68k allnoconfig m68k sun3_defconfig m68kdefconfig m68k allyesconfig nios2 defconfig nios2allyesconfig openriscdefconfig c6x allyesconfig c6x allnoconfig openrisc allyesconfig nds32 defconfig csky allyesconfig cskydefconfig alpha defconfig alphaallyesconfig xtensa allyesconfig h8300allmodconfig xtensa defconfig arc allyesconfig sh allmodconfig shallnoconfig microblazeallnoconfig mips allyesconfig mips allnoconfig mips allmodconfig parisc defconfig parisc allyesconfig parisc allmodconfig powerpc defconfig powerpc allyesconfig powerpc allmodconfig powerpc allnoconfig powerpc rhel-kconfig riscvallyesconfig riscv allnoconfig riscv defconfig riscvallmodconfig s390 allyesconfig s390 allnoconfig s390 allmodconfig s390defconfig sparcallyesconfig sparc defconfig sparc64 defconfig sparc64 allnoconfig sparc64 allyesconfig sparc64 allmodconfig um allmodconfig umallnoconfig um allyesconfig um defconfig x86_64 rhel-7.6 x86_64rhel-7.6-kselftests x86_64 rhel-8.3 x86_64 kexec x86_64 rhel x86_64 rhel-7.2-clear x86_64lkp x86_64 fedora-25 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org
Re: [PATCH v2 bpf-next 4/4] selftests/bpf: add bpf_iter test with bpf_get_task_stack()
On Fri, Jun 26, 2020 at 4:05 PM Song Liu wrote: > > > > > On Jun 26, 2020, at 1:21 PM, Andrii Nakryiko > > wrote: > > > > On Thu, Jun 25, 2020 at 5:15 PM Song Liu wrote: > >> > >> The new test is similar to other bpf_iter tests. > >> > >> Signed-off-by: Song Liu > >> --- > >> .../selftests/bpf/prog_tests/bpf_iter.c | 17 ++ > >> .../selftests/bpf/progs/bpf_iter_task_stack.c | 60 +++ > >> 2 files changed, 77 insertions(+) > >> create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c > >> > >> diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c > >> b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c > >> index 87c29dde1cf96..baa83328f810d 100644 > >> --- a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c > >> +++ b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c > >> @@ -5,6 +5,7 @@ > >> #include "bpf_iter_netlink.skel.h" > >> #include "bpf_iter_bpf_map.skel.h" > >> #include "bpf_iter_task.skel.h" > >> +#include "bpf_iter_task_stack.skel.h" > >> #include "bpf_iter_task_file.skel.h" > >> #include "bpf_iter_test_kern1.skel.h" > >> #include "bpf_iter_test_kern2.skel.h" > >> @@ -106,6 +107,20 @@ static void test_task(void) > >>bpf_iter_task__destroy(skel); > >> } > >> > >> +static void test_task_stack(void) > >> +{ > >> + struct bpf_iter_task_stack *skel; > >> + > >> + skel = bpf_iter_task_stack__open_and_load(); > >> + if (CHECK(!skel, "bpf_iter_task_stack__open_and_load", > >> + "skeleton open_and_load failed\n")) > >> + return; > >> + > >> + do_dummy_read(skel->progs.dump_task_stack); > >> + > >> + bpf_iter_task_stack__destroy(skel); > >> +} > >> + > >> static void test_task_file(void) > >> { > >>struct bpf_iter_task_file *skel; > >> @@ -392,6 +407,8 @@ void test_bpf_iter(void) > >>test_bpf_map(); > >>if (test__start_subtest("task")) > >>test_task(); > >> + if (test__start_subtest("task_stack")) > >> + test_task_stack(); > >>if (test__start_subtest("task_file")) > >>test_task_file(); > >>if (test__start_subtest("anon")) > >> diff --git a/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c > >> b/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c > >> new file mode 100644 > >> index 0..83aca5b1a7965 > >> --- /dev/null > >> +++ b/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c > >> @@ -0,0 +1,60 @@ > >> +// SPDX-License-Identifier: GPL-2.0 > >> +/* Copyright (c) 2020 Facebook */ > >> +/* "undefine" structs in vmlinux.h, because we "override" them below */ > >> +#define bpf_iter_meta bpf_iter_meta___not_used > >> +#define bpf_iter__task bpf_iter__task___not_used > >> +#include "vmlinux.h" > >> +#undef bpf_iter_meta > >> +#undef bpf_iter__task > >> +#include > >> +#include > >> + > >> +char _license[] SEC("license") = "GPL"; > >> + > >> +/* bpf_get_task_stack needs a stackmap to work */ > > > > no it doesn't anymore :) please drop > > We still need stack_map_alloc() to call get_callchain_buffers() in this > case. Without an active stack map, get_callchain_buffers() may fail. Oh... um... is it possible to do it some other way? It's extremely confusing dependency. Does bpf_get_stack() also require stackmap? > > Thanks, > Song
linux-next: Signed-off-by missing for commit in the block tree
Hi all, Commit d3cac64c498c ("io_uring: fix NULL-mm for linked reqs") is missing a Signed-off-by from its committer. -- Cheers, Stephen Rothwell pgpUjej8XyqjY.pgp Description: OpenPGP digital signature
Re: [PATCH 0/6] Overhaul memalloc_no*
On Fri, Jun 26, 2020 at 11:02:19AM -0400, Mikulas Patocka wrote: > Hi > > I suggest to join memalloc_noio and memalloc_nofs into just one flag that > prevents both filesystem recursion and i/o recursion. > > Note that any I/O can recurse into a filesystem via the loop device, thus > it doesn't make much sense to have a context where PF_MEMALLOC_NOFS is set > and PF_MEMALLOC_NOIO is not set. Correct me if I'm wrong, but I think that will prevent swapping from GFP_NOFS memory reclaim contexts. IOWs, this will substantially change the behaviour of the memory reclaim system under sustained GFP_NOFS memory pressure. Sustained GFP_NOFS memory pressure is quite common, so I really don't think we want to telling memory reclaim "you can't do IO at all" when all we are trying to do is prevent recursion back into the same filesystem. Given that the loop device IO path already operates under memalloc_noio context, (i.e. the recursion restriction is applied in only the context that needs is) I see no reason for making that a global reclaim limitation In reality, we need to be moving the other way with GFP_NOFS - to fine grained anti-recursion contexts, not more broad contexts. That is, GFP_NOFS prevents recursion into any filesystem, not just the one that we are actively operating on and needing to prevent recursion back into. We can safely have reclaim do relcaim work on other filesysetms without fear of recursion deadlocks, but the memory reclaim infrastructure does not provide that capability.(*) e.g. if memalloc_nofs_save() took a reclaim context structure that the filesystem put the superblock, the superblock's nesting depth (because layering on loop devices can create cross-filesystem recursion dependencies), and any other filesyetm private data the fs wanted to add, we could actually have reclaim only avoid reclaim from filesytsems where there is a deadlock possiblity. e.g: - superblock nesting depth is different, apply GFP_NOFS reclaim unconditionally - superblock different apply GFP_KERNEL reclaim - superblock the same, pass context to filesystem to decide if reclaim from the sueprblock is safe. At this point, we get memory reclaim able to always be able to reclaim from filesystems that are not at risk of recursion deadlocks. Direct reclaim is much more likely to be able to make progress now because it is much less restricted in what it can reclaim. That's going to make direct relcaim faster and more efficient, and taht's the ultimate goal we are aiming to acheive here... Cheers, Dave. -- Dave Chinner da...@fromorbit.com
linux-next: Fixes tag needs some work in the block tree
Hi all, In commit cd664b0e35cb ("io_uring: fix hanging iopoll in case of -EAGAIN") Fixes tag Fixes: bbde017a32b3 ("io_uring: add memory barrier to synchronize has these problem(s): - Subject has leading but no trailing parentheses - Subject has leading but no trailing quotes Please do not split Fixes tags over more than one line. -- Cheers, Stephen Rothwell pgpA2IUxBdAJ6.pgp Description: OpenPGP digital signature
Re: [PATCH v2 bpf-next 4/4] selftests/bpf: add bpf_iter test with bpf_get_task_stack()
> On Jun 26, 2020, at 1:21 PM, Andrii Nakryiko > wrote: > > On Thu, Jun 25, 2020 at 5:15 PM Song Liu wrote: >> >> The new test is similar to other bpf_iter tests. >> >> Signed-off-by: Song Liu >> --- >> .../selftests/bpf/prog_tests/bpf_iter.c | 17 ++ >> .../selftests/bpf/progs/bpf_iter_task_stack.c | 60 +++ >> 2 files changed, 77 insertions(+) >> create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c >> >> diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c >> b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c >> index 87c29dde1cf96..baa83328f810d 100644 >> --- a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c >> +++ b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c >> @@ -5,6 +5,7 @@ >> #include "bpf_iter_netlink.skel.h" >> #include "bpf_iter_bpf_map.skel.h" >> #include "bpf_iter_task.skel.h" >> +#include "bpf_iter_task_stack.skel.h" >> #include "bpf_iter_task_file.skel.h" >> #include "bpf_iter_test_kern1.skel.h" >> #include "bpf_iter_test_kern2.skel.h" >> @@ -106,6 +107,20 @@ static void test_task(void) >>bpf_iter_task__destroy(skel); >> } >> >> +static void test_task_stack(void) >> +{ >> + struct bpf_iter_task_stack *skel; >> + >> + skel = bpf_iter_task_stack__open_and_load(); >> + if (CHECK(!skel, "bpf_iter_task_stack__open_and_load", >> + "skeleton open_and_load failed\n")) >> + return; >> + >> + do_dummy_read(skel->progs.dump_task_stack); >> + >> + bpf_iter_task_stack__destroy(skel); >> +} >> + >> static void test_task_file(void) >> { >>struct bpf_iter_task_file *skel; >> @@ -392,6 +407,8 @@ void test_bpf_iter(void) >>test_bpf_map(); >>if (test__start_subtest("task")) >>test_task(); >> + if (test__start_subtest("task_stack")) >> + test_task_stack(); >>if (test__start_subtest("task_file")) >>test_task_file(); >>if (test__start_subtest("anon")) >> diff --git a/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c >> b/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c >> new file mode 100644 >> index 0..83aca5b1a7965 >> --- /dev/null >> +++ b/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c >> @@ -0,0 +1,60 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* Copyright (c) 2020 Facebook */ >> +/* "undefine" structs in vmlinux.h, because we "override" them below */ >> +#define bpf_iter_meta bpf_iter_meta___not_used >> +#define bpf_iter__task bpf_iter__task___not_used >> +#include "vmlinux.h" >> +#undef bpf_iter_meta >> +#undef bpf_iter__task >> +#include >> +#include >> + >> +char _license[] SEC("license") = "GPL"; >> + >> +/* bpf_get_task_stack needs a stackmap to work */ > > no it doesn't anymore :) please drop We still need stack_map_alloc() to call get_callchain_buffers() in this case. Without an active stack map, get_callchain_buffers() may fail. Thanks, Song
linux-next: Fixes tag needs some work in the nfsd tree
Hi all, In commit 886c4fe8bdff ("nfsd4: fix nfsdfs reference count loop") Fixes tag Fixes: 2c830dd720 ("nfsd: persist nfsd filesystem across mounts") has these problem(s): - SHA1 should be at least 12 digits long Can be fixed by setting core.abbrev to 12 (or more) or (for git v2.11 or later) just making sure it is not set (or set to "auto"). -- Cheers, Stephen Rothwell pgpp1O_U4tj2A.pgp Description: OpenPGP digital signature
linux-next: Fixes tag needs some work in the nfs-anna tree
Hi all, In commit b7ade38165ca ("sunrpc: fixed rollback in rpc_gssd_dummy_populate()") Fixes tag Fixes: commit 4b9a445e3eeb ("sunrpc: create a new dummy pipe for gssd to hold open") has these problem(s): - leading word 'commit' unexpected -- Cheers, Stephen Rothwell pgpSAmSaxFhuL.pgp Description: OpenPGP digital signature