linux-next: manual merge of the akpm-current tree with Linus' tree
Hi Andrew, Today's linux-next merge of the akpm-current tree got a conflict in: mm/page_alloc.c between commit: 3e04040df6d4 ("Revert "mm/page_alloc: fix memmap_init_zone pageblock alignment"") from Linus' tree and commit: 45251b0909dc ("mm: remove unused arg from memblock_next_valid_pfn()") from the akpm-current tree. I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts. -- Cheers, Stephen Rothwell diff --cc mm/page_alloc.c index b32488f10a46,3f9cb47974ed.. --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@@ -5361,9 -5487,14 +5489,9 @@@ void __meminit memmap_init_zone(unsigne /* * Skip to the pfn preceding the next valid one (or * end_pfn), such that we hit a valid pfn (or end_pfn) - * on our next iteration of the loop. Note that it needs - * to be pageblock aligned even when the region itself - * is not. move_freepages_block() can shift ahead of - * the valid region but still depends on correct page - * metadata. + * on our next iteration of the loop. */ - pfn = memblock_next_valid_pfn(pfn, end_pfn) - 1; - pfn = (memblock_next_valid_pfn(pfn) & - ~(pageblock_nr_pages-1)) - 1; ++ pfn = memblock_next_valid_pfn(pfn) - 1; #endif continue; } pgpgmsmmRQ0kf.pgp Description: OpenPGP digital signature
linux-next: manual merge of the akpm-current tree with Linus' tree
Hi Andrew, Today's linux-next merge of the akpm-current tree got a conflict in: mm/page_alloc.c between commit: 3e04040df6d4 ("Revert "mm/page_alloc: fix memmap_init_zone pageblock alignment"") from Linus' tree and commit: 45251b0909dc ("mm: remove unused arg from memblock_next_valid_pfn()") from the akpm-current tree. I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts. -- Cheers, Stephen Rothwell diff --cc mm/page_alloc.c index b32488f10a46,3f9cb47974ed.. --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@@ -5361,9 -5487,14 +5489,9 @@@ void __meminit memmap_init_zone(unsigne /* * Skip to the pfn preceding the next valid one (or * end_pfn), such that we hit a valid pfn (or end_pfn) - * on our next iteration of the loop. Note that it needs - * to be pageblock aligned even when the region itself - * is not. move_freepages_block() can shift ahead of - * the valid region but still depends on correct page - * metadata. + * on our next iteration of the loop. */ - pfn = memblock_next_valid_pfn(pfn, end_pfn) - 1; - pfn = (memblock_next_valid_pfn(pfn) & - ~(pageblock_nr_pages-1)) - 1; ++ pfn = memblock_next_valid_pfn(pfn) - 1; #endif continue; } pgpgmsmmRQ0kf.pgp Description: OpenPGP digital signature
Re: [PATCH v1 1/2] arm: npcm: modify configuration for the NPCM7xx BMC.
On Thu, Mar 15, 2018 at 4:16 PM Tomer Maimonwrote: > Modify configuration and MakeFile > for the Nuvoton NPCM and NPCM7xx BMC. > Signed-off-by: Tomer Maimon > --- > arch/arm/mach-npcm/Kconfig | 40 +++- > arch/arm/mach-npcm/Makefile | 4 +++- > 2 files changed, 14 insertions(+), 30 deletions(-) Reviewed-by: Brendan Higgins
Re: [PATCH v1 1/2] arm: npcm: modify configuration for the NPCM7xx BMC.
On Thu, Mar 15, 2018 at 4:16 PM Tomer Maimon wrote: > Modify configuration and MakeFile > for the Nuvoton NPCM and NPCM7xx BMC. > Signed-off-by: Tomer Maimon > --- > arch/arm/mach-npcm/Kconfig | 40 +++- > arch/arm/mach-npcm/Makefile | 4 +++- > 2 files changed, 14 insertions(+), 30 deletions(-) Reviewed-by: Brendan Higgins
Re: [PATCH v3] vsprintf: Prevent crash when dereferencing invalid pointers
On (03/15/18 18:35), Linus Torvalds wrote: > On Thu, Mar 15, 2018 at 6:18 PM, Sergey Senozhatsky >wrote: > > > > Hm, may be sizeof(ptr) still won't suffice. It would be great if we > > could always look at spec.field_width, which can be up to 2 * sizeof(void > > *), > > and then just probe_kernel_read(spec.field_width). E.g., %b/%bl prints out a > > bitmap, accessing max_t(int, spec.field_width, 0) bits, which is good. But, > > for instance, %U (uuid printout) doesn't look at spec.field_width, and reads > > in 16 bytes from the given memory address. Then we have ipv4/ipv6, mac, etc. > > So I think that checking just 1 byte or sizeof(ptr) is not really enough if > > we want to fix vsprintf. What do you think? > > Honestly, I think it would be better to move the whole logic to the > functions that actually do the printout. > > Then you can do it right, and you don't need to have the strchr() either. > > There really isn't any commonality between the different versions. > field_width is meaningless, since it's about the size of the _printed_ > field, not the size in memory. Agreed! > Would it be a few more lines? Yes. But it would also clarify the code > and get all the cases right. Look at hex_string() for example, and > imagine fetching a byte at a time and just getting the corner cases > automatically right. So, basically, what I tried to say - any byte past the first sizeof(ptr) bytes or past the first byte that we check_access() can cause problems, which this patch is trying to address. As an example, FORMAT_TYPE_STR case printk("%.*s\n", p->buf) vsnprintf() string() Where ->buf is a _nearly always_ properly nul terminated char buf[128] array in struct foo. So moving that check_access() to every function that does printout sounds good to me, as well as checking every byte we access [assuming that we want to cure vsprintf], not just the first one or the first sizeof(ptr) bytes. -ss
Re: [PATCH v3] vsprintf: Prevent crash when dereferencing invalid pointers
On (03/15/18 18:35), Linus Torvalds wrote: > On Thu, Mar 15, 2018 at 6:18 PM, Sergey Senozhatsky > wrote: > > > > Hm, may be sizeof(ptr) still won't suffice. It would be great if we > > could always look at spec.field_width, which can be up to 2 * sizeof(void > > *), > > and then just probe_kernel_read(spec.field_width). E.g., %b/%bl prints out a > > bitmap, accessing max_t(int, spec.field_width, 0) bits, which is good. But, > > for instance, %U (uuid printout) doesn't look at spec.field_width, and reads > > in 16 bytes from the given memory address. Then we have ipv4/ipv6, mac, etc. > > So I think that checking just 1 byte or sizeof(ptr) is not really enough if > > we want to fix vsprintf. What do you think? > > Honestly, I think it would be better to move the whole logic to the > functions that actually do the printout. > > Then you can do it right, and you don't need to have the strchr() either. > > There really isn't any commonality between the different versions. > field_width is meaningless, since it's about the size of the _printed_ > field, not the size in memory. Agreed! > Would it be a few more lines? Yes. But it would also clarify the code > and get all the cases right. Look at hex_string() for example, and > imagine fetching a byte at a time and just getting the corner cases > automatically right. So, basically, what I tried to say - any byte past the first sizeof(ptr) bytes or past the first byte that we check_access() can cause problems, which this patch is trying to address. As an example, FORMAT_TYPE_STR case printk("%.*s\n", p->buf) vsnprintf() string() Where ->buf is a _nearly always_ properly nul terminated char buf[128] array in struct foo. So moving that check_access() to every function that does printout sounds good to me, as well as checking every byte we access [assuming that we want to cure vsprintf], not just the first one or the first sizeof(ptr) bytes. -ss
Re: [PATCH v1 2/2] arm: npcm: Enable L2 Cache in NPCM7xx
On Thu, Mar 15, 2018 at 4:16 PM Tomer Maimonwrote: > Enable L2 Cache in Nuvoton NPCM7xx BMC. > Signed-off-by: Tomer Maimon > --- > arch/arm/mach-npcm/npcm7xx.c | 2 ++ > 1 file changed, 2 insertions(+) > diff --git a/arch/arm/mach-npcm/npcm7xx.c b/arch/arm/mach-npcm/npcm7xx.c > index 5f7cd88103ef..c5f77d854c4f 100644 > --- a/arch/arm/mach-npcm/npcm7xx.c > +++ b/arch/arm/mach-npcm/npcm7xx.c > @@ -17,4 +17,6 @@ static const char *const npcm7xx_dt_match[] = { > DT_MACHINE_START(NPCM7XX_DT, "NPCM7XX Chip family") > .atag_offset= 0x100, > .dt_compat = npcm7xx_dt_match, > + .l2c_aux_val= 0x0, > + .l2c_aux_mask = ~0x0, You need to limit this to the specific bit(s) you want to set and verify that the l2c driver does not already manage that bit appropriately and that it can not be specified via the dtsi. We discussed this a little while ago with Rob here: https://www.spinics.net/lists/arm-kernel/msg613372.html > MACHINE_END > -- > 2.14.1 Cheers
Re: [PATCH v1 2/2] arm: npcm: Enable L2 Cache in NPCM7xx
On Thu, Mar 15, 2018 at 4:16 PM Tomer Maimon wrote: > Enable L2 Cache in Nuvoton NPCM7xx BMC. > Signed-off-by: Tomer Maimon > --- > arch/arm/mach-npcm/npcm7xx.c | 2 ++ > 1 file changed, 2 insertions(+) > diff --git a/arch/arm/mach-npcm/npcm7xx.c b/arch/arm/mach-npcm/npcm7xx.c > index 5f7cd88103ef..c5f77d854c4f 100644 > --- a/arch/arm/mach-npcm/npcm7xx.c > +++ b/arch/arm/mach-npcm/npcm7xx.c > @@ -17,4 +17,6 @@ static const char *const npcm7xx_dt_match[] = { > DT_MACHINE_START(NPCM7XX_DT, "NPCM7XX Chip family") > .atag_offset= 0x100, > .dt_compat = npcm7xx_dt_match, > + .l2c_aux_val= 0x0, > + .l2c_aux_mask = ~0x0, You need to limit this to the specific bit(s) you want to set and verify that the l2c driver does not already manage that bit appropriately and that it can not be specified via the dtsi. We discussed this a little while ago with Rob here: https://www.spinics.net/lists/arm-kernel/msg613372.html > MACHINE_END > -- > 2.14.1 Cheers
Re: linux-next: build warning after merge of the tip tree
Hi Stephen, At 03/16/2018 01:37 PM, Stephen Rothwell wrote: Hi all, After merging the tip tree, yesterday's linux-next build (x86_64 allnoconfig) produced this warning: kernel/cpu.c:129:13: warning: 'cpuhp_is_ap_state' defined but not used [-Wunused-function] static bool cpuhp_is_ap_state(enum cpuhp_state state) ^ Yes, Jiangshan has replaced it with cpuhp_hp_states. So it is obsolete, it should be removed. Thanks, dou. Introduced by commit 17a2f1ced028 ("cpu/hotplug: Merge cpuhp_bp_states and cpuhp_ap_states")
Re: linux-next: build warning after merge of the tip tree
Hi Stephen, At 03/16/2018 01:37 PM, Stephen Rothwell wrote: Hi all, After merging the tip tree, yesterday's linux-next build (x86_64 allnoconfig) produced this warning: kernel/cpu.c:129:13: warning: 'cpuhp_is_ap_state' defined but not used [-Wunused-function] static bool cpuhp_is_ap_state(enum cpuhp_state state) ^ Yes, Jiangshan has replaced it with cpuhp_hp_states. So it is obsolete, it should be removed. Thanks, dou. Introduced by commit 17a2f1ced028 ("cpu/hotplug: Merge cpuhp_bp_states and cpuhp_ap_states")
Re: [PATCH 4/7] soc: qcom: rpmpd: Add support for get/set performance state
On 03/16/2018 10:05 AM, Viresh Kumar wrote: > On 16-03-18, 09:38, Rajendra Nayak wrote: >> With genpd now expecting powerdomain drivers supporting performance >> state to support get/set performance state callbacks, add support for it >> in the rpmpd driver. >> >> Signed-off-by: Rajendra Nayak>> Signed-off-by: Viresh Kumar >> --- >> drivers/soc/qcom/rpmpd.c | 42 ++ >> 1 file changed, 42 insertions(+) >> >> diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c >> index c8754d867c33..4058c5b450c6 100644 >> --- a/drivers/soc/qcom/rpmpd.c >> +++ b/drivers/soc/qcom/rpmpd.c >> @@ -14,6 +14,7 @@ >> #include >> #include >> #include >> +#include >> #include >> >> #include >> @@ -29,6 +30,8 @@ >> #define KEY_ENABLE 0x6e657773 /* swen */ >> #define KEY_FLOOR_CORNER0x636676 /* vfc */ >> >> +#define MAX_RPMPD_STATE 6 >> + >> #define DEFINE_RPMPD_CORN_SMPA(_platform, _name, _active, r_id) >> \ >> static struct rpmpd _platform##_##_active; \ >> static struct rpmpd _platform##_##_name = { \ >> @@ -222,6 +225,43 @@ static int rpmpd_power_off(struct generic_pm_domain >> *domain) >> return ret; >> } >> >> +static int rpmpd_set_performance(struct generic_pm_domain *domain, >> + unsigned int state) >> +{ >> +int ret = 0; >> +struct rpmpd *pd = domain_to_rpmpd(domain); >> + >> +mutex_lock(_lock); >> + >> +if (state > MAX_RPMPD_STATE) >> +goto out; >> + >> +pd->corner = state; >> + >> +if (!pd->enabled && (pd->key != KEY_FLOOR_CORNER)) >> +goto out; >> + >> +ret = rpmpd_aggregate_corner(pd); >> + >> +out: >> +mutex_unlock(_lock); >> + >> +return ret; >> +} >> + >> +static unsigned int rpmpd_get_performance(struct generic_pm_domain *genpd, >> + struct dev_pm_opp *opp) >> +{ >> +struct device_node *np; >> +unsigned int corner = 0; >> + >> +np = dev_pm_opp_get_of_node(opp); >> +of_property_read_u32(np, "qcom,level", ); > > Don't we want to error out or do something else in case of an error ? yes, I missed the error checks, will add. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCH 4/7] soc: qcom: rpmpd: Add support for get/set performance state
On 03/16/2018 10:05 AM, Viresh Kumar wrote: > On 16-03-18, 09:38, Rajendra Nayak wrote: >> With genpd now expecting powerdomain drivers supporting performance >> state to support get/set performance state callbacks, add support for it >> in the rpmpd driver. >> >> Signed-off-by: Rajendra Nayak >> Signed-off-by: Viresh Kumar >> --- >> drivers/soc/qcom/rpmpd.c | 42 ++ >> 1 file changed, 42 insertions(+) >> >> diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c >> index c8754d867c33..4058c5b450c6 100644 >> --- a/drivers/soc/qcom/rpmpd.c >> +++ b/drivers/soc/qcom/rpmpd.c >> @@ -14,6 +14,7 @@ >> #include >> #include >> #include >> +#include >> #include >> >> #include >> @@ -29,6 +30,8 @@ >> #define KEY_ENABLE 0x6e657773 /* swen */ >> #define KEY_FLOOR_CORNER0x636676 /* vfc */ >> >> +#define MAX_RPMPD_STATE 6 >> + >> #define DEFINE_RPMPD_CORN_SMPA(_platform, _name, _active, r_id) >> \ >> static struct rpmpd _platform##_##_active; \ >> static struct rpmpd _platform##_##_name = { \ >> @@ -222,6 +225,43 @@ static int rpmpd_power_off(struct generic_pm_domain >> *domain) >> return ret; >> } >> >> +static int rpmpd_set_performance(struct generic_pm_domain *domain, >> + unsigned int state) >> +{ >> +int ret = 0; >> +struct rpmpd *pd = domain_to_rpmpd(domain); >> + >> +mutex_lock(_lock); >> + >> +if (state > MAX_RPMPD_STATE) >> +goto out; >> + >> +pd->corner = state; >> + >> +if (!pd->enabled && (pd->key != KEY_FLOOR_CORNER)) >> +goto out; >> + >> +ret = rpmpd_aggregate_corner(pd); >> + >> +out: >> +mutex_unlock(_lock); >> + >> +return ret; >> +} >> + >> +static unsigned int rpmpd_get_performance(struct generic_pm_domain *genpd, >> + struct dev_pm_opp *opp) >> +{ >> +struct device_node *np; >> +unsigned int corner = 0; >> + >> +np = dev_pm_opp_get_of_node(opp); >> +of_property_read_u32(np, "qcom,level", ); > > Don't we want to error out or do something else in case of an error ? yes, I missed the error checks, will add. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
linux-next: build warning after merge of the tip tree
Hi all, After merging the tip tree, yesterday's linux-next build (x86_64 allnoconfig) produced this warning: kernel/cpu.c:129:13: warning: 'cpuhp_is_ap_state' defined but not used [-Wunused-function] static bool cpuhp_is_ap_state(enum cpuhp_state state) ^ Introduced by commit 17a2f1ced028 ("cpu/hotplug: Merge cpuhp_bp_states and cpuhp_ap_states") -- Cheers, Stephen Rothwell pgpECM6Qteoxu.pgp Description: OpenPGP digital signature
linux-next: build warning after merge of the tip tree
Hi all, After merging the tip tree, yesterday's linux-next build (x86_64 allnoconfig) produced this warning: kernel/cpu.c:129:13: warning: 'cpuhp_is_ap_state' defined but not used [-Wunused-function] static bool cpuhp_is_ap_state(enum cpuhp_state state) ^ Introduced by commit 17a2f1ced028 ("cpu/hotplug: Merge cpuhp_bp_states and cpuhp_ap_states") -- Cheers, Stephen Rothwell pgpECM6Qteoxu.pgp Description: OpenPGP digital signature
Re: [PATCH V7 00/13] drivers: Boot Constraint core
On 23-02-18, 15:53, Viresh Kumar wrote: > Hi Greg, > > The V7 version incorporates the organizational changes suggested by Olof > earlier. Everything else is same otherwise. > > I have tested the Hisilicon patches (again) on hikey 9660 board, IMX stuff was > earlier tested by Sascha (Pengutronix) on i.MX6 and Qualcomm stuff was earlier > tested by Rajendra (Qualcomm) on Dragonboard 410C (This required some more > patches related to display driver which Rajendra should be sending separately > later on). Hi Greg, Are you going to pick this one for 4.17 ? Thanks. -- viresh
Re: [PATCH V7 00/13] drivers: Boot Constraint core
On 23-02-18, 15:53, Viresh Kumar wrote: > Hi Greg, > > The V7 version incorporates the organizational changes suggested by Olof > earlier. Everything else is same otherwise. > > I have tested the Hisilicon patches (again) on hikey 9660 board, IMX stuff was > earlier tested by Sascha (Pengutronix) on i.MX6 and Qualcomm stuff was earlier > tested by Rajendra (Qualcomm) on Dragonboard 410C (This required some more > patches related to display driver which Rajendra should be sending separately > later on). Hi Greg, Are you going to pick this one for 4.17 ? Thanks. -- viresh
Re: [PATCH v2] watchdog: aspeed: Allow configuring for alternate boot
On 03/15/2018 09:02 AM, Eddie James wrote: From: Milton MillerAllow the device tree to specify a watchdog to fallover to the alternate boot source. The aspeeed watchdog can set a latch directing flash chip select 0 to chip select 1, allowing boot from an alternate media if the watchdog is not reset in time. On the ast2400 bank 1 also goes to flash bank 1, while on the ast2500 the chip selects are swapped. Also clear the secondary boot bit during the machine restart operation. Otherwise, the system will switch to the alternate boot after every reboot, which is not desired. Signed-off-by: Milton Miller Signed-off-by: Eddie James Reviewed-by: Guenter Roeck --- Changes since v1: * Disable secondary boot before the restart operation. drivers/watchdog/aspeed_wdt.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c index d1987d6..a5b8eb2 100644 --- a/drivers/watchdog/aspeed_wdt.c +++ b/drivers/watchdog/aspeed_wdt.c @@ -46,6 +46,7 @@ struct aspeed_wdt_config { #define WDT_RELOAD_VALUE 0x04 #define WDT_RESTART 0x08 #define WDT_CTRL 0x0C +#define WDT_CTRL_BOOT_SECONDARY BIT(7) #define WDT_CTRL_RESET_MODE_SOC (0x00 << 5) #define WDT_CTRL_RESET_MODE_FULL_CHIP (0x01 << 5) #define WDT_CTRL_RESET_MODE_ARM_CPU (0x10 << 5) @@ -158,6 +159,7 @@ static int aspeed_wdt_restart(struct watchdog_device *wdd, { struct aspeed_wdt *wdt = to_aspeed_wdt(wdd); + wdt->ctrl &= ~WDT_CTRL_BOOT_SECONDARY; aspeed_wdt_enable(wdt, 128 * WDT_RATE_1MHZ / 1000); mdelay(1000); @@ -245,6 +247,8 @@ static int aspeed_wdt_probe(struct platform_device *pdev) } if (of_property_read_bool(np, "aspeed,external-signal")) wdt->ctrl |= WDT_CTRL_WDT_EXT; + if (of_property_read_bool(np, "aspeed,alt-boot")) + wdt->ctrl |= WDT_CTRL_BOOT_SECONDARY; if (readl(wdt->base + WDT_CTRL) & WDT_CTRL_ENABLE) { /*
Re: [PATCH v2] watchdog: aspeed: Allow configuring for alternate boot
On 03/15/2018 09:02 AM, Eddie James wrote: From: Milton Miller Allow the device tree to specify a watchdog to fallover to the alternate boot source. The aspeeed watchdog can set a latch directing flash chip select 0 to chip select 1, allowing boot from an alternate media if the watchdog is not reset in time. On the ast2400 bank 1 also goes to flash bank 1, while on the ast2500 the chip selects are swapped. Also clear the secondary boot bit during the machine restart operation. Otherwise, the system will switch to the alternate boot after every reboot, which is not desired. Signed-off-by: Milton Miller Signed-off-by: Eddie James Reviewed-by: Guenter Roeck --- Changes since v1: * Disable secondary boot before the restart operation. drivers/watchdog/aspeed_wdt.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c index d1987d6..a5b8eb2 100644 --- a/drivers/watchdog/aspeed_wdt.c +++ b/drivers/watchdog/aspeed_wdt.c @@ -46,6 +46,7 @@ struct aspeed_wdt_config { #define WDT_RELOAD_VALUE 0x04 #define WDT_RESTART 0x08 #define WDT_CTRL 0x0C +#define WDT_CTRL_BOOT_SECONDARY BIT(7) #define WDT_CTRL_RESET_MODE_SOC (0x00 << 5) #define WDT_CTRL_RESET_MODE_FULL_CHIP (0x01 << 5) #define WDT_CTRL_RESET_MODE_ARM_CPU (0x10 << 5) @@ -158,6 +159,7 @@ static int aspeed_wdt_restart(struct watchdog_device *wdd, { struct aspeed_wdt *wdt = to_aspeed_wdt(wdd); + wdt->ctrl &= ~WDT_CTRL_BOOT_SECONDARY; aspeed_wdt_enable(wdt, 128 * WDT_RATE_1MHZ / 1000); mdelay(1000); @@ -245,6 +247,8 @@ static int aspeed_wdt_probe(struct platform_device *pdev) } if (of_property_read_bool(np, "aspeed,external-signal")) wdt->ctrl |= WDT_CTRL_WDT_EXT; + if (of_property_read_bool(np, "aspeed,alt-boot")) + wdt->ctrl |= WDT_CTRL_BOOT_SECONDARY; if (readl(wdt->base + WDT_CTRL) & WDT_CTRL_ENABLE) { /*
Great News!
We have a great about your E-mail address!!! You Won $950,500.00 USD on Amnesty International UK online E-mail Promotion. For more details about your prize claims, file with the following; Names: Country: Tel: Regards, Mr. David Ford
Great News!
We have a great about your E-mail address!!! You Won $950,500.00 USD on Amnesty International UK online E-mail Promotion. For more details about your prize claims, file with the following; Names: Country: Tel: Regards, Mr. David Ford
Re: [PATCH v2 1/2] hwmon: (ucd9000) Add gpio chip interface
Hi Christopher, Thank you for the patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v4.16-rc5 next-20180315] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Eddie-James/hwmon-ucd9000-Add-gpio-and-debugfs-interfaces/20180316-125048 config: x86_64-randconfig-x019-201810 (attached as .config) compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All error/warnings (new ones prefixed by >>): >> drivers/hwmon/pmbus/ucd9000.c:69:19: error: field 'gpio' has incomplete type struct gpio_chip gpio; ^~~~ drivers/hwmon/pmbus/ucd9000.c: In function 'ucd9000_gpio_get': >> drivers/hwmon/pmbus/ucd9000.c:184:31: error: implicit declaration of >> function 'gpiochip_get_data'; did you mean 'gpio_get_value'? >> [-Werror=implicit-function-declaration] struct i2c_client *client = gpiochip_get_data(gc); ^ gpio_get_value >> drivers/hwmon/pmbus/ucd9000.c:184:31: warning: initialization makes pointer >> from integer without a cast [-Wint-conversion] drivers/hwmon/pmbus/ucd9000.c: In function 'ucd9000_gpio_set': drivers/hwmon/pmbus/ucd9000.c:197:30: warning: initialization makes pointer from integer without a cast [-Wint-conversion] struct i2c_client *client = gpiochip_get_data(gc); ^ drivers/hwmon/pmbus/ucd9000.c: In function 'ucd9000_gpio_get_direction': drivers/hwmon/pmbus/ucd9000.c:240:30: warning: initialization makes pointer from integer without a cast [-Wint-conversion] struct i2c_client *client = gpiochip_get_data(gc); ^ drivers/hwmon/pmbus/ucd9000.c: In function 'ucd9000_gpio_set_direction': drivers/hwmon/pmbus/ucd9000.c:254:30: warning: initialization makes pointer from integer without a cast [-Wint-conversion] struct i2c_client *client = gpiochip_get_data(gc); ^ drivers/hwmon/pmbus/ucd9000.c: In function 'ucd9000_probe': >> drivers/hwmon/pmbus/ucd9000.c:460:9: error: implicit declaration of function >> 'devm_gpiochip_add_data'; did you mean 'devm_gpio_request'? >> [-Werror=implicit-function-declaration] ret = devm_gpiochip_add_data(>dev, >gpio, ^~ devm_gpio_request cc1: some warnings being treated as errors vim +/gpio +69 drivers/hwmon/pmbus/ucd9000.c 65 66 struct ucd9000_data { 67 u8 fan_data[UCD9000_NUM_FAN][I2C_SMBUS_BLOCK_MAX]; 68 struct pmbus_driver_info info; > 69 struct gpio_chip gpio; 70 }; 71 #define to_ucd9000_data(_info) container_of(_info, struct ucd9000_data, info) 72 73 static int ucd9000_get_fan_config(struct i2c_client *client, int fan) 74 { 75 int fan_config = 0; 76 struct ucd9000_data *data 77= to_ucd9000_data(pmbus_get_driver_info(client)); 78 79 if (data->fan_data[fan][3] & 1) 80 fan_config |= PB_FAN_2_INSTALLED; /* Use lower bit position */ 81 82 /* Pulses/revolution */ 83 fan_config |= (data->fan_data[fan][3] & 0x06) >> 1; 84 85 return fan_config; 86 } 87 88 static int ucd9000_read_byte_data(struct i2c_client *client, int page, int reg) 89 { 90 int ret = 0; 91 int fan_config; 92 93 switch (reg) { 94 case PMBUS_FAN_CONFIG_12: 95 if (page > 0) 96 return -ENXIO; 97 98 ret = ucd9000_get_fan_config(client, 0); 99 if (ret < 0) 100 return ret; 101 fan_config = ret << 4; 102 ret = ucd9000_get_fan_config(client, 1); 103 if (ret < 0) 104 return ret; 105 fan_config |= ret; 106 ret = fan_config; 107 break; 108 case PMBUS_FAN_CONFIG_34: 109 if (page > 0) 110 return -ENXIO; 111 112 ret = ucd9000_get_fan_config(client, 2); 113 if (ret < 0) 114 return ret; 115 fan_config = ret << 4; 116 ret = ucd9000_get_fan_config(client, 3); 117 if (ret < 0) 118 return ret; 119 fan_config |= ret; 120 r
Re: [PATCH v2 1/2] hwmon: (ucd9000) Add gpio chip interface
Hi Christopher, Thank you for the patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v4.16-rc5 next-20180315] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Eddie-James/hwmon-ucd9000-Add-gpio-and-debugfs-interfaces/20180316-125048 config: x86_64-randconfig-x019-201810 (attached as .config) compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All error/warnings (new ones prefixed by >>): >> drivers/hwmon/pmbus/ucd9000.c:69:19: error: field 'gpio' has incomplete type struct gpio_chip gpio; ^~~~ drivers/hwmon/pmbus/ucd9000.c: In function 'ucd9000_gpio_get': >> drivers/hwmon/pmbus/ucd9000.c:184:31: error: implicit declaration of >> function 'gpiochip_get_data'; did you mean 'gpio_get_value'? >> [-Werror=implicit-function-declaration] struct i2c_client *client = gpiochip_get_data(gc); ^ gpio_get_value >> drivers/hwmon/pmbus/ucd9000.c:184:31: warning: initialization makes pointer >> from integer without a cast [-Wint-conversion] drivers/hwmon/pmbus/ucd9000.c: In function 'ucd9000_gpio_set': drivers/hwmon/pmbus/ucd9000.c:197:30: warning: initialization makes pointer from integer without a cast [-Wint-conversion] struct i2c_client *client = gpiochip_get_data(gc); ^ drivers/hwmon/pmbus/ucd9000.c: In function 'ucd9000_gpio_get_direction': drivers/hwmon/pmbus/ucd9000.c:240:30: warning: initialization makes pointer from integer without a cast [-Wint-conversion] struct i2c_client *client = gpiochip_get_data(gc); ^ drivers/hwmon/pmbus/ucd9000.c: In function 'ucd9000_gpio_set_direction': drivers/hwmon/pmbus/ucd9000.c:254:30: warning: initialization makes pointer from integer without a cast [-Wint-conversion] struct i2c_client *client = gpiochip_get_data(gc); ^ drivers/hwmon/pmbus/ucd9000.c: In function 'ucd9000_probe': >> drivers/hwmon/pmbus/ucd9000.c:460:9: error: implicit declaration of function >> 'devm_gpiochip_add_data'; did you mean 'devm_gpio_request'? >> [-Werror=implicit-function-declaration] ret = devm_gpiochip_add_data(>dev, >gpio, ^~ devm_gpio_request cc1: some warnings being treated as errors vim +/gpio +69 drivers/hwmon/pmbus/ucd9000.c 65 66 struct ucd9000_data { 67 u8 fan_data[UCD9000_NUM_FAN][I2C_SMBUS_BLOCK_MAX]; 68 struct pmbus_driver_info info; > 69 struct gpio_chip gpio; 70 }; 71 #define to_ucd9000_data(_info) container_of(_info, struct ucd9000_data, info) 72 73 static int ucd9000_get_fan_config(struct i2c_client *client, int fan) 74 { 75 int fan_config = 0; 76 struct ucd9000_data *data 77= to_ucd9000_data(pmbus_get_driver_info(client)); 78 79 if (data->fan_data[fan][3] & 1) 80 fan_config |= PB_FAN_2_INSTALLED; /* Use lower bit position */ 81 82 /* Pulses/revolution */ 83 fan_config |= (data->fan_data[fan][3] & 0x06) >> 1; 84 85 return fan_config; 86 } 87 88 static int ucd9000_read_byte_data(struct i2c_client *client, int page, int reg) 89 { 90 int ret = 0; 91 int fan_config; 92 93 switch (reg) { 94 case PMBUS_FAN_CONFIG_12: 95 if (page > 0) 96 return -ENXIO; 97 98 ret = ucd9000_get_fan_config(client, 0); 99 if (ret < 0) 100 return ret; 101 fan_config = ret << 4; 102 ret = ucd9000_get_fan_config(client, 1); 103 if (ret < 0) 104 return ret; 105 fan_config |= ret; 106 ret = fan_config; 107 break; 108 case PMBUS_FAN_CONFIG_34: 109 if (page > 0) 110 return -ENXIO; 111 112 ret = ucd9000_get_fan_config(client, 2); 113 if (ret < 0) 114 return ret; 115 fan_config = ret << 4; 116 ret = ucd9000_get_fan_config(client, 3); 117 if (ret < 0) 118 return ret; 119 fan_config |= ret; 120 r
Re: linux-next: build failure after merge of the y2038 tree
Hi Arnd, Do you want me to send the fix as a patch or should I re-post the series? Thanks, Deepa On Thu, Mar 15, 2018 at 7:25 PM, Stephen Rothwellwrote: > Hi Arnd, > > After merging the y2038 tree, today's linux-next build (s390 allnoconfig) > failed like this: > > In file included from include/linux/elf.h:5:0, > from include/linux/module.h:15, > from init/main.c:16: > arch/s390/include/asm/elf.h:138:1: error: unknown type name 's390_compat_regs' > > Caused by commit > > f00689038f71 ("include: Move compat_timespec/ timeval to compat_time.h") > > -- > Cheers, > Stephen Rothwell
Re: linux-next: build failure after merge of the y2038 tree
Hi Arnd, Do you want me to send the fix as a patch or should I re-post the series? Thanks, Deepa On Thu, Mar 15, 2018 at 7:25 PM, Stephen Rothwell wrote: > Hi Arnd, > > After merging the y2038 tree, today's linux-next build (s390 allnoconfig) > failed like this: > > In file included from include/linux/elf.h:5:0, > from include/linux/module.h:15, > from init/main.c:16: > arch/s390/include/asm/elf.h:138:1: error: unknown type name 's390_compat_regs' > > Caused by commit > > f00689038f71 ("include: Move compat_timespec/ timeval to compat_time.h") > > -- > Cheers, > Stephen Rothwell
Re: [PATCH v2] watchdog: aspeed: Allow configuring for alternate boot
On Fri, Mar 16, 2018 at 2:32 AM, Eddie Jameswrote: > From: Milton Miller > > Allow the device tree to specify a watchdog to fallover to > the alternate boot source. > > The aspeeed watchdog can set a latch directing flash chip select 0 to > chip select 1, allowing boot from an alternate media if the watchdog > is not reset in time. On the ast2400 bank 1 also goes to flash bank 1, > while on the ast2500 the chip selects are swapped. > > Also clear the secondary boot bit during the machine restart operation. > Otherwise, the system will switch to the alternate boot after every > reboot, which is not desired. > > Signed-off-by: Milton Miller > Signed-off-by: Eddie James That will do. Reviewed-by: Joel Stanley Cheers, Joel > --- > Changes since v1: > * Disable secondary boot before the restart operation. > > drivers/watchdog/aspeed_wdt.c | 4 > 1 file changed, 4 insertions(+) > > diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c > index d1987d6..a5b8eb2 100644 > --- a/drivers/watchdog/aspeed_wdt.c > +++ b/drivers/watchdog/aspeed_wdt.c > @@ -46,6 +46,7 @@ struct aspeed_wdt_config { > #define WDT_RELOAD_VALUE 0x04 > #define WDT_RESTART0x08 > #define WDT_CTRL 0x0C > +#define WDT_CTRL_BOOT_SECONDARY BIT(7) > #define WDT_CTRL_RESET_MODE_SOC (0x00 << 5) > #define WDT_CTRL_RESET_MODE_FULL_CHIP(0x01 << 5) > #define WDT_CTRL_RESET_MODE_ARM_CPU (0x10 << 5) > @@ -158,6 +159,7 @@ static int aspeed_wdt_restart(struct watchdog_device *wdd, > { > struct aspeed_wdt *wdt = to_aspeed_wdt(wdd); > > + wdt->ctrl &= ~WDT_CTRL_BOOT_SECONDARY; > aspeed_wdt_enable(wdt, 128 * WDT_RATE_1MHZ / 1000); > > mdelay(1000); > @@ -245,6 +247,8 @@ static int aspeed_wdt_probe(struct platform_device *pdev) > } > if (of_property_read_bool(np, "aspeed,external-signal")) > wdt->ctrl |= WDT_CTRL_WDT_EXT; > + if (of_property_read_bool(np, "aspeed,alt-boot")) > + wdt->ctrl |= WDT_CTRL_BOOT_SECONDARY; > > if (readl(wdt->base + WDT_CTRL) & WDT_CTRL_ENABLE) { > /* > -- > 1.8.3.1 >
Re: [PATCH v2] watchdog: aspeed: Allow configuring for alternate boot
On Fri, Mar 16, 2018 at 2:32 AM, Eddie James wrote: > From: Milton Miller > > Allow the device tree to specify a watchdog to fallover to > the alternate boot source. > > The aspeeed watchdog can set a latch directing flash chip select 0 to > chip select 1, allowing boot from an alternate media if the watchdog > is not reset in time. On the ast2400 bank 1 also goes to flash bank 1, > while on the ast2500 the chip selects are swapped. > > Also clear the secondary boot bit during the machine restart operation. > Otherwise, the system will switch to the alternate boot after every > reboot, which is not desired. > > Signed-off-by: Milton Miller > Signed-off-by: Eddie James That will do. Reviewed-by: Joel Stanley Cheers, Joel > --- > Changes since v1: > * Disable secondary boot before the restart operation. > > drivers/watchdog/aspeed_wdt.c | 4 > 1 file changed, 4 insertions(+) > > diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c > index d1987d6..a5b8eb2 100644 > --- a/drivers/watchdog/aspeed_wdt.c > +++ b/drivers/watchdog/aspeed_wdt.c > @@ -46,6 +46,7 @@ struct aspeed_wdt_config { > #define WDT_RELOAD_VALUE 0x04 > #define WDT_RESTART0x08 > #define WDT_CTRL 0x0C > +#define WDT_CTRL_BOOT_SECONDARY BIT(7) > #define WDT_CTRL_RESET_MODE_SOC (0x00 << 5) > #define WDT_CTRL_RESET_MODE_FULL_CHIP(0x01 << 5) > #define WDT_CTRL_RESET_MODE_ARM_CPU (0x10 << 5) > @@ -158,6 +159,7 @@ static int aspeed_wdt_restart(struct watchdog_device *wdd, > { > struct aspeed_wdt *wdt = to_aspeed_wdt(wdd); > > + wdt->ctrl &= ~WDT_CTRL_BOOT_SECONDARY; > aspeed_wdt_enable(wdt, 128 * WDT_RATE_1MHZ / 1000); > > mdelay(1000); > @@ -245,6 +247,8 @@ static int aspeed_wdt_probe(struct platform_device *pdev) > } > if (of_property_read_bool(np, "aspeed,external-signal")) > wdt->ctrl |= WDT_CTRL_WDT_EXT; > + if (of_property_read_bool(np, "aspeed,alt-boot")) > + wdt->ctrl |= WDT_CTRL_BOOT_SECONDARY; > > if (readl(wdt->base + WDT_CTRL) & WDT_CTRL_ENABLE) { > /* > -- > 1.8.3.1 >
Re: [PATCH RFC rebase 3/9] powerpc/64: Use barrier_nospec in syscall entry
On Thu, 15 Mar 2018 20:15:52 +0100 Michal Suchanekwrote: > On powerpc syscall entry is done in assembly so patch in an explicit > barrier_nospec. Same comment as Linus for this -- the barriers are before the branch here, so is it possible the branch instruction can be speculative while the index is used to load the syscall table? Thanks, Nick > > Signed-off-by: Michal Suchanek > --- > arch/powerpc/kernel/entry_64.S | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S > index 2cb5109a7ea3..7bfc4cf48af2 100644 > --- a/arch/powerpc/kernel/entry_64.S > +++ b/arch/powerpc/kernel/entry_64.S > @@ -36,6 +36,7 @@ > #include > #include > #include > +#include > #include > #ifdef CONFIG_PPC_BOOK3S > #include > @@ -159,6 +160,7 @@ system_call: /* label this so stack > traces look sane */ > andi. r11,r10,_TIF_SYSCALL_DOTRACE > bne .Lsyscall_dotrace /* does not return */ > cmpldi 0,r0,NR_syscalls > + barrier_nospec > bge-.Lsyscall_enosys > > .Lsyscall: > @@ -319,6 +321,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) > ld r10,TI_FLAGS(r10) > > cmpldi r0,NR_syscalls > + barrier_nospec > blt+.Lsyscall > > /* Return code is already in r3 thanks to do_syscall_trace_enter() */
Re: [PATCH RFC rebase 3/9] powerpc/64: Use barrier_nospec in syscall entry
On Thu, 15 Mar 2018 20:15:52 +0100 Michal Suchanek wrote: > On powerpc syscall entry is done in assembly so patch in an explicit > barrier_nospec. Same comment as Linus for this -- the barriers are before the branch here, so is it possible the branch instruction can be speculative while the index is used to load the syscall table? Thanks, Nick > > Signed-off-by: Michal Suchanek > --- > arch/powerpc/kernel/entry_64.S | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S > index 2cb5109a7ea3..7bfc4cf48af2 100644 > --- a/arch/powerpc/kernel/entry_64.S > +++ b/arch/powerpc/kernel/entry_64.S > @@ -36,6 +36,7 @@ > #include > #include > #include > +#include > #include > #ifdef CONFIG_PPC_BOOK3S > #include > @@ -159,6 +160,7 @@ system_call: /* label this so stack > traces look sane */ > andi. r11,r10,_TIF_SYSCALL_DOTRACE > bne .Lsyscall_dotrace /* does not return */ > cmpldi 0,r0,NR_syscalls > + barrier_nospec > bge-.Lsyscall_enosys > > .Lsyscall: > @@ -319,6 +321,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) > ld r10,TI_FLAGS(r10) > > cmpldi r0,NR_syscalls > + barrier_nospec > blt+.Lsyscall > > /* Return code is already in r3 thanks to do_syscall_trace_enter() */
Re: [PATCH 4/4] mm/hmm: change CPU page table snapshot functions to simplify drivers
On 03/15/2018 11:37 AM, jgli...@redhat.com wrote: > From: Jérôme Glisse> > This change hmm_vma_fault() and hmm_vma_get_pfns() API to allow HMM > to directly write entry that can match any device page table entry > format. Device driver now provide an array of flags value and we use > enum to index this array for each flag. > > This also allow the device driver to ask for write fault on a per page > basis making API more flexible to service multiple device page faults > in one go. > Hi Jerome, This is a large patch, so I'm going to review it in two passes. The first pass is just an overview plus the hmm.h changes (now), and tomorrow I will review the hmm.c, which is where the real changes are. Overview: the hmm.c changes are doing several things, and it is difficult to review, because refactoring, plus new behavior, makes diffs less useful here. It would probably be good to split the hmm.c changes into a few patches, such as: -- HMM_PFN_FLAG_* changes, plus function signature changes (mm_range* being passed to functions), and -- New behavior in the page handling loops, and -- Refactoring into new routines (hmm_vma_handle_pte, and others) That way, reviewers can see more easily that things are correct. > Signed-off-by: Jérôme Glisse > Cc: Evgeny Baskakov > Cc: Ralph Campbell > Cc: Mark Hairgrove > Cc: John Hubbard > --- > include/linux/hmm.h | 130 +++-- > mm/hmm.c| 331 > +--- > 2 files changed, 249 insertions(+), 212 deletions(-) > > diff --git a/include/linux/hmm.h b/include/linux/hmm.h > index 61b0e1c05ee1..34e8a8c65bbd 100644 > --- a/include/linux/hmm.h > +++ b/include/linux/hmm.h > @@ -80,11 +80,10 @@ > struct hmm; > > /* > - * hmm_pfn_t - HMM uses its own pfn type to keep several flags per page > + * uint64_t - HMM uses its own pfn type to keep several flags per page This line now is a little odd, because it looks like it's trying to document uint64_t as an HMM pfn type. :) Maybe: * HMM pfns are of type uint64_t ...or else just delete it, either way. > * > * Flags: > * HMM_PFN_VALID: pfn is valid All of these are missing a _FLAG_ piece. The above should be HMM_PFN_FLAG_VALID, to match the enum below. > - * HMM_PFN_READ: CPU page table has read permission set So why is it that we don't need the _READ flag anymore? I looked at the corresponding hmm.c but still don't quite get it. Is it that we just expect that _READ is always set if there is an entry at all? Or something else? > * HMM_PFN_WRITE: CPU page table has write permission set > * HMM_PFN_ERROR: corresponding CPU page table entry points to poisoned > memory > * HMM_PFN_EMPTY: corresponding CPU page table entry is pte_none() > @@ -92,64 +91,94 @@ struct hmm; > * result of vm_insert_pfn() or vm_insert_page(). Therefore, it should > not > * be mirrored by a device, because the entry will never have > HMM_PFN_VALID > * set and the pfn value is undefined. > - * HMM_PFN_DEVICE_UNADDRESSABLE: unaddressable device memory (ZONE_DEVICE) > + * HMM_PFN_DEVICE_PRIVATE: private device memory (ZONE_DEVICE) > */ > -typedef unsigned long hmm_pfn_t; > +enum hmm_pfn_flag_e { > + HMM_PFN_FLAG_VALID = 0, > + HMM_PFN_FLAG_WRITE, > + HMM_PFN_FLAG_ERROR, > + HMM_PFN_FLAG_NONE, > + HMM_PFN_FLAG_SPECIAL, > + HMM_PFN_FLAG_DEVICE_PRIVATE, > + HMM_PFN_FLAG_MAX > +}; > + > +/* > + * struct hmm_range - track invalidation lock on virtual address range > + * > + * @vma: the vm area struct for the range > + * @list: all range lock are on a list > + * @start: range virtual start address (inclusive) > + * @end: range virtual end address (exclusive) > + * @pfns: array of pfns (big enough for the range) > + * @flags: pfn flags to match device driver page table > + * @valid: pfns array did not change since it has been fill by an HMM > function > + */ > +struct hmm_range { > + struct vm_area_struct *vma; > + struct list_headlist; > + unsigned long start; > + unsigned long end; > + uint64_t*pfns; > + const uint64_t *flags; > + uint8_t pfn_shift; > + boolvalid; > +}; > +#define HMM_RANGE_PFN_FLAG(f) (range->flags[HMM_PFN_FLAG_##f]) Please please please no. :) This breaks grep without actually adding any value. It's not as if you need to build up a whole set of symmetric macros like the Page* flags do, after all. So we can keep this very simple, instead. I've looked through the hmm.c and it's always just something like HMM_RANGE_PFN_FLAG(WRITE), so there really is no need for this macro at all. Just use HMM_PFN_FLAG_WRITE and friends directly, and enjoy the resulting clarity. > > -#define HMM_PFN_VALID (1 << 0) >
Re: [PATCH 4/4] mm/hmm: change CPU page table snapshot functions to simplify drivers
On 03/15/2018 11:37 AM, jgli...@redhat.com wrote: > From: Jérôme Glisse > > This change hmm_vma_fault() and hmm_vma_get_pfns() API to allow HMM > to directly write entry that can match any device page table entry > format. Device driver now provide an array of flags value and we use > enum to index this array for each flag. > > This also allow the device driver to ask for write fault on a per page > basis making API more flexible to service multiple device page faults > in one go. > Hi Jerome, This is a large patch, so I'm going to review it in two passes. The first pass is just an overview plus the hmm.h changes (now), and tomorrow I will review the hmm.c, which is where the real changes are. Overview: the hmm.c changes are doing several things, and it is difficult to review, because refactoring, plus new behavior, makes diffs less useful here. It would probably be good to split the hmm.c changes into a few patches, such as: -- HMM_PFN_FLAG_* changes, plus function signature changes (mm_range* being passed to functions), and -- New behavior in the page handling loops, and -- Refactoring into new routines (hmm_vma_handle_pte, and others) That way, reviewers can see more easily that things are correct. > Signed-off-by: Jérôme Glisse > Cc: Evgeny Baskakov > Cc: Ralph Campbell > Cc: Mark Hairgrove > Cc: John Hubbard > --- > include/linux/hmm.h | 130 +++-- > mm/hmm.c| 331 > +--- > 2 files changed, 249 insertions(+), 212 deletions(-) > > diff --git a/include/linux/hmm.h b/include/linux/hmm.h > index 61b0e1c05ee1..34e8a8c65bbd 100644 > --- a/include/linux/hmm.h > +++ b/include/linux/hmm.h > @@ -80,11 +80,10 @@ > struct hmm; > > /* > - * hmm_pfn_t - HMM uses its own pfn type to keep several flags per page > + * uint64_t - HMM uses its own pfn type to keep several flags per page This line now is a little odd, because it looks like it's trying to document uint64_t as an HMM pfn type. :) Maybe: * HMM pfns are of type uint64_t ...or else just delete it, either way. > * > * Flags: > * HMM_PFN_VALID: pfn is valid All of these are missing a _FLAG_ piece. The above should be HMM_PFN_FLAG_VALID, to match the enum below. > - * HMM_PFN_READ: CPU page table has read permission set So why is it that we don't need the _READ flag anymore? I looked at the corresponding hmm.c but still don't quite get it. Is it that we just expect that _READ is always set if there is an entry at all? Or something else? > * HMM_PFN_WRITE: CPU page table has write permission set > * HMM_PFN_ERROR: corresponding CPU page table entry points to poisoned > memory > * HMM_PFN_EMPTY: corresponding CPU page table entry is pte_none() > @@ -92,64 +91,94 @@ struct hmm; > * result of vm_insert_pfn() or vm_insert_page(). Therefore, it should > not > * be mirrored by a device, because the entry will never have > HMM_PFN_VALID > * set and the pfn value is undefined. > - * HMM_PFN_DEVICE_UNADDRESSABLE: unaddressable device memory (ZONE_DEVICE) > + * HMM_PFN_DEVICE_PRIVATE: private device memory (ZONE_DEVICE) > */ > -typedef unsigned long hmm_pfn_t; > +enum hmm_pfn_flag_e { > + HMM_PFN_FLAG_VALID = 0, > + HMM_PFN_FLAG_WRITE, > + HMM_PFN_FLAG_ERROR, > + HMM_PFN_FLAG_NONE, > + HMM_PFN_FLAG_SPECIAL, > + HMM_PFN_FLAG_DEVICE_PRIVATE, > + HMM_PFN_FLAG_MAX > +}; > + > +/* > + * struct hmm_range - track invalidation lock on virtual address range > + * > + * @vma: the vm area struct for the range > + * @list: all range lock are on a list > + * @start: range virtual start address (inclusive) > + * @end: range virtual end address (exclusive) > + * @pfns: array of pfns (big enough for the range) > + * @flags: pfn flags to match device driver page table > + * @valid: pfns array did not change since it has been fill by an HMM > function > + */ > +struct hmm_range { > + struct vm_area_struct *vma; > + struct list_headlist; > + unsigned long start; > + unsigned long end; > + uint64_t*pfns; > + const uint64_t *flags; > + uint8_t pfn_shift; > + boolvalid; > +}; > +#define HMM_RANGE_PFN_FLAG(f) (range->flags[HMM_PFN_FLAG_##f]) Please please please no. :) This breaks grep without actually adding any value. It's not as if you need to build up a whole set of symmetric macros like the Page* flags do, after all. So we can keep this very simple, instead. I've looked through the hmm.c and it's always just something like HMM_RANGE_PFN_FLAG(WRITE), so there really is no need for this macro at all. Just use HMM_PFN_FLAG_WRITE and friends directly, and enjoy the resulting clarity. > > -#define HMM_PFN_VALID (1 << 0) > -#define HMM_PFN_READ (1 << 1) > -#define HMM_PFN_WRITE (1 << 2) > -#define HMM_PFN_ERROR (1 << 3) > -#define HMM_PFN_EMPTY (1 << 4) >
[PATCH] staging: media: davinci_vpfe: add error handling on kmalloc failure
There is no failure checking on the param value which will be allocated memory by kmalloc. Add a null pointer checking statement. Then goto error: and return -ENOMEM error code when kmalloc is failed. Signed-off-by: Ji-Hun Kim--- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index 6a3434c..55a922c 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -1280,6 +1280,10 @@ static int ipipe_s_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg) params = kmalloc(sizeof(struct ipipe_module_params), GFP_KERNEL); + if (!params) { + rval = -ENOMEM; + goto error; + } to = (void *)params + module_if->param_offset; size = module_if->param_size; @@ -1323,6 +1327,10 @@ static int ipipe_g_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg) params = kmalloc(sizeof(struct ipipe_module_params), GFP_KERNEL); + if (!params) { + rval = -ENOMEM; + goto error; + } from = (void *)params + module_if->param_offset; size = module_if->param_size; -- 1.9.1
[PATCH] staging: media: davinci_vpfe: add error handling on kmalloc failure
There is no failure checking on the param value which will be allocated memory by kmalloc. Add a null pointer checking statement. Then goto error: and return -ENOMEM error code when kmalloc is failed. Signed-off-by: Ji-Hun Kim --- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index 6a3434c..55a922c 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -1280,6 +1280,10 @@ static int ipipe_s_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg) params = kmalloc(sizeof(struct ipipe_module_params), GFP_KERNEL); + if (!params) { + rval = -ENOMEM; + goto error; + } to = (void *)params + module_if->param_offset; size = module_if->param_size; @@ -1323,6 +1327,10 @@ static int ipipe_g_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg) params = kmalloc(sizeof(struct ipipe_module_params), GFP_KERNEL); + if (!params) { + rval = -ENOMEM; + goto error; + } from = (void *)params + module_if->param_offset; size = module_if->param_size; -- 1.9.1
Re: [PATCH] [v2] Bluetooth: btrsi: rework dependencies
Arnd Bergmannwrites: > On Thu, Mar 15, 2018 at 7:30 PM, Marcel Holtmann wrote: >> Hi Arnd, >> >>> The linkage between the bluetooth driver and the wireless >>> driver is not defined properly, leading to build problems >>> such as: >>> >>> warning: (BT_HCIRSI) selects RSI_COEX which has unmet direct >>> dependencies (NETDEVICES && WLAN && WLAN_VENDOR_RSI && BT_HCIRSI && >>> RSI_91X) >>> drivers/net/wireless/rsi/rsi_91x_main.o: In function `rsi_read_pkt': >>> (.text+0x205): undefined reference to `rsi_bt_ops' >>> >>> As the dependency is actually the reverse (RSI_91X uses >>> the BT_RSI driver, not the other way round), this changes >>> the dependency to match, and enables the bluetooth driver >>> from the RSI_COEX symbol. >>> >>> Fixes: 38aa4da50483 ("Bluetooth: btrsi: add new rsi bluetooth driver") >>> Signed-off-by: Arnd Bergmann >>> --- >>> v2: Pick a different from v1 >>> --- >>> drivers/bluetooth/Kconfig| 4 +--- >>> drivers/net/wireless/rsi/Kconfig | 4 +++- >>> 2 files changed, 4 insertions(+), 4 deletions(-) >> >> Acked-by: Marcel Holtmann >> >> Since I think Kalle still has to take it through his tree until the >> btrsi driver makes it into net-next. Yes, I have to take this as I haven't sent the original patch to Dave yet. > Kalle, please wait for v3 though, I just ran into another build > failure caused by a typo in v2. Ok, I saw it. -- Kalle Valo
Re: [PATCH] [v2] Bluetooth: btrsi: rework dependencies
Arnd Bergmann writes: > On Thu, Mar 15, 2018 at 7:30 PM, Marcel Holtmann wrote: >> Hi Arnd, >> >>> The linkage between the bluetooth driver and the wireless >>> driver is not defined properly, leading to build problems >>> such as: >>> >>> warning: (BT_HCIRSI) selects RSI_COEX which has unmet direct >>> dependencies (NETDEVICES && WLAN && WLAN_VENDOR_RSI && BT_HCIRSI && >>> RSI_91X) >>> drivers/net/wireless/rsi/rsi_91x_main.o: In function `rsi_read_pkt': >>> (.text+0x205): undefined reference to `rsi_bt_ops' >>> >>> As the dependency is actually the reverse (RSI_91X uses >>> the BT_RSI driver, not the other way round), this changes >>> the dependency to match, and enables the bluetooth driver >>> from the RSI_COEX symbol. >>> >>> Fixes: 38aa4da50483 ("Bluetooth: btrsi: add new rsi bluetooth driver") >>> Signed-off-by: Arnd Bergmann >>> --- >>> v2: Pick a different from v1 >>> --- >>> drivers/bluetooth/Kconfig| 4 +--- >>> drivers/net/wireless/rsi/Kconfig | 4 +++- >>> 2 files changed, 4 insertions(+), 4 deletions(-) >> >> Acked-by: Marcel Holtmann >> >> Since I think Kalle still has to take it through his tree until the >> btrsi driver makes it into net-next. Yes, I have to take this as I haven't sent the original patch to Dave yet. > Kalle, please wait for v3 though, I just ran into another build > failure caused by a typo in v2. Ok, I saw it. -- Kalle Valo
Re: [PATCH 00/16] remove eight obsolete architectures
Hi, On Thu, Mar 15, 2018 at 10:56:48AM +0100, Arnd Bergmann wrote: > On Thu, Mar 15, 2018 at 10:42 AM, David Howellswrote: > > Do we have anything left that still implements NOMMU? Please don't kill !MMU. > Yes, plenty. > I've made an overview of the remaining architectures for my own reference[1]. > The remaining NOMMU architectures are: > > - arch/arm has ARMv7-M (Cortex-M microcontroller), which is actually > gaining traction ARMv7-R as well, also seems ARM is coming up with more !MMU's - v8-M, v8-R. In addition, though only of academic interest, ARM MMU capable platform's can run !MMU Linux. afzal > - arch/sh has an open-source J2 core that was added not that long ago, > it seems to > be the only SH compatible core that anyone is working on. > - arch/microblaze supports both MMU/NOMMU modes (most use an MMU) > - arch/m68k supports several NOMMU targets, both the coldfire SoCs and the > classic processors > - c6x has no MMU
Re: [PATCH 00/16] remove eight obsolete architectures
Hi, On Thu, Mar 15, 2018 at 10:56:48AM +0100, Arnd Bergmann wrote: > On Thu, Mar 15, 2018 at 10:42 AM, David Howells wrote: > > Do we have anything left that still implements NOMMU? Please don't kill !MMU. > Yes, plenty. > I've made an overview of the remaining architectures for my own reference[1]. > The remaining NOMMU architectures are: > > - arch/arm has ARMv7-M (Cortex-M microcontroller), which is actually > gaining traction ARMv7-R as well, also seems ARM is coming up with more !MMU's - v8-M, v8-R. In addition, though only of academic interest, ARM MMU capable platform's can run !MMU Linux. afzal > - arch/sh has an open-source J2 core that was added not that long ago, > it seems to > be the only SH compatible core that anyone is working on. > - arch/microblaze supports both MMU/NOMMU modes (most use an MMU) > - arch/m68k supports several NOMMU targets, both the coldfire SoCs and the > classic processors > - c6x has no MMU
Re: [PATCH 7/7] soc: qcom: rpmpd: Add a max vote on all corners at init
On 16-03-18, 09:38, Rajendra Nayak wrote: > As we move from no clients/consumers in kernel voting on corners, > to *some* voting and some not voting, we might end up in a situation > where the clients which remove votes can adversly impact others > who still don't have a way to vote. > > To avoid this situation, have a max vote on all corners at init. > This should/can be removed once we have all clients moved to > be able to vote/unvote for themselves. > > Signed-off-by: Rajendra Nayak> --- > drivers/soc/qcom/rpmpd.c | 9 + > 1 file changed, 9 insertions(+) > > diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c > index 4058c5b450c6..ebdcf9398441 100644 > --- a/drivers/soc/qcom/rpmpd.c > +++ b/drivers/soc/qcom/rpmpd.c > @@ -304,6 +304,15 @@ static int rpmpd_probe(struct platform_device *pdev) > pm_genpd_init([i]->pd, NULL, true); > > data->domains[i] = [i]->pd; > + > + /* > + * Until we have all consumers voting on corners > + * just vote the max corner on all PDs > + * This should ideally be *removed* once we have > + * all (most) consumers being able to vote > + */ > + rpmpd_set_performance([i]->pd, MAX_RPMPD_STATE); > + rpmpd_power_on([i]->pd); > } > > return of_genpd_add_provider_onecell(pdev->dev.of_node, data); Acked-by: Viresh Kumar -- viresh
Re: [PATCH 7/7] soc: qcom: rpmpd: Add a max vote on all corners at init
On 16-03-18, 09:38, Rajendra Nayak wrote: > As we move from no clients/consumers in kernel voting on corners, > to *some* voting and some not voting, we might end up in a situation > where the clients which remove votes can adversly impact others > who still don't have a way to vote. > > To avoid this situation, have a max vote on all corners at init. > This should/can be removed once we have all clients moved to > be able to vote/unvote for themselves. > > Signed-off-by: Rajendra Nayak > --- > drivers/soc/qcom/rpmpd.c | 9 + > 1 file changed, 9 insertions(+) > > diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c > index 4058c5b450c6..ebdcf9398441 100644 > --- a/drivers/soc/qcom/rpmpd.c > +++ b/drivers/soc/qcom/rpmpd.c > @@ -304,6 +304,15 @@ static int rpmpd_probe(struct platform_device *pdev) > pm_genpd_init([i]->pd, NULL, true); > > data->domains[i] = [i]->pd; > + > + /* > + * Until we have all consumers voting on corners > + * just vote the max corner on all PDs > + * This should ideally be *removed* once we have > + * all (most) consumers being able to vote > + */ > + rpmpd_set_performance([i]->pd, MAX_RPMPD_STATE); > + rpmpd_power_on([i]->pd); > } > > return of_genpd_add_provider_onecell(pdev->dev.of_node, data); Acked-by: Viresh Kumar -- viresh
Re: [PATCH 6/7] mmc: sdhci-msm: Adapt the driver to use OPPs to set clocks/performance state
On 16-03-18, 09:38, Rajendra Nayak wrote: > @@ -1540,6 +1571,9 @@ static int sdhci_msm_probe(struct platform_device *pdev) > pm_runtime_disable(>dev); > pm_runtime_set_suspended(>dev); > pm_runtime_put_noidle(>dev); > + dev_pm_opp_of_remove_table(>dev); You can't do this if there is no OPP table. Probably you should just make it part of the below if block. > + if (msm_host->opp_table) > + dev_pm_opp_put_clkname(msm_host->opp_table); > clk_disable: > clk_bulk_disable_unprepare(ARRAY_SIZE(msm_host->bulk_clks), > msm_host->bulk_clks); > @@ -1564,6 +1598,9 @@ static int sdhci_msm_remove(struct platform_device > *pdev) > pm_runtime_get_sync(>dev); > pm_runtime_disable(>dev); > pm_runtime_put_noidle(>dev); > + dev_pm_opp_of_remove_table(>dev); And this too. > + if (msm_host->opp_table) > + dev_pm_opp_put_clkname(msm_host->opp_table); > > clk_bulk_disable_unprepare(ARRAY_SIZE(msm_host->bulk_clks), > msm_host->bulk_clks); Acked-by: Viresh Kumar-- viresh
Re: [PATCH 6/7] mmc: sdhci-msm: Adapt the driver to use OPPs to set clocks/performance state
On 16-03-18, 09:38, Rajendra Nayak wrote: > @@ -1540,6 +1571,9 @@ static int sdhci_msm_probe(struct platform_device *pdev) > pm_runtime_disable(>dev); > pm_runtime_set_suspended(>dev); > pm_runtime_put_noidle(>dev); > + dev_pm_opp_of_remove_table(>dev); You can't do this if there is no OPP table. Probably you should just make it part of the below if block. > + if (msm_host->opp_table) > + dev_pm_opp_put_clkname(msm_host->opp_table); > clk_disable: > clk_bulk_disable_unprepare(ARRAY_SIZE(msm_host->bulk_clks), > msm_host->bulk_clks); > @@ -1564,6 +1598,9 @@ static int sdhci_msm_remove(struct platform_device > *pdev) > pm_runtime_get_sync(>dev); > pm_runtime_disable(>dev); > pm_runtime_put_noidle(>dev); > + dev_pm_opp_of_remove_table(>dev); And this too. > + if (msm_host->opp_table) > + dev_pm_opp_put_clkname(msm_host->opp_table); > > clk_bulk_disable_unprepare(ARRAY_SIZE(msm_host->bulk_clks), > msm_host->bulk_clks); Acked-by: Viresh Kumar -- viresh
Re: [PATCH v2 3/3] vfio/pci: Add ioeventfd support
On Thu, Mar 15, 2018 at 03:31:58PM -0600, Alex Williamson wrote: > The ioeventfd here is actually irqfd handling of an ioeventfd such as > supported in KVM. A user is able to pre-program a device write to > occur when the eventfd triggers. This is yet another instance of > eventfd-irqfd triggering between KVM and vfio. The impetus for this > is high frequency writes to pages which are virtualized in QEMU. > Enabling this near-direct write path for selected registers within > the virtualized page can improve performance and reduce overhead. > Specifically this is initially targeted at NVIDIA graphics cards where > the driver issues a write to an MMIO register within a virtualized > region in order to allow the MSI interrupt to re-trigger. > > Signed-off-by: Alex WilliamsonReviewed-by: Peter Xu -- Peter Xu
Re: [PATCH v2 3/3] vfio/pci: Add ioeventfd support
On Thu, Mar 15, 2018 at 03:31:58PM -0600, Alex Williamson wrote: > The ioeventfd here is actually irqfd handling of an ioeventfd such as > supported in KVM. A user is able to pre-program a device write to > occur when the eventfd triggers. This is yet another instance of > eventfd-irqfd triggering between KVM and vfio. The impetus for this > is high frequency writes to pages which are virtualized in QEMU. > Enabling this near-direct write path for selected registers within > the virtualized page can improve performance and reduce overhead. > Specifically this is initially targeted at NVIDIA graphics cards where > the driver issues a write to an MMIO register within a virtualized > region in order to allow the MSI interrupt to re-trigger. > > Signed-off-by: Alex Williamson Reviewed-by: Peter Xu -- Peter Xu
[PATCH 1/1] iommu/vt-d: Use real PASID for flush in caching mode
If caching mode is supported, the hardware will cache none-present or erroneous translation entries. Hence, software should explicitly invalidate the PASID cache after a PASID table entry becomes present. We should issue such invalidation with the PASID value that we have changed. PASID 0 is not reserved for this case. Cc: Jacob PanCc: Kevin Tian Cc: Sankaran Rajesh Suggested-by: Ashok Raj Signed-off-by: Liu Yi L Signed-off-by: Lu Baolu --- drivers/iommu/intel-svm.c | 16 ++-- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c index 99bc9bd..b7b88b5 100644 --- a/drivers/iommu/intel-svm.c +++ b/drivers/iommu/intel-svm.c @@ -422,17 +422,13 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ iommu->pasid_table[svm->pasid].val = pasid_entry_val; wmb(); - /* In caching mode, we still have to flush with PASID 0 when -* a PASID table entry becomes present. Not entirely clear -* *why* that would be the case — surely we could just issue -* a flush with the PASID value that we've changed? The PASID -* is the index into the table, after all. It's not like domain -* IDs in the case of the equivalent context-entry change in -* caching mode. And for that matter it's not entirely clear why -* a VMM would be in the business of caching the PASID table -* anyway. Surely that can be left entirely to the guest? */ + + /* +* Flush PASID cache when a PASID table entry becomes +* present. +*/ if (cap_caching_mode(iommu->cap)) - intel_flush_pasid_dev(svm, sdev, 0); + intel_flush_pasid_dev(svm, sdev, svm->pasid); } list_add_rcu(>list, >devs); -- 2.7.4
[PATCH 1/1] iommu/vt-d: Use real PASID for flush in caching mode
If caching mode is supported, the hardware will cache none-present or erroneous translation entries. Hence, software should explicitly invalidate the PASID cache after a PASID table entry becomes present. We should issue such invalidation with the PASID value that we have changed. PASID 0 is not reserved for this case. Cc: Jacob Pan Cc: Kevin Tian Cc: Sankaran Rajesh Suggested-by: Ashok Raj Signed-off-by: Liu Yi L Signed-off-by: Lu Baolu --- drivers/iommu/intel-svm.c | 16 ++-- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c index 99bc9bd..b7b88b5 100644 --- a/drivers/iommu/intel-svm.c +++ b/drivers/iommu/intel-svm.c @@ -422,17 +422,13 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ iommu->pasid_table[svm->pasid].val = pasid_entry_val; wmb(); - /* In caching mode, we still have to flush with PASID 0 when -* a PASID table entry becomes present. Not entirely clear -* *why* that would be the case — surely we could just issue -* a flush with the PASID value that we've changed? The PASID -* is the index into the table, after all. It's not like domain -* IDs in the case of the equivalent context-entry change in -* caching mode. And for that matter it's not entirely clear why -* a VMM would be in the business of caching the PASID table -* anyway. Surely that can be left entirely to the guest? */ + + /* +* Flush PASID cache when a PASID table entry becomes +* present. +*/ if (cap_caching_mode(iommu->cap)) - intel_flush_pasid_dev(svm, sdev, 0); + intel_flush_pasid_dev(svm, sdev, svm->pasid); } list_add_rcu(>list, >devs); -- 2.7.4
Re: [PATCH v4 08/24] fpga: add FPGA DFL PCIe device driver
On Thu, Mar 15, 2018 at 11:49:56AM -0700, Moritz Fischer wrote: > Hi Hao, > > On Tue, Feb 13, 2018 at 05:24:37PM +0800, Wu Hao wrote: > > From: Zhang Yi> > > > This patch implements the basic framework of the driver for FPGA PCIe > > device which implements the Device Feature List (DFL) in its MMIO space. > > This driver is verified on Intel(R) PCIe based FPGA DFL devices, including > > both integrated (e.g Intel Server Platform with In-package FPGA) and > > discrete (e.g Intel FPGA PCIe Acceleration Cards) solutions. > > > > Signed-off-by: Tim Whisonant > > Signed-off-by: Enno Luebbers > > Signed-off-by: Shiva Rao > > Signed-off-by: Christopher Rauer > > Signed-off-by: Zhang Yi > > Signed-off-by: Xiao Guangrong > > Signed-off-by: Wu Hao > > with module_pci_driver() fix: > > Acked-by: Moritz Fischer > > --- > > v2: move the code to drivers/fpga folder as suggested by Alan Tull. > > switch to GPLv2 license. > > fix comments from Moritz Fischer. > > v3: switch to pci_set_dma_mask/consistent_dma_mask() function. > > remove pci_save_state() in probe function. > > rename driver to INTEL_FPGA_DFL_PCI and intel-dfl-pci.c to indicate > > this driver supports Intel FPGA PCI devices which implement DFL. > > improve Kconfig description for INTEL_FPGA_DFL_PCI > > v4: rename to FPGA_DFL_PCI (dfl-pci.c) for better reuse. > > fix SPDX license issue. > > --- > > drivers/fpga/Kconfig | 15 ++ > > drivers/fpga/Makefile | 3 ++ > > drivers/fpga/dfl-pci.c | 127 > > + > > 3 files changed, 145 insertions(+) > > create mode 100644 drivers/fpga/dfl-pci.c > > > > diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig > > index 01ad31f..87f3d44 100644 > > --- a/drivers/fpga/Kconfig > > +++ b/drivers/fpga/Kconfig > > @@ -140,4 +140,19 @@ config FPGA_DFL > > Gate Array (FPGA) solutions which implement Device Feature List. > > It provides enumeration APIs, and feature device infrastructure. > > > > +config FPGA_DFL_PCI > > + tristate "FPGA Device Feature List (DFL) PCIe Device Driver" > > + depends on PCI && FPGA_DFL > > + help > > + Select this option to enable PCIe driver for PCIe based > > + Field-Programmable Gate Array (FPGA) solutions which implemented > > + the Device Feature List (DFL). This driver provides interfaces > > + for userspace applications to configure, enumerate, open and access > > + FPGA accelerators on the FPGA DFL devices, enables system level > > + management functions such as FPGA partial reconfiguration, power > > + management, and virtualization with DFL framework and DFL feature > > + device drivers. > > + > > + To compile this as a module, choose M here. > > + > > endif # FPGA > > diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile > > index c4c62b9..4375630 100644 > > --- a/drivers/fpga/Makefile > > +++ b/drivers/fpga/Makefile > > @@ -30,3 +30,6 @@ obj-$(CONFIG_OF_FPGA_REGION) += > > of-fpga-region.o > > > > # FPGA Device Feature List Support > > obj-$(CONFIG_FPGA_DFL) += dfl.o > > + > > +# Drivers for FPGAs which implement DFL > > +obj-$(CONFIG_FPGA_DFL_PCI) += dfl-pci.o > > diff --git a/drivers/fpga/dfl-pci.c b/drivers/fpga/dfl-pci.c > > new file mode 100644 > > index 000..d91ea42 > > --- /dev/null > > +++ b/drivers/fpga/dfl-pci.c > > @@ -0,0 +1,127 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Driver for FPGA Device Feature List (DFL) PCIe device > > + * > > + * Copyright (C) 2017 Intel Corporation, Inc. > > + * > > + * Authors: > > + * Zhang Yi > > + * Xiao Guangrong > > + * Joseph Grecco > > + * Enno Luebbers > > + * Tim Whisonant > > + * Ananda Ravuri > > + * Henry Mitchel > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#define DRV_VERSION"0.8" > > +#define DRV_NAME "dfl-pci" > > + > > +/* PCI Device ID */ > > +#define PCIE_DEVICE_ID_PF_INT_5_X 0xBCBD > > +#define PCIE_DEVICE_ID_PF_INT_6_X 0xBCC0 > > +#define PCIE_DEVICE_ID_PF_DSC_1_X 0x09C4 > > +/* VF Device */ > > +#define PCIE_DEVICE_ID_VF_INT_5_X 0xBCBF > > +#define PCIE_DEVICE_ID_VF_INT_6_X 0xBCC1 > > +#define PCIE_DEVICE_ID_VF_DSC_1_X 0x09C5 > > + > > +static struct pci_device_id cci_pcie_id_tbl[] = { > > + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_PF_INT_5_X),}, > > + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_VF_INT_5_X),}, > > + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_PF_INT_6_X),}, >
Re: [PATCH v4 08/24] fpga: add FPGA DFL PCIe device driver
On Thu, Mar 15, 2018 at 11:49:56AM -0700, Moritz Fischer wrote: > Hi Hao, > > On Tue, Feb 13, 2018 at 05:24:37PM +0800, Wu Hao wrote: > > From: Zhang Yi > > > > This patch implements the basic framework of the driver for FPGA PCIe > > device which implements the Device Feature List (DFL) in its MMIO space. > > This driver is verified on Intel(R) PCIe based FPGA DFL devices, including > > both integrated (e.g Intel Server Platform with In-package FPGA) and > > discrete (e.g Intel FPGA PCIe Acceleration Cards) solutions. > > > > Signed-off-by: Tim Whisonant > > Signed-off-by: Enno Luebbers > > Signed-off-by: Shiva Rao > > Signed-off-by: Christopher Rauer > > Signed-off-by: Zhang Yi > > Signed-off-by: Xiao Guangrong > > Signed-off-by: Wu Hao > > with module_pci_driver() fix: > > Acked-by: Moritz Fischer > > --- > > v2: move the code to drivers/fpga folder as suggested by Alan Tull. > > switch to GPLv2 license. > > fix comments from Moritz Fischer. > > v3: switch to pci_set_dma_mask/consistent_dma_mask() function. > > remove pci_save_state() in probe function. > > rename driver to INTEL_FPGA_DFL_PCI and intel-dfl-pci.c to indicate > > this driver supports Intel FPGA PCI devices which implement DFL. > > improve Kconfig description for INTEL_FPGA_DFL_PCI > > v4: rename to FPGA_DFL_PCI (dfl-pci.c) for better reuse. > > fix SPDX license issue. > > --- > > drivers/fpga/Kconfig | 15 ++ > > drivers/fpga/Makefile | 3 ++ > > drivers/fpga/dfl-pci.c | 127 > > + > > 3 files changed, 145 insertions(+) > > create mode 100644 drivers/fpga/dfl-pci.c > > > > diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig > > index 01ad31f..87f3d44 100644 > > --- a/drivers/fpga/Kconfig > > +++ b/drivers/fpga/Kconfig > > @@ -140,4 +140,19 @@ config FPGA_DFL > > Gate Array (FPGA) solutions which implement Device Feature List. > > It provides enumeration APIs, and feature device infrastructure. > > > > +config FPGA_DFL_PCI > > + tristate "FPGA Device Feature List (DFL) PCIe Device Driver" > > + depends on PCI && FPGA_DFL > > + help > > + Select this option to enable PCIe driver for PCIe based > > + Field-Programmable Gate Array (FPGA) solutions which implemented > > + the Device Feature List (DFL). This driver provides interfaces > > + for userspace applications to configure, enumerate, open and access > > + FPGA accelerators on the FPGA DFL devices, enables system level > > + management functions such as FPGA partial reconfiguration, power > > + management, and virtualization with DFL framework and DFL feature > > + device drivers. > > + > > + To compile this as a module, choose M here. > > + > > endif # FPGA > > diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile > > index c4c62b9..4375630 100644 > > --- a/drivers/fpga/Makefile > > +++ b/drivers/fpga/Makefile > > @@ -30,3 +30,6 @@ obj-$(CONFIG_OF_FPGA_REGION) += > > of-fpga-region.o > > > > # FPGA Device Feature List Support > > obj-$(CONFIG_FPGA_DFL) += dfl.o > > + > > +# Drivers for FPGAs which implement DFL > > +obj-$(CONFIG_FPGA_DFL_PCI) += dfl-pci.o > > diff --git a/drivers/fpga/dfl-pci.c b/drivers/fpga/dfl-pci.c > > new file mode 100644 > > index 000..d91ea42 > > --- /dev/null > > +++ b/drivers/fpga/dfl-pci.c > > @@ -0,0 +1,127 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Driver for FPGA Device Feature List (DFL) PCIe device > > + * > > + * Copyright (C) 2017 Intel Corporation, Inc. > > + * > > + * Authors: > > + * Zhang Yi > > + * Xiao Guangrong > > + * Joseph Grecco > > + * Enno Luebbers > > + * Tim Whisonant > > + * Ananda Ravuri > > + * Henry Mitchel > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#define DRV_VERSION"0.8" > > +#define DRV_NAME "dfl-pci" > > + > > +/* PCI Device ID */ > > +#define PCIE_DEVICE_ID_PF_INT_5_X 0xBCBD > > +#define PCIE_DEVICE_ID_PF_INT_6_X 0xBCC0 > > +#define PCIE_DEVICE_ID_PF_DSC_1_X 0x09C4 > > +/* VF Device */ > > +#define PCIE_DEVICE_ID_VF_INT_5_X 0xBCBF > > +#define PCIE_DEVICE_ID_VF_INT_6_X 0xBCC1 > > +#define PCIE_DEVICE_ID_VF_DSC_1_X 0x09C5 > > + > > +static struct pci_device_id cci_pcie_id_tbl[] = { > > + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_PF_INT_5_X),}, > > + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_VF_INT_5_X),}, > > + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_PF_INT_6_X),}, > > + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_VF_INT_6_X),}, > > + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_PF_DSC_1_X),}, > > + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_VF_DSC_1_X),}, > > + {0,} > > +}; > > +MODULE_DEVICE_TABLE(pci, cci_pcie_id_tbl); > > + > > +static > > +int cci_pci_probe(struct pci_dev *pcidev, const struct pci_device_id > > *pcidevid)
Re: [PATCH 5/7] arm64: dts: msm8996: Add rpmpd device node
On 16-03-18, 09:38, Rajendra Nayak wrote: > Add rpmpd device node and its OPP table > > Signed-off-by: Rajendra Nayak> Signed-off-by: Viresh Kumar > --- > arch/arm64/boot/dts/qcom/msm8996.dtsi | 46 > +++ > 1 file changed, 46 insertions(+) > > diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi > b/arch/arm64/boot/dts/qcom/msm8996.dtsi > index 0a6f7952bbb1..43757a078146 100644 > --- a/arch/arm64/boot/dts/qcom/msm8996.dtsi > +++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi > @@ -297,6 +297,52 @@ > #clock-cells = <1>; > }; > > + rpmpd: qcom,rpmpd { > + compatible = "qcom,rpmpd-msm8996"; > + #power-domain-cells = <1>; > + operating-points-v2 = <_opp_table>, /* cx > */ > + <_opp_table>, /* > cx_ao */ > + <_opp_table>, /* > cx_vfc */ > + <_opp_table>, /* mx > */ > + <_opp_table>, /* > mx_ao */ > + <_opp_table>, /* > sscx */ > + <_opp_table>; /* > sscx_vfc */ > + }; > + > + rpmpd_opp_table: opp-table { > + compatible = "operating-points-v2", > "operating-points-v2-qcom"; > + > + rpmpd_opp1: opp@1 { > + opp-hz = /bits/ 64 <1>; Actually this (magic values) isn't allowed right now. I will send a patchset to make this property optional later on separately (once the other series is accepted). > + qcom,level = <1>; > + }; > + > + rpmpd_opp2: opp@2 { > + opp-hz = /bits/ 64 <2>; > + qcom,level = <2>; > + }; > + > + rpmpd_opp3: opp@3 { > + opp-hz = /bits/ 64 <3>; > + qcom,level = <3>; > + }; > + > + rpmpd_opp4: opp@4 { > + opp-hz = /bits/ 64 <4>; > + qcom,level = <4>; > + }; > + > + rpmpd_opp5: opp@5 { > + opp-hz = /bits/ 64 <5>; > + qcom,level = <5>; > + }; > + > + rpmpd_opp6: opp@6 { > + opp-hz = /bits/ 64 <6>; > + qcom,level = <6>; > + }; > + }; > + > pm8994-regulators { > compatible = "qcom,rpm-pm8994-regulators"; > Everything else is fine. After you remove the opp-hz property from this table: Acked-by: Viresh Kumar -- viresh
Re: [PATCH 5/7] arm64: dts: msm8996: Add rpmpd device node
On 16-03-18, 09:38, Rajendra Nayak wrote: > Add rpmpd device node and its OPP table > > Signed-off-by: Rajendra Nayak > Signed-off-by: Viresh Kumar > --- > arch/arm64/boot/dts/qcom/msm8996.dtsi | 46 > +++ > 1 file changed, 46 insertions(+) > > diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi > b/arch/arm64/boot/dts/qcom/msm8996.dtsi > index 0a6f7952bbb1..43757a078146 100644 > --- a/arch/arm64/boot/dts/qcom/msm8996.dtsi > +++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi > @@ -297,6 +297,52 @@ > #clock-cells = <1>; > }; > > + rpmpd: qcom,rpmpd { > + compatible = "qcom,rpmpd-msm8996"; > + #power-domain-cells = <1>; > + operating-points-v2 = <_opp_table>, /* cx > */ > + <_opp_table>, /* > cx_ao */ > + <_opp_table>, /* > cx_vfc */ > + <_opp_table>, /* mx > */ > + <_opp_table>, /* > mx_ao */ > + <_opp_table>, /* > sscx */ > + <_opp_table>; /* > sscx_vfc */ > + }; > + > + rpmpd_opp_table: opp-table { > + compatible = "operating-points-v2", > "operating-points-v2-qcom"; > + > + rpmpd_opp1: opp@1 { > + opp-hz = /bits/ 64 <1>; Actually this (magic values) isn't allowed right now. I will send a patchset to make this property optional later on separately (once the other series is accepted). > + qcom,level = <1>; > + }; > + > + rpmpd_opp2: opp@2 { > + opp-hz = /bits/ 64 <2>; > + qcom,level = <2>; > + }; > + > + rpmpd_opp3: opp@3 { > + opp-hz = /bits/ 64 <3>; > + qcom,level = <3>; > + }; > + > + rpmpd_opp4: opp@4 { > + opp-hz = /bits/ 64 <4>; > + qcom,level = <4>; > + }; > + > + rpmpd_opp5: opp@5 { > + opp-hz = /bits/ 64 <5>; > + qcom,level = <5>; > + }; > + > + rpmpd_opp6: opp@6 { > + opp-hz = /bits/ 64 <6>; > + qcom,level = <6>; > + }; > + }; > + > pm8994-regulators { > compatible = "qcom,rpm-pm8994-regulators"; > Everything else is fine. After you remove the opp-hz property from this table: Acked-by: Viresh Kumar -- viresh
Re: [PATCH 4/7] soc: qcom: rpmpd: Add support for get/set performance state
On 16-03-18, 09:38, Rajendra Nayak wrote: > With genpd now expecting powerdomain drivers supporting performance > state to support get/set performance state callbacks, add support for it > in the rpmpd driver. > > Signed-off-by: Rajendra Nayak> Signed-off-by: Viresh Kumar > --- > drivers/soc/qcom/rpmpd.c | 42 ++ > 1 file changed, 42 insertions(+) > > diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c > index c8754d867c33..4058c5b450c6 100644 > --- a/drivers/soc/qcom/rpmpd.c > +++ b/drivers/soc/qcom/rpmpd.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include > #include > > #include > @@ -29,6 +30,8 @@ > #define KEY_ENABLE 0x6e657773 /* swen */ > #define KEY_FLOOR_CORNER 0x636676 /* vfc */ > > +#define MAX_RPMPD_STATE 6 > + > #define DEFINE_RPMPD_CORN_SMPA(_platform, _name, _active, r_id) > \ > static struct rpmpd _platform##_##_active; \ > static struct rpmpd _platform##_##_name = { \ > @@ -222,6 +225,43 @@ static int rpmpd_power_off(struct generic_pm_domain > *domain) > return ret; > } > > +static int rpmpd_set_performance(struct generic_pm_domain *domain, > + unsigned int state) > +{ > + int ret = 0; > + struct rpmpd *pd = domain_to_rpmpd(domain); > + > + mutex_lock(_lock); > + > + if (state > MAX_RPMPD_STATE) > + goto out; > + > + pd->corner = state; > + > + if (!pd->enabled && (pd->key != KEY_FLOOR_CORNER)) > + goto out; > + > + ret = rpmpd_aggregate_corner(pd); > + > +out: > + mutex_unlock(_lock); > + > + return ret; > +} > + > +static unsigned int rpmpd_get_performance(struct generic_pm_domain *genpd, > + struct dev_pm_opp *opp) > +{ > + struct device_node *np; > + unsigned int corner = 0; > + > + np = dev_pm_opp_get_of_node(opp); > + of_property_read_u32(np, "qcom,level", ); Don't we want to error out or do something else in case of an error ? > + of_node_put(np); > + > + return corner; > +} > + > static int rpmpd_probe(struct platform_device *pdev) > { > int i; > @@ -259,6 +299,8 @@ static int rpmpd_probe(struct platform_device *pdev) > rpmpds[i]->rpm = rpm; > rpmpds[i]->pd.power_off = rpmpd_power_off; > rpmpds[i]->pd.power_on = rpmpd_power_on; > + rpmpds[i]->pd.set_performance_state = rpmpd_set_performance; > + rpmpds[i]->pd.get_performance_state = rpmpd_get_performance; > pm_genpd_init([i]->pd, NULL, true); > > data->domains[i] = [i]->pd; Acked-by: Viresh Kumar -- viresh
Re: [PATCH 4/7] soc: qcom: rpmpd: Add support for get/set performance state
On 16-03-18, 09:38, Rajendra Nayak wrote: > With genpd now expecting powerdomain drivers supporting performance > state to support get/set performance state callbacks, add support for it > in the rpmpd driver. > > Signed-off-by: Rajendra Nayak > Signed-off-by: Viresh Kumar > --- > drivers/soc/qcom/rpmpd.c | 42 ++ > 1 file changed, 42 insertions(+) > > diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c > index c8754d867c33..4058c5b450c6 100644 > --- a/drivers/soc/qcom/rpmpd.c > +++ b/drivers/soc/qcom/rpmpd.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include > #include > > #include > @@ -29,6 +30,8 @@ > #define KEY_ENABLE 0x6e657773 /* swen */ > #define KEY_FLOOR_CORNER 0x636676 /* vfc */ > > +#define MAX_RPMPD_STATE 6 > + > #define DEFINE_RPMPD_CORN_SMPA(_platform, _name, _active, r_id) > \ > static struct rpmpd _platform##_##_active; \ > static struct rpmpd _platform##_##_name = { \ > @@ -222,6 +225,43 @@ static int rpmpd_power_off(struct generic_pm_domain > *domain) > return ret; > } > > +static int rpmpd_set_performance(struct generic_pm_domain *domain, > + unsigned int state) > +{ > + int ret = 0; > + struct rpmpd *pd = domain_to_rpmpd(domain); > + > + mutex_lock(_lock); > + > + if (state > MAX_RPMPD_STATE) > + goto out; > + > + pd->corner = state; > + > + if (!pd->enabled && (pd->key != KEY_FLOOR_CORNER)) > + goto out; > + > + ret = rpmpd_aggregate_corner(pd); > + > +out: > + mutex_unlock(_lock); > + > + return ret; > +} > + > +static unsigned int rpmpd_get_performance(struct generic_pm_domain *genpd, > + struct dev_pm_opp *opp) > +{ > + struct device_node *np; > + unsigned int corner = 0; > + > + np = dev_pm_opp_get_of_node(opp); > + of_property_read_u32(np, "qcom,level", ); Don't we want to error out or do something else in case of an error ? > + of_node_put(np); > + > + return corner; > +} > + > static int rpmpd_probe(struct platform_device *pdev) > { > int i; > @@ -259,6 +299,8 @@ static int rpmpd_probe(struct platform_device *pdev) > rpmpds[i]->rpm = rpm; > rpmpds[i]->pd.power_off = rpmpd_power_off; > rpmpds[i]->pd.power_on = rpmpd_power_on; > + rpmpds[i]->pd.set_performance_state = rpmpd_set_performance; > + rpmpds[i]->pd.get_performance_state = rpmpd_get_performance; > pm_genpd_init([i]->pd, NULL, true); > > data->domains[i] = [i]->pd; Acked-by: Viresh Kumar -- viresh
Re: [PATCH 3/7] dt-bindings: opp: Introduce qcom-opp bindings
On 16-03-18, 09:38, Rajendra Nayak wrote: > On Qualcomm platforms, an OPP node needs to describe an > additional level/corner value that is then communicated to > a remote microprocessor by the CPU, which then takes some > actions (like adjusting voltage values across various rails) > based on the value passed. > > Describe these bindings in the qcom-opp bindings document. > > Signed-off-by: Rajendra Nayak> --- > Documentation/devicetree/bindings/opp/qcom-opp.txt | 25 > ++ > 1 file changed, 25 insertions(+) > create mode 100644 Documentation/devicetree/bindings/opp/qcom-opp.txt > > diff --git a/Documentation/devicetree/bindings/opp/qcom-opp.txt > b/Documentation/devicetree/bindings/opp/qcom-opp.txt > new file mode 100644 > index ..56fe87751881 > --- /dev/null > +++ b/Documentation/devicetree/bindings/opp/qcom-opp.txt > @@ -0,0 +1,25 @@ > +Qualcomm OPP bindings to descibe OPP nodes with corner/level values > + > +OPP tables for devices on qualcomm platforms require an additional > +platform specific corner/level value to be specified. > +This value is passed on to the RPM (Resource Power Manager) by > +the CPU, which then takes the necessary actions to set a voltage > +rail to a appropriate voltage based on the value passed. > + > +The bindings are based on top of the operating-points-v2 bindings > +described in Documentation/devicetree/bindings/opp/opp.txt > +Additional properties are described below. > + > +* OPP Table Node > + > +Required properties: > +- compatible: Allow OPPs to express their compatibility. It should be: > + "operating-points-v2-qcom" > + > +* OPP Node > + > +Required properties: > +- qcom,level: On Qualcomm platforms an OPP node can describe a positive value > +representing a corner/level thats comminicated with a remote microprocessor > +(Usually called the RPM) which then translates it into a certain voltage on > +a voltage rail. Acked-by: Viresh Kumar -- viresh
Re: [PATCH 3/7] dt-bindings: opp: Introduce qcom-opp bindings
On 16-03-18, 09:38, Rajendra Nayak wrote: > On Qualcomm platforms, an OPP node needs to describe an > additional level/corner value that is then communicated to > a remote microprocessor by the CPU, which then takes some > actions (like adjusting voltage values across various rails) > based on the value passed. > > Describe these bindings in the qcom-opp bindings document. > > Signed-off-by: Rajendra Nayak > --- > Documentation/devicetree/bindings/opp/qcom-opp.txt | 25 > ++ > 1 file changed, 25 insertions(+) > create mode 100644 Documentation/devicetree/bindings/opp/qcom-opp.txt > > diff --git a/Documentation/devicetree/bindings/opp/qcom-opp.txt > b/Documentation/devicetree/bindings/opp/qcom-opp.txt > new file mode 100644 > index ..56fe87751881 > --- /dev/null > +++ b/Documentation/devicetree/bindings/opp/qcom-opp.txt > @@ -0,0 +1,25 @@ > +Qualcomm OPP bindings to descibe OPP nodes with corner/level values > + > +OPP tables for devices on qualcomm platforms require an additional > +platform specific corner/level value to be specified. > +This value is passed on to the RPM (Resource Power Manager) by > +the CPU, which then takes the necessary actions to set a voltage > +rail to a appropriate voltage based on the value passed. > + > +The bindings are based on top of the operating-points-v2 bindings > +described in Documentation/devicetree/bindings/opp/opp.txt > +Additional properties are described below. > + > +* OPP Table Node > + > +Required properties: > +- compatible: Allow OPPs to express their compatibility. It should be: > + "operating-points-v2-qcom" > + > +* OPP Node > + > +Required properties: > +- qcom,level: On Qualcomm platforms an OPP node can describe a positive value > +representing a corner/level thats comminicated with a remote microprocessor > +(Usually called the RPM) which then translates it into a certain voltage on > +a voltage rail. Acked-by: Viresh Kumar -- viresh
[PATCH v2] rbd: Remove VLA usage
As part of the effort to remove VLAs from the kernel[1], this moves the literal values into the stack array calculation instead of using a variable for the sizing. The resulting size can be found from sizeof(buf). [1] https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Kyle Spiers--- drivers/block/rbd.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 8e40da0..0e94e1f 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -3100,8 +3100,8 @@ static int __rbd_notify_op_lock(struct rbd_device *rbd_dev, { struct ceph_osd_client *osdc = _dev->rbd_client->client->osdc; struct rbd_client_id cid = rbd_get_cid(rbd_dev); - int buf_size = 4 + 8 + 8 + CEPH_ENCODING_START_BLK_LEN; - char buf[buf_size]; + char buf[4 + 4 + 8 + 8 + CEPH_ENCODING_START_BLK_LEN]; + int buf_size = sizeof(buf) void *p = buf; dout("%s rbd_dev %p notify_op %d\n", __func__, rbd_dev, notify_op); @@ -3619,8 +3619,8 @@ static void __rbd_acknowledge_notify(struct rbd_device *rbd_dev, u64 notify_id, u64 cookie, s32 *result) { struct ceph_osd_client *osdc = _dev->rbd_client->client->osdc; - int buf_size = 4 + CEPH_ENCODING_START_BLK_LEN; - char buf[buf_size]; + char buf[4 + CEPH_ENCODING_START_BLK_LEN]; + int buf_size = sizeof(buf); int ret; if (result) { -- 2.7.4
[PATCH v2] rbd: Remove VLA usage
As part of the effort to remove VLAs from the kernel[1], this moves the literal values into the stack array calculation instead of using a variable for the sizing. The resulting size can be found from sizeof(buf). [1] https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Kyle Spiers --- drivers/block/rbd.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 8e40da0..0e94e1f 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -3100,8 +3100,8 @@ static int __rbd_notify_op_lock(struct rbd_device *rbd_dev, { struct ceph_osd_client *osdc = _dev->rbd_client->client->osdc; struct rbd_client_id cid = rbd_get_cid(rbd_dev); - int buf_size = 4 + 8 + 8 + CEPH_ENCODING_START_BLK_LEN; - char buf[buf_size]; + char buf[4 + 4 + 8 + 8 + CEPH_ENCODING_START_BLK_LEN]; + int buf_size = sizeof(buf) void *p = buf; dout("%s rbd_dev %p notify_op %d\n", __func__, rbd_dev, notify_op); @@ -3619,8 +3619,8 @@ static void __rbd_acknowledge_notify(struct rbd_device *rbd_dev, u64 notify_id, u64 cookie, s32 *result) { struct ceph_osd_client *osdc = _dev->rbd_client->client->osdc; - int buf_size = 4 + CEPH_ENCODING_START_BLK_LEN; - char buf[buf_size]; + char buf[4 + CEPH_ENCODING_START_BLK_LEN]; + int buf_size = sizeof(buf); int ret; if (result) { -- 2.7.4
[PATCH v5 0/2] Remove false-positive VLAs when using max()
Patch 1 adds const_max_t(), patch 2 uses it in all the places max() was used for stack arrays. Commit log from patch 1: ---snip--- kernel.h: Introduce const_max_t() for VLA removal In the effort to remove all VLAs from the kernel[1], it is desirable to build with -Wvla. However, this warning is overly pessimistic, in that it is only happy with stack array sizes that are declared as constant expressions, and not constant values. One case of this is the evaluation of the max() macro which, due to its construction, ends up converting constant expression arguments into a constant value result. Attempts to adjust the behavior of max() ran afoul of version-dependent compiler behavior[2]. To work around this and still gain -Wvla coverage, this patch introduces a new macro, const_max_t(), for use in these cases of stack array size declaration, where the constant expressions are retained. Since this means losing the double-evaluation protections of the max() macro, this macro is designed to explicitly fail if used on non-constant arguments. Older compilers will fail with the unhelpful message: error: first argument to ‘__builtin_choose_expr’ not a constant Newer compilers will fail with a hopefully more helpful message: error: call to ‘__error_non_const_arg’ declared with attribute error: const_max_t() used with non-constant expression To gain the ability to compare differing types, the desired type must be explicitly declared, as with the existing max_t() macro. This is needed when comparing different enum types and to allow things like: int foo[const_max_t(size_t, 6, sizeof(something))]; [1] https://lkml.org/lkml/2018/3/7/621 [2] https://lkml.org/lkml/2018/3/10/170 ---eol--- Hopefully this reads well as a summary from all the things that got tried. I've tested this on allmodconfig builds with gcc 4.4.4 and 6.3.0, with and without -Wvla. -Kees v5: explicit type argument v4: forced size_t type
[PATCH v5 0/2] Remove false-positive VLAs when using max()
Patch 1 adds const_max_t(), patch 2 uses it in all the places max() was used for stack arrays. Commit log from patch 1: ---snip--- kernel.h: Introduce const_max_t() for VLA removal In the effort to remove all VLAs from the kernel[1], it is desirable to build with -Wvla. However, this warning is overly pessimistic, in that it is only happy with stack array sizes that are declared as constant expressions, and not constant values. One case of this is the evaluation of the max() macro which, due to its construction, ends up converting constant expression arguments into a constant value result. Attempts to adjust the behavior of max() ran afoul of version-dependent compiler behavior[2]. To work around this and still gain -Wvla coverage, this patch introduces a new macro, const_max_t(), for use in these cases of stack array size declaration, where the constant expressions are retained. Since this means losing the double-evaluation protections of the max() macro, this macro is designed to explicitly fail if used on non-constant arguments. Older compilers will fail with the unhelpful message: error: first argument to ‘__builtin_choose_expr’ not a constant Newer compilers will fail with a hopefully more helpful message: error: call to ‘__error_non_const_arg’ declared with attribute error: const_max_t() used with non-constant expression To gain the ability to compare differing types, the desired type must be explicitly declared, as with the existing max_t() macro. This is needed when comparing different enum types and to allow things like: int foo[const_max_t(size_t, 6, sizeof(something))]; [1] https://lkml.org/lkml/2018/3/7/621 [2] https://lkml.org/lkml/2018/3/10/170 ---eol--- Hopefully this reads well as a summary from all the things that got tried. I've tested this on allmodconfig builds with gcc 4.4.4 and 6.3.0, with and without -Wvla. -Kees v5: explicit type argument v4: forced size_t type
[PATCH v5 2/2] Remove false-positive VLAs when using max()
As part of removing VLAs from the kernel[1], we want to build with -Wvla, but it is overly pessimistic and only accepts constant expressions for stack array sizes, instead of also constant values. The max() macro triggers the warning, so this refactors these uses of max() to use the new const_max() instead. [1] https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Kees Cook--- drivers/input/touchscreen/cyttsp4_core.c | 2 +- fs/btrfs/tree-checker.c | 3 ++- lib/vsprintf.c | 5 +++-- net/ipv4/proc.c | 8 net/ipv6/proc.c | 11 +-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c index 727c3232517c..7fb9bd48e41c 100644 --- a/drivers/input/touchscreen/cyttsp4_core.c +++ b/drivers/input/touchscreen/cyttsp4_core.c @@ -868,7 +868,7 @@ static void cyttsp4_get_mt_touches(struct cyttsp4_mt_data *md, int num_cur_tch) struct cyttsp4_touch tch; int sig; int i, j, t = 0; - int ids[max(CY_TMA1036_MAX_TCH, CY_TMA4XX_MAX_TCH)]; + int ids[const_max_t(size_t, CY_TMA1036_MAX_TCH, CY_TMA4XX_MAX_TCH)]; memset(ids, 0, si->si_ofs.tch_abs[CY_TCH_T].max * sizeof(int)); for (i = 0; i < num_cur_tch; i++) { diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c index c3c8d48f6618..d83244e3821f 100644 --- a/fs/btrfs/tree-checker.c +++ b/fs/btrfs/tree-checker.c @@ -341,7 +341,8 @@ static int check_dir_item(struct btrfs_root *root, */ if (key->type == BTRFS_DIR_ITEM_KEY || key->type == BTRFS_XATTR_ITEM_KEY) { - char namebuf[max(BTRFS_NAME_LEN, XATTR_NAME_MAX)]; + char namebuf[const_max_t(size_t, BTRFS_NAME_LEN, +XATTR_NAME_MAX)]; read_extent_buffer(leaf, namebuf, (unsigned long)(di + 1), name_len); diff --git a/lib/vsprintf.c b/lib/vsprintf.c index d7a708f82559..12ff57a36171 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -744,8 +744,9 @@ char *resource_string(char *buf, char *end, struct resource *res, #define FLAG_BUF_SIZE (2 * sizeof(res->flags)) #define DECODED_BUF_SIZE sizeof("[mem - 64bit pref window disabled]") #define RAW_BUF_SIZE sizeof("[mem - flags 0x]") - char sym[max(2*RSRC_BUF_SIZE + DECODED_BUF_SIZE, -2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)]; + char sym[const_max_t(size_t, +2*RSRC_BUF_SIZE + DECODED_BUF_SIZE, +2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)]; char *p = sym, *pend = sym + sizeof(sym); int decode = (fmt[0] == 'R') ? 1 : 0; diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index dc5edc8f7564..7f5c3b40dac9 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c @@ -46,7 +46,7 @@ #include #include -#define TCPUDP_MIB_MAX max_t(u32, UDP_MIB_MAX, TCP_MIB_MAX) +#define TCPUDP_MIB_MAX const_max_t(size_t, UDP_MIB_MAX, TCP_MIB_MAX) /* * Report socket allocation statistics [m...@utu.fi] @@ -404,7 +404,7 @@ static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v) struct net *net = seq->private; int i; - memset(buff, 0, TCPUDP_MIB_MAX * sizeof(unsigned long)); + memset(buff, 0, sizeof(buff)); seq_puts(seq, "\nTcp:"); for (i = 0; snmp4_tcp_list[i].name; i++) @@ -421,7 +421,7 @@ static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v) seq_printf(seq, " %lu", buff[i]); } - memset(buff, 0, TCPUDP_MIB_MAX * sizeof(unsigned long)); + memset(buff, 0, sizeof(buff)); snmp_get_cpu_field_batch(buff, snmp4_udp_list, net->mib.udp_statistics); @@ -432,7 +432,7 @@ static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v) for (i = 0; snmp4_udp_list[i].name; i++) seq_printf(seq, " %lu", buff[i]); - memset(buff, 0, TCPUDP_MIB_MAX * sizeof(unsigned long)); + memset(buff, 0, sizeof(buff)); /* the UDP and UDP-Lite MIBs are the same */ seq_puts(seq, "\nUdpLite:"); diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index b67814242f78..b68c233de296 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c @@ -30,10 +30,9 @@ #include #include -#define MAX4(a, b, c, d) \ - max_t(u32, max_t(u32, a, b), max_t(u32, c, d)) -#define SNMP_MIB_MAX MAX4(UDP_MIB_MAX, TCP_MIB_MAX, \ - IPSTATS_MIB_MAX, ICMP_MIB_MAX) +#define SNMP_MIB_MAX const_max_t(u32, \ + const_max_t(u32, UDP_MIB_MAX, TCP_MIB_MAX), \ + const_max_t(u32, IPSTATS_MIB_MAX, ICMP_MIB_MAX)) static int
[PATCH v5 2/2] Remove false-positive VLAs when using max()
As part of removing VLAs from the kernel[1], we want to build with -Wvla, but it is overly pessimistic and only accepts constant expressions for stack array sizes, instead of also constant values. The max() macro triggers the warning, so this refactors these uses of max() to use the new const_max() instead. [1] https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Kees Cook --- drivers/input/touchscreen/cyttsp4_core.c | 2 +- fs/btrfs/tree-checker.c | 3 ++- lib/vsprintf.c | 5 +++-- net/ipv4/proc.c | 8 net/ipv6/proc.c | 11 +-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c index 727c3232517c..7fb9bd48e41c 100644 --- a/drivers/input/touchscreen/cyttsp4_core.c +++ b/drivers/input/touchscreen/cyttsp4_core.c @@ -868,7 +868,7 @@ static void cyttsp4_get_mt_touches(struct cyttsp4_mt_data *md, int num_cur_tch) struct cyttsp4_touch tch; int sig; int i, j, t = 0; - int ids[max(CY_TMA1036_MAX_TCH, CY_TMA4XX_MAX_TCH)]; + int ids[const_max_t(size_t, CY_TMA1036_MAX_TCH, CY_TMA4XX_MAX_TCH)]; memset(ids, 0, si->si_ofs.tch_abs[CY_TCH_T].max * sizeof(int)); for (i = 0; i < num_cur_tch; i++) { diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c index c3c8d48f6618..d83244e3821f 100644 --- a/fs/btrfs/tree-checker.c +++ b/fs/btrfs/tree-checker.c @@ -341,7 +341,8 @@ static int check_dir_item(struct btrfs_root *root, */ if (key->type == BTRFS_DIR_ITEM_KEY || key->type == BTRFS_XATTR_ITEM_KEY) { - char namebuf[max(BTRFS_NAME_LEN, XATTR_NAME_MAX)]; + char namebuf[const_max_t(size_t, BTRFS_NAME_LEN, +XATTR_NAME_MAX)]; read_extent_buffer(leaf, namebuf, (unsigned long)(di + 1), name_len); diff --git a/lib/vsprintf.c b/lib/vsprintf.c index d7a708f82559..12ff57a36171 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -744,8 +744,9 @@ char *resource_string(char *buf, char *end, struct resource *res, #define FLAG_BUF_SIZE (2 * sizeof(res->flags)) #define DECODED_BUF_SIZE sizeof("[mem - 64bit pref window disabled]") #define RAW_BUF_SIZE sizeof("[mem - flags 0x]") - char sym[max(2*RSRC_BUF_SIZE + DECODED_BUF_SIZE, -2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)]; + char sym[const_max_t(size_t, +2*RSRC_BUF_SIZE + DECODED_BUF_SIZE, +2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)]; char *p = sym, *pend = sym + sizeof(sym); int decode = (fmt[0] == 'R') ? 1 : 0; diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index dc5edc8f7564..7f5c3b40dac9 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c @@ -46,7 +46,7 @@ #include #include -#define TCPUDP_MIB_MAX max_t(u32, UDP_MIB_MAX, TCP_MIB_MAX) +#define TCPUDP_MIB_MAX const_max_t(size_t, UDP_MIB_MAX, TCP_MIB_MAX) /* * Report socket allocation statistics [m...@utu.fi] @@ -404,7 +404,7 @@ static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v) struct net *net = seq->private; int i; - memset(buff, 0, TCPUDP_MIB_MAX * sizeof(unsigned long)); + memset(buff, 0, sizeof(buff)); seq_puts(seq, "\nTcp:"); for (i = 0; snmp4_tcp_list[i].name; i++) @@ -421,7 +421,7 @@ static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v) seq_printf(seq, " %lu", buff[i]); } - memset(buff, 0, TCPUDP_MIB_MAX * sizeof(unsigned long)); + memset(buff, 0, sizeof(buff)); snmp_get_cpu_field_batch(buff, snmp4_udp_list, net->mib.udp_statistics); @@ -432,7 +432,7 @@ static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v) for (i = 0; snmp4_udp_list[i].name; i++) seq_printf(seq, " %lu", buff[i]); - memset(buff, 0, TCPUDP_MIB_MAX * sizeof(unsigned long)); + memset(buff, 0, sizeof(buff)); /* the UDP and UDP-Lite MIBs are the same */ seq_puts(seq, "\nUdpLite:"); diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index b67814242f78..b68c233de296 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c @@ -30,10 +30,9 @@ #include #include -#define MAX4(a, b, c, d) \ - max_t(u32, max_t(u32, a, b), max_t(u32, c, d)) -#define SNMP_MIB_MAX MAX4(UDP_MIB_MAX, TCP_MIB_MAX, \ - IPSTATS_MIB_MAX, ICMP_MIB_MAX) +#define SNMP_MIB_MAX const_max_t(u32, \ + const_max_t(u32, UDP_MIB_MAX, TCP_MIB_MAX), \ + const_max_t(u32, IPSTATS_MIB_MAX, ICMP_MIB_MAX)) static int sockstat6_seq_show(struct seq_file *seq,
[PATCH v5 1/2] kernel.h: Introduce const_max_t() for VLA removal
In the effort to remove all VLAs from the kernel[1], it is desirable to build with -Wvla. However, this warning is overly pessimistic, in that it is only happy with stack array sizes that are declared as constant expressions, and not constant values. One case of this is the evaluation of the max() macro which, due to its construction, ends up converting constant expression arguments into a constant value result. Attempts to adjust the behavior of max() ran afoul of version-dependent compiler behavior[2]. To work around this and still gain -Wvla coverage, this patch introduces a new macro, const_max_t(), for use in these cases of stack array size declaration, where the constant expressions are retained. Since this means losing the double-evaluation protections of the max() macro, this macro is designed to explicitly fail if used on non-constant arguments. Older compilers will fail with the unhelpful message: error: first argument to ‘__builtin_choose_expr’ not a constant Newer compilers will fail with a hopefully more helpful message: error: call to ‘__error_non_const_arg’ declared with attribute error: const_max_t() used with non-constant expression To gain the ability to compare differing types, the desired type must be explicitly declared, as with the existing max_t() macro. This is needed when comparing different enum types and to allow things like: int foo[const_max_t(size_t, 6, sizeof(something))]; [1] https://lkml.org/lkml/2018/3/7/621 [2] https://lkml.org/lkml/2018/3/10/170 Signed-off-by: Kees Cook--- include/linux/kernel.h | 19 +++ 1 file changed, 19 insertions(+) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 3fd291503576..e14531781568 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -820,6 +820,25 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } x, y) /** + * const_max_t - return maximum of two compile-time constant expressions + * @type: type used for evaluation + * @x: first compile-time constant expression + * @y: second compile-time constant expression + * + * This has no multi-evaluation defenses, and must only ever be used with + * compile-time constant expressions (for example when calculating a stack + * array size). + */ +size_t __error_non_const_arg(void) \ +__compiletime_error("const_max_t() used with non-constant expression"); +#define const_max_t(type, x, y)\ + __builtin_choose_expr(__builtin_constant_p(x) &&\ + __builtin_constant_p(y), \ + (type)(x) > (type)(y) ? \ + (type)(x) : (type)(y), \ + __error_non_const_arg()) + +/** * min3 - return minimum of three values * @x: first value * @y: second value -- 2.7.4
[PATCH v5 1/2] kernel.h: Introduce const_max_t() for VLA removal
In the effort to remove all VLAs from the kernel[1], it is desirable to build with -Wvla. However, this warning is overly pessimistic, in that it is only happy with stack array sizes that are declared as constant expressions, and not constant values. One case of this is the evaluation of the max() macro which, due to its construction, ends up converting constant expression arguments into a constant value result. Attempts to adjust the behavior of max() ran afoul of version-dependent compiler behavior[2]. To work around this and still gain -Wvla coverage, this patch introduces a new macro, const_max_t(), for use in these cases of stack array size declaration, where the constant expressions are retained. Since this means losing the double-evaluation protections of the max() macro, this macro is designed to explicitly fail if used on non-constant arguments. Older compilers will fail with the unhelpful message: error: first argument to ‘__builtin_choose_expr’ not a constant Newer compilers will fail with a hopefully more helpful message: error: call to ‘__error_non_const_arg’ declared with attribute error: const_max_t() used with non-constant expression To gain the ability to compare differing types, the desired type must be explicitly declared, as with the existing max_t() macro. This is needed when comparing different enum types and to allow things like: int foo[const_max_t(size_t, 6, sizeof(something))]; [1] https://lkml.org/lkml/2018/3/7/621 [2] https://lkml.org/lkml/2018/3/10/170 Signed-off-by: Kees Cook --- include/linux/kernel.h | 19 +++ 1 file changed, 19 insertions(+) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 3fd291503576..e14531781568 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -820,6 +820,25 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } x, y) /** + * const_max_t - return maximum of two compile-time constant expressions + * @type: type used for evaluation + * @x: first compile-time constant expression + * @y: second compile-time constant expression + * + * This has no multi-evaluation defenses, and must only ever be used with + * compile-time constant expressions (for example when calculating a stack + * array size). + */ +size_t __error_non_const_arg(void) \ +__compiletime_error("const_max_t() used with non-constant expression"); +#define const_max_t(type, x, y)\ + __builtin_choose_expr(__builtin_constant_p(x) &&\ + __builtin_constant_p(y), \ + (type)(x) > (type)(y) ? \ + (type)(x) : (type)(y), \ + __error_non_const_arg()) + +/** * min3 - return minimum of three values * @x: first value * @y: second value -- 2.7.4
Re: [PATCH][RFC] kernel.h: provide array iterator
On Thu, Mar 15, 2018 at 3:00 AM, Kieran Binghamwrote: > Simplify array iteration with a helper to iterate each entry in an array. > Utilise the existing ARRAY_SIZE macro to identify the length of the array > and pointer arithmetic to process each item as a for loop. > > Signed-off-by: Kieran Bingham > --- > include/linux/kernel.h | 10 ++ > 1 file changed, 10 insertions(+) > > The use of static arrays to store data is a common use case throughout the > kernel. Along with that is the obvious need to iterate that data. > > In fact there are just shy of 5000 instances of iterating a static array: > git grep "for .*ARRAY_SIZE" | wc -l > 4943 I suspect the main question is "Does this macro make the code easier to read?" I think it does, and we have other kinds of iterators like this in the kernel already. Would it be worth building a Coccinelle script to do the 5000 replacements? -Kees > > When working on the UVC driver - I found that I needed to split one such > iteration into two parts, and at the same time felt that this could be > refactored to be cleaner / easier to read. > > I do however worry that this simple short patch might not be desired or could > also be heavily bikeshedded due to it's potential wide spread use (though > perhaps that would be a good thing to have more users) ... but here it is, > along with an example usage below which is part of a separate series. > > The aim is to simplify iteration on static arrays, in the same way that we > have > iterators for lists. The use of the ARRAY_SIZE macro, provides all the > protections given by "__must_be_array(arr)" to this macro too. > > Regards > > Kieran > > = > Example Usage from a pending UVC development: > > +#define for_each_uvc_urb(uvc_urb, uvc_streaming) \ > + for_each_array_element(uvc_urb, uvc_streaming->uvc_urb) > > /* > * Uninitialize isochronous/bulk URBs and free transfer buffers. > */ > static void uvc_uninit_video(struct uvc_streaming *stream, int free_buffers) > { > - struct urb *urb; > - unsigned int i; > + struct uvc_urb *uvc_urb; > > uvc_video_stats_stop(stream); > > - for (i = 0; i < UVC_URBS; ++i) { > - struct uvc_urb *uvc_urb = >uvc_urb[i]; > + for_each_uvc_urb(uvc_urb, stream) > + usb_kill_urb(uvc_urb->urb); > > - urb = uvc_urb->urb; > - if (urb == NULL) > - continue; > + flush_workqueue(stream->async_wq); > > - usb_kill_urb(urb); > - usb_free_urb(urb); > + for_each_uvc_urb(uvc_urb, stream) { > + usb_free_urb(uvc_urb->urb); > uvc_urb->urb = NULL; > } > > if (free_buffers) > uvc_free_urb_buffers(stream); > } > = > > > > > diff --git a/include/linux/kernel.h b/include/linux/kernel.h > index ce51455e2adf..95d7dae248b7 100644 > --- a/include/linux/kernel.h > +++ b/include/linux/kernel.h > @@ -70,6 +70,16 @@ > */ > #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + > __must_be_array(arr)) > > +/** > + * for_each_array_element - Iterate all items in an array > + * @elem: pointer of array type for iteration cursor > + * @array: array to be iterated > + */ > +#define for_each_array_element(elem, array) \ > + for (elem = &(array)[0]; \ > +elem < &(array)[ARRAY_SIZE(array)]; \ > +++elem) > + > #define u64_to_user_ptr(x) ( \ > { \ > typecheck(u64, x); \ > -- > 2.7.4 > -- Kees Cook Pixel Security
Re: [PATCH][RFC] kernel.h: provide array iterator
On Thu, Mar 15, 2018 at 3:00 AM, Kieran Bingham wrote: > Simplify array iteration with a helper to iterate each entry in an array. > Utilise the existing ARRAY_SIZE macro to identify the length of the array > and pointer arithmetic to process each item as a for loop. > > Signed-off-by: Kieran Bingham > --- > include/linux/kernel.h | 10 ++ > 1 file changed, 10 insertions(+) > > The use of static arrays to store data is a common use case throughout the > kernel. Along with that is the obvious need to iterate that data. > > In fact there are just shy of 5000 instances of iterating a static array: > git grep "for .*ARRAY_SIZE" | wc -l > 4943 I suspect the main question is "Does this macro make the code easier to read?" I think it does, and we have other kinds of iterators like this in the kernel already. Would it be worth building a Coccinelle script to do the 5000 replacements? -Kees > > When working on the UVC driver - I found that I needed to split one such > iteration into two parts, and at the same time felt that this could be > refactored to be cleaner / easier to read. > > I do however worry that this simple short patch might not be desired or could > also be heavily bikeshedded due to it's potential wide spread use (though > perhaps that would be a good thing to have more users) ... but here it is, > along with an example usage below which is part of a separate series. > > The aim is to simplify iteration on static arrays, in the same way that we > have > iterators for lists. The use of the ARRAY_SIZE macro, provides all the > protections given by "__must_be_array(arr)" to this macro too. > > Regards > > Kieran > > = > Example Usage from a pending UVC development: > > +#define for_each_uvc_urb(uvc_urb, uvc_streaming) \ > + for_each_array_element(uvc_urb, uvc_streaming->uvc_urb) > > /* > * Uninitialize isochronous/bulk URBs and free transfer buffers. > */ > static void uvc_uninit_video(struct uvc_streaming *stream, int free_buffers) > { > - struct urb *urb; > - unsigned int i; > + struct uvc_urb *uvc_urb; > > uvc_video_stats_stop(stream); > > - for (i = 0; i < UVC_URBS; ++i) { > - struct uvc_urb *uvc_urb = >uvc_urb[i]; > + for_each_uvc_urb(uvc_urb, stream) > + usb_kill_urb(uvc_urb->urb); > > - urb = uvc_urb->urb; > - if (urb == NULL) > - continue; > + flush_workqueue(stream->async_wq); > > - usb_kill_urb(urb); > - usb_free_urb(urb); > + for_each_uvc_urb(uvc_urb, stream) { > + usb_free_urb(uvc_urb->urb); > uvc_urb->urb = NULL; > } > > if (free_buffers) > uvc_free_urb_buffers(stream); > } > = > > > > > diff --git a/include/linux/kernel.h b/include/linux/kernel.h > index ce51455e2adf..95d7dae248b7 100644 > --- a/include/linux/kernel.h > +++ b/include/linux/kernel.h > @@ -70,6 +70,16 @@ > */ > #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + > __must_be_array(arr)) > > +/** > + * for_each_array_element - Iterate all items in an array > + * @elem: pointer of array type for iteration cursor > + * @array: array to be iterated > + */ > +#define for_each_array_element(elem, array) \ > + for (elem = &(array)[0]; \ > +elem < &(array)[ARRAY_SIZE(array)]; \ > +++elem) > + > #define u64_to_user_ptr(x) ( \ > { \ > typecheck(u64, x); \ > -- > 2.7.4 > -- Kees Cook Pixel Security
Re: [PATCH v10] mmc: Export host capabilities to debugfs.
On Thursday 15 March 2018 05:59 PM, Ulf Hansson wrote: > On 15 March 2018 at 11:26, Andy Shevchenko >wrote: >> On Thu, 2018-03-15 at 11:12 +0100, Ulf Hansson wrote: >>> On 13 March 2018 at 06:10, Harish Jenny K N >> Honestly, I don't like this, but maybe other people do, then I am fine >>> with this approach. >>> >>> If were to decide, I would just rather print the caps field in a >>> hexadecimal bit form and leave the translation to the user. >> A compromise would be to print both: >> >> 0x\n >> Description of each enabled field, one per line >> >> >> Another format would be: >> >> Bit XX: Description of a field > If we were to print the description, there is no point in printing the > bits in hex. Or is it? Yes. I also do not see the use of printing hex value if we are printing the description. > > As I said, if you and other folkz thinks this is valuable, then I am > fine as well. Just saying, it's not my preferred option. > > I just want to inform that the idea of printing the description came after discussion in https://www.spinics.net/lists/linux-mmc/msg48246.html, where it was decided adding utility in mmc-utils was not going to work ( reason: We may very well be changing the bit offsets for the caps and caps2 in the mmc kernel header, keeping a copy of them is not a good idea. It's just a matter of *when* it will break). On Thu, 2018-03-15 at 11:12 +0100, Ulf Hansson wrote: > If were to decide, I would just rather print the caps field in a hexadecimal > bit form and leave the translation to the user. I think translation becomes difficult for the above reason and hence I would prefer printing the description. Note: Printing values in Hex was the original idea and it is also available in https://www.spinics.net/lists/linux-mmc/msg48213.html just in case if it is required. Thanks & Regards, Harish Jenny K N
Re: [PATCH v10] mmc: Export host capabilities to debugfs.
On Thursday 15 March 2018 05:59 PM, Ulf Hansson wrote: > On 15 March 2018 at 11:26, Andy Shevchenko > wrote: >> On Thu, 2018-03-15 at 11:12 +0100, Ulf Hansson wrote: >>> On 13 March 2018 at 06:10, Harish Jenny K N >>> wrote: >>> Honestly, I don't like this, but maybe other people do, then I am fine >>> with this approach. >>> >>> If were to decide, I would just rather print the caps field in a >>> hexadecimal bit form and leave the translation to the user. >> A compromise would be to print both: >> >> 0x\n >> Description of each enabled field, one per line >> >> >> Another format would be: >> >> Bit XX: Description of a field > If we were to print the description, there is no point in printing the > bits in hex. Or is it? Yes. I also do not see the use of printing hex value if we are printing the description. > > As I said, if you and other folkz thinks this is valuable, then I am > fine as well. Just saying, it's not my preferred option. > > I just want to inform that the idea of printing the description came after discussion in https://www.spinics.net/lists/linux-mmc/msg48246.html, where it was decided adding utility in mmc-utils was not going to work ( reason: We may very well be changing the bit offsets for the caps and caps2 in the mmc kernel header, keeping a copy of them is not a good idea. It's just a matter of *when* it will break). On Thu, 2018-03-15 at 11:12 +0100, Ulf Hansson wrote: > If were to decide, I would just rather print the caps field in a hexadecimal > bit form and leave the translation to the user. I think translation becomes difficult for the above reason and hence I would prefer printing the description. Note: Printing values in Hex was the original idea and it is also available in https://www.spinics.net/lists/linux-mmc/msg48213.html just in case if it is required. Thanks & Regards, Harish Jenny K N
[PATCH 4/7] soc: qcom: rpmpd: Add support for get/set performance state
With genpd now expecting powerdomain drivers supporting performance state to support get/set performance state callbacks, add support for it in the rpmpd driver. Signed-off-by: Rajendra NayakSigned-off-by: Viresh Kumar --- drivers/soc/qcom/rpmpd.c | 42 ++ 1 file changed, 42 insertions(+) diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c index c8754d867c33..4058c5b450c6 100644 --- a/drivers/soc/qcom/rpmpd.c +++ b/drivers/soc/qcom/rpmpd.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -29,6 +30,8 @@ #define KEY_ENABLE 0x6e657773 /* swen */ #define KEY_FLOOR_CORNER 0x636676 /* vfc */ +#define MAX_RPMPD_STATE6 + #define DEFINE_RPMPD_CORN_SMPA(_platform, _name, _active, r_id) \ static struct rpmpd _platform##_##_active; \ static struct rpmpd _platform##_##_name = { \ @@ -222,6 +225,43 @@ static int rpmpd_power_off(struct generic_pm_domain *domain) return ret; } +static int rpmpd_set_performance(struct generic_pm_domain *domain, +unsigned int state) +{ + int ret = 0; + struct rpmpd *pd = domain_to_rpmpd(domain); + + mutex_lock(_lock); + + if (state > MAX_RPMPD_STATE) + goto out; + + pd->corner = state; + + if (!pd->enabled && (pd->key != KEY_FLOOR_CORNER)) + goto out; + + ret = rpmpd_aggregate_corner(pd); + +out: + mutex_unlock(_lock); + + return ret; +} + +static unsigned int rpmpd_get_performance(struct generic_pm_domain *genpd, + struct dev_pm_opp *opp) +{ + struct device_node *np; + unsigned int corner = 0; + + np = dev_pm_opp_get_of_node(opp); + of_property_read_u32(np, "qcom,level", ); + of_node_put(np); + + return corner; +} + static int rpmpd_probe(struct platform_device *pdev) { int i; @@ -259,6 +299,8 @@ static int rpmpd_probe(struct platform_device *pdev) rpmpds[i]->rpm = rpm; rpmpds[i]->pd.power_off = rpmpd_power_off; rpmpds[i]->pd.power_on = rpmpd_power_on; + rpmpds[i]->pd.set_performance_state = rpmpd_set_performance; + rpmpds[i]->pd.get_performance_state = rpmpd_get_performance; pm_genpd_init([i]->pd, NULL, true); data->domains[i] = [i]->pd; -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
[PATCH 4/7] soc: qcom: rpmpd: Add support for get/set performance state
With genpd now expecting powerdomain drivers supporting performance state to support get/set performance state callbacks, add support for it in the rpmpd driver. Signed-off-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/soc/qcom/rpmpd.c | 42 ++ 1 file changed, 42 insertions(+) diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c index c8754d867c33..4058c5b450c6 100644 --- a/drivers/soc/qcom/rpmpd.c +++ b/drivers/soc/qcom/rpmpd.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -29,6 +30,8 @@ #define KEY_ENABLE 0x6e657773 /* swen */ #define KEY_FLOOR_CORNER 0x636676 /* vfc */ +#define MAX_RPMPD_STATE6 + #define DEFINE_RPMPD_CORN_SMPA(_platform, _name, _active, r_id) \ static struct rpmpd _platform##_##_active; \ static struct rpmpd _platform##_##_name = { \ @@ -222,6 +225,43 @@ static int rpmpd_power_off(struct generic_pm_domain *domain) return ret; } +static int rpmpd_set_performance(struct generic_pm_domain *domain, +unsigned int state) +{ + int ret = 0; + struct rpmpd *pd = domain_to_rpmpd(domain); + + mutex_lock(_lock); + + if (state > MAX_RPMPD_STATE) + goto out; + + pd->corner = state; + + if (!pd->enabled && (pd->key != KEY_FLOOR_CORNER)) + goto out; + + ret = rpmpd_aggregate_corner(pd); + +out: + mutex_unlock(_lock); + + return ret; +} + +static unsigned int rpmpd_get_performance(struct generic_pm_domain *genpd, + struct dev_pm_opp *opp) +{ + struct device_node *np; + unsigned int corner = 0; + + np = dev_pm_opp_get_of_node(opp); + of_property_read_u32(np, "qcom,level", ); + of_node_put(np); + + return corner; +} + static int rpmpd_probe(struct platform_device *pdev) { int i; @@ -259,6 +299,8 @@ static int rpmpd_probe(struct platform_device *pdev) rpmpds[i]->rpm = rpm; rpmpds[i]->pd.power_off = rpmpd_power_off; rpmpds[i]->pd.power_on = rpmpd_power_on; + rpmpds[i]->pd.set_performance_state = rpmpd_set_performance; + rpmpds[i]->pd.get_performance_state = rpmpd_get_performance; pm_genpd_init([i]->pd, NULL, true); data->domains[i] = [i]->pd; -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
[PATCH 0/7] Add powerdomain driver for corners on msm8996
With performance state support for genpd merged, and with some more patches to add support for them in the OPP layer [1] under discussion, this is an effort to model a powerdomain driver to communicate corner/level values for qualcomm platforms to RPM (Remote Power Manager) This series adds data specific to msm8996 and is tested on the db820c. We also modify mmc as one of the first devices to move to using an OPP table and vote on corners using the performance state infrastructure. [1] https://lwn.net/Articles/742136/ Rajendra Nayak (6): soc: qcom: rpmpd: Add a powerdomain driver to model corners dt-bindings: opp: Introduce qcom-opp bindings soc: qcom: rpmpd: Add support for get/set performance state arm64: dts: msm8996: Add rpmpd device node mmc: sdhci-msm: Adapt the driver to use OPPs to set clocks/performance state soc: qcom: rpmpd: Add a max vote on all corners at init Viresh Kumar (1): PM / OPP: Add dev_pm_opp_get_of_node() Documentation/devicetree/bindings/opp/qcom-opp.txt | 25 ++ .../devicetree/bindings/power/qcom,rpmpd.txt | 14 + arch/arm64/boot/dts/qcom/msm8996.dtsi | 87 + drivers/clk/qcom/gcc-msm8996.c | 8 +- drivers/mmc/host/sdhci-msm.c | 57 +++- drivers/opp/of.c | 19 ++ drivers/soc/qcom/Kconfig | 9 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/rpmpd.c | 350 + include/linux/pm_opp.h | 5 + 10 files changed, 561 insertions(+), 14 deletions(-) create mode 100644 Documentation/devicetree/bindings/opp/qcom-opp.txt create mode 100644 Documentation/devicetree/bindings/power/qcom,rpmpd.txt create mode 100644 drivers/soc/qcom/rpmpd.c -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
[PATCH 0/7] Add powerdomain driver for corners on msm8996
With performance state support for genpd merged, and with some more patches to add support for them in the OPP layer [1] under discussion, this is an effort to model a powerdomain driver to communicate corner/level values for qualcomm platforms to RPM (Remote Power Manager) This series adds data specific to msm8996 and is tested on the db820c. We also modify mmc as one of the first devices to move to using an OPP table and vote on corners using the performance state infrastructure. [1] https://lwn.net/Articles/742136/ Rajendra Nayak (6): soc: qcom: rpmpd: Add a powerdomain driver to model corners dt-bindings: opp: Introduce qcom-opp bindings soc: qcom: rpmpd: Add support for get/set performance state arm64: dts: msm8996: Add rpmpd device node mmc: sdhci-msm: Adapt the driver to use OPPs to set clocks/performance state soc: qcom: rpmpd: Add a max vote on all corners at init Viresh Kumar (1): PM / OPP: Add dev_pm_opp_get_of_node() Documentation/devicetree/bindings/opp/qcom-opp.txt | 25 ++ .../devicetree/bindings/power/qcom,rpmpd.txt | 14 + arch/arm64/boot/dts/qcom/msm8996.dtsi | 87 + drivers/clk/qcom/gcc-msm8996.c | 8 +- drivers/mmc/host/sdhci-msm.c | 57 +++- drivers/opp/of.c | 19 ++ drivers/soc/qcom/Kconfig | 9 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/rpmpd.c | 350 + include/linux/pm_opp.h | 5 + 10 files changed, 561 insertions(+), 14 deletions(-) create mode 100644 Documentation/devicetree/bindings/opp/qcom-opp.txt create mode 100644 Documentation/devicetree/bindings/power/qcom,rpmpd.txt create mode 100644 drivers/soc/qcom/rpmpd.c -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
[PATCH 3/7] dt-bindings: opp: Introduce qcom-opp bindings
On Qualcomm platforms, an OPP node needs to describe an additional level/corner value that is then communicated to a remote microprocessor by the CPU, which then takes some actions (like adjusting voltage values across various rails) based on the value passed. Describe these bindings in the qcom-opp bindings document. Signed-off-by: Rajendra Nayak--- Documentation/devicetree/bindings/opp/qcom-opp.txt | 25 ++ 1 file changed, 25 insertions(+) create mode 100644 Documentation/devicetree/bindings/opp/qcom-opp.txt diff --git a/Documentation/devicetree/bindings/opp/qcom-opp.txt b/Documentation/devicetree/bindings/opp/qcom-opp.txt new file mode 100644 index ..56fe87751881 --- /dev/null +++ b/Documentation/devicetree/bindings/opp/qcom-opp.txt @@ -0,0 +1,25 @@ +Qualcomm OPP bindings to descibe OPP nodes with corner/level values + +OPP tables for devices on qualcomm platforms require an additional +platform specific corner/level value to be specified. +This value is passed on to the RPM (Resource Power Manager) by +the CPU, which then takes the necessary actions to set a voltage +rail to a appropriate voltage based on the value passed. + +The bindings are based on top of the operating-points-v2 bindings +described in Documentation/devicetree/bindings/opp/opp.txt +Additional properties are described below. + +* OPP Table Node + +Required properties: +- compatible: Allow OPPs to express their compatibility. It should be: + "operating-points-v2-qcom" + +* OPP Node + +Required properties: +- qcom,level: On Qualcomm platforms an OPP node can describe a positive value +representing a corner/level thats comminicated with a remote microprocessor +(Usually called the RPM) which then translates it into a certain voltage on +a voltage rail. -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
[PATCH 5/7] arm64: dts: msm8996: Add rpmpd device node
Add rpmpd device node and its OPP table Signed-off-by: Rajendra NayakSigned-off-by: Viresh Kumar --- arch/arm64/boot/dts/qcom/msm8996.dtsi | 46 +++ 1 file changed, 46 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi index 0a6f7952bbb1..43757a078146 100644 --- a/arch/arm64/boot/dts/qcom/msm8996.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi @@ -297,6 +297,52 @@ #clock-cells = <1>; }; + rpmpd: qcom,rpmpd { + compatible = "qcom,rpmpd-msm8996"; + #power-domain-cells = <1>; + operating-points-v2 = <_opp_table>, /* cx */ + <_opp_table>, /* cx_ao */ + <_opp_table>, /* cx_vfc */ + <_opp_table>, /* mx */ + <_opp_table>, /* mx_ao */ + <_opp_table>, /* sscx */ + <_opp_table>; /* sscx_vfc */ + }; + + rpmpd_opp_table: opp-table { + compatible = "operating-points-v2", "operating-points-v2-qcom"; + + rpmpd_opp1: opp@1 { + opp-hz = /bits/ 64 <1>; + qcom,level = <1>; + }; + + rpmpd_opp2: opp@2 { + opp-hz = /bits/ 64 <2>; + qcom,level = <2>; + }; + + rpmpd_opp3: opp@3 { + opp-hz = /bits/ 64 <3>; + qcom,level = <3>; + }; + + rpmpd_opp4: opp@4 { + opp-hz = /bits/ 64 <4>; + qcom,level = <4>; + }; + + rpmpd_opp5: opp@5 { + opp-hz = /bits/ 64 <5>; + qcom,level = <5>; + }; + + rpmpd_opp6: opp@6 { + opp-hz = /bits/ 64 <6>; + qcom,level = <6>; + }; + }; + pm8994-regulators { compatible = "qcom,rpm-pm8994-regulators"; -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
[PATCH 3/7] dt-bindings: opp: Introduce qcom-opp bindings
On Qualcomm platforms, an OPP node needs to describe an additional level/corner value that is then communicated to a remote microprocessor by the CPU, which then takes some actions (like adjusting voltage values across various rails) based on the value passed. Describe these bindings in the qcom-opp bindings document. Signed-off-by: Rajendra Nayak --- Documentation/devicetree/bindings/opp/qcom-opp.txt | 25 ++ 1 file changed, 25 insertions(+) create mode 100644 Documentation/devicetree/bindings/opp/qcom-opp.txt diff --git a/Documentation/devicetree/bindings/opp/qcom-opp.txt b/Documentation/devicetree/bindings/opp/qcom-opp.txt new file mode 100644 index ..56fe87751881 --- /dev/null +++ b/Documentation/devicetree/bindings/opp/qcom-opp.txt @@ -0,0 +1,25 @@ +Qualcomm OPP bindings to descibe OPP nodes with corner/level values + +OPP tables for devices on qualcomm platforms require an additional +platform specific corner/level value to be specified. +This value is passed on to the RPM (Resource Power Manager) by +the CPU, which then takes the necessary actions to set a voltage +rail to a appropriate voltage based on the value passed. + +The bindings are based on top of the operating-points-v2 bindings +described in Documentation/devicetree/bindings/opp/opp.txt +Additional properties are described below. + +* OPP Table Node + +Required properties: +- compatible: Allow OPPs to express their compatibility. It should be: + "operating-points-v2-qcom" + +* OPP Node + +Required properties: +- qcom,level: On Qualcomm platforms an OPP node can describe a positive value +representing a corner/level thats comminicated with a remote microprocessor +(Usually called the RPM) which then translates it into a certain voltage on +a voltage rail. -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
[PATCH 5/7] arm64: dts: msm8996: Add rpmpd device node
Add rpmpd device node and its OPP table Signed-off-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- arch/arm64/boot/dts/qcom/msm8996.dtsi | 46 +++ 1 file changed, 46 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi index 0a6f7952bbb1..43757a078146 100644 --- a/arch/arm64/boot/dts/qcom/msm8996.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi @@ -297,6 +297,52 @@ #clock-cells = <1>; }; + rpmpd: qcom,rpmpd { + compatible = "qcom,rpmpd-msm8996"; + #power-domain-cells = <1>; + operating-points-v2 = <_opp_table>, /* cx */ + <_opp_table>, /* cx_ao */ + <_opp_table>, /* cx_vfc */ + <_opp_table>, /* mx */ + <_opp_table>, /* mx_ao */ + <_opp_table>, /* sscx */ + <_opp_table>; /* sscx_vfc */ + }; + + rpmpd_opp_table: opp-table { + compatible = "operating-points-v2", "operating-points-v2-qcom"; + + rpmpd_opp1: opp@1 { + opp-hz = /bits/ 64 <1>; + qcom,level = <1>; + }; + + rpmpd_opp2: opp@2 { + opp-hz = /bits/ 64 <2>; + qcom,level = <2>; + }; + + rpmpd_opp3: opp@3 { + opp-hz = /bits/ 64 <3>; + qcom,level = <3>; + }; + + rpmpd_opp4: opp@4 { + opp-hz = /bits/ 64 <4>; + qcom,level = <4>; + }; + + rpmpd_opp5: opp@5 { + opp-hz = /bits/ 64 <5>; + qcom,level = <5>; + }; + + rpmpd_opp6: opp@6 { + opp-hz = /bits/ 64 <6>; + qcom,level = <6>; + }; + }; + pm8994-regulators { compatible = "qcom,rpm-pm8994-regulators"; -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
[PATCH 6/7] mmc: sdhci-msm: Adapt the driver to use OPPs to set clocks/performance state
SDHCI driver needs to set a performance state along with scaling its clocks. Modify the driver to use the newly introduced powerdomain performance state based OPPs to scale clocks as well as set an appropriate powerdomain performance state. The patch also adds OPPs for sdhci device on msm8996. On platforms which don't specify an OPP table the driver falls back to just setting the clock rates (as is done today) Signed-off-by: Rajendra NayakSigned-off-by: Viresh Kumar Cc: linux-...@vger.kernel.org --- arch/arm64/boot/dts/qcom/msm8996.dtsi | 41 + drivers/clk/qcom/gcc-msm8996.c| 8 ++--- drivers/mmc/host/sdhci-msm.c | 57 +-- 3 files changed, 92 insertions(+), 14 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi index 43757a078146..e880a8433596 100644 --- a/arch/arm64/boot/dts/qcom/msm8996.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi @@ -569,8 +569,49 @@ < GCC_SDCC2_APPS_CLK>, <_board>; bus-width = <4>; + power-domains = < 0>; + operating-points-v2 = <_opp_table>; }; + sdhc_opp_table: opp_table { + compatible = "operating-points-v2"; + + opp@144000 { + opp-hz = /bits/ 64 <144000>; + required-opp = <_opp1>; + }; + + opp@400 { + opp-hz = /bits/ 64 <40>; + required-opp = <_opp1>; + }; + + opp@2000 { + opp-hz = /bits/ 64 <2000>; + required-opp = <_opp2>; + }; + + opp@2500 { + opp-hz = /bits/ 64 <2500>; + required-opp = <_opp2>; + }; + + opp@5000 { + opp-hz = /bits/ 64 <5000>; + required-opp = <_opp2>; + }; + + opp@1 { + opp-hz = /bits/ 64 <1>; + required-opp = <_opp3>; + }; + + opp@2 { + opp-hz = /bits/ 64 <2>; + required-opp = <_opp3>; + }; + }; + msmgpio: pinctrl@101 { compatible = "qcom,msm8996-pinctrl"; reg = <0x0101 0x30>; diff --git a/drivers/clk/qcom/gcc-msm8996.c b/drivers/clk/qcom/gcc-msm8996.c index 5d7451209206..fc90dbbdcd70 100644 --- a/drivers/clk/qcom/gcc-msm8996.c +++ b/drivers/clk/qcom/gcc-msm8996.c @@ -464,7 +464,7 @@ static struct clk_rcg2 sdcc1_apps_clk_src = { .name = "sdcc1_apps_clk_src", .parent_names = gcc_xo_gpll0_gpll4_gpll0_early_div, .num_parents = 4, - .ops = _rcg2_floor_ops, + .ops = _rcg2_ops, }, }; @@ -509,7 +509,7 @@ static struct clk_rcg2 sdcc2_apps_clk_src = { .name = "sdcc2_apps_clk_src", .parent_names = gcc_xo_gpll0_gpll4, .num_parents = 3, - .ops = _rcg2_floor_ops, + .ops = _rcg2_ops, }, }; @@ -523,7 +523,7 @@ static struct clk_rcg2 sdcc3_apps_clk_src = { .name = "sdcc3_apps_clk_src", .parent_names = gcc_xo_gpll0_gpll4, .num_parents = 3, - .ops = _rcg2_floor_ops, + .ops = _rcg2_ops, }, }; @@ -547,7 +547,7 @@ static struct clk_rcg2 sdcc4_apps_clk_src = { .name = "sdcc4_apps_clk_src", .parent_names = gcc_xo_gpll0, .num_parents = 2, - .ops = _rcg2_floor_ops, + .ops = _rcg2_ops, }, }; diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index c283291db705..8e6abc0a23c7 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "sdhci-pltfm.h" @@ -137,6 +138,7 @@ struct sdhci_msm_host { struct clk *bus_clk;/* SDHC bus voter clock */ struct clk *xo_clk; /* TCXO clk needed for FLL feature of cm_dll*/ struct clk_bulk_data bulk_clks[4]; /* core, iface, cal, sleep clocks */ + struct opp_table *opp_table; unsigned long clk_rate; struct mmc_host *mmc; bool use_14lpp_dll_reset; @@ -150,7 +152,7 @@ struct sdhci_msm_host { bool pwr_irq_flag; };
[PATCH 6/7] mmc: sdhci-msm: Adapt the driver to use OPPs to set clocks/performance state
SDHCI driver needs to set a performance state along with scaling its clocks. Modify the driver to use the newly introduced powerdomain performance state based OPPs to scale clocks as well as set an appropriate powerdomain performance state. The patch also adds OPPs for sdhci device on msm8996. On platforms which don't specify an OPP table the driver falls back to just setting the clock rates (as is done today) Signed-off-by: Rajendra Nayak Signed-off-by: Viresh Kumar Cc: linux-...@vger.kernel.org --- arch/arm64/boot/dts/qcom/msm8996.dtsi | 41 + drivers/clk/qcom/gcc-msm8996.c| 8 ++--- drivers/mmc/host/sdhci-msm.c | 57 +-- 3 files changed, 92 insertions(+), 14 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi index 43757a078146..e880a8433596 100644 --- a/arch/arm64/boot/dts/qcom/msm8996.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi @@ -569,8 +569,49 @@ < GCC_SDCC2_APPS_CLK>, <_board>; bus-width = <4>; + power-domains = < 0>; + operating-points-v2 = <_opp_table>; }; + sdhc_opp_table: opp_table { + compatible = "operating-points-v2"; + + opp@144000 { + opp-hz = /bits/ 64 <144000>; + required-opp = <_opp1>; + }; + + opp@400 { + opp-hz = /bits/ 64 <40>; + required-opp = <_opp1>; + }; + + opp@2000 { + opp-hz = /bits/ 64 <2000>; + required-opp = <_opp2>; + }; + + opp@2500 { + opp-hz = /bits/ 64 <2500>; + required-opp = <_opp2>; + }; + + opp@5000 { + opp-hz = /bits/ 64 <5000>; + required-opp = <_opp2>; + }; + + opp@1 { + opp-hz = /bits/ 64 <1>; + required-opp = <_opp3>; + }; + + opp@2 { + opp-hz = /bits/ 64 <2>; + required-opp = <_opp3>; + }; + }; + msmgpio: pinctrl@101 { compatible = "qcom,msm8996-pinctrl"; reg = <0x0101 0x30>; diff --git a/drivers/clk/qcom/gcc-msm8996.c b/drivers/clk/qcom/gcc-msm8996.c index 5d7451209206..fc90dbbdcd70 100644 --- a/drivers/clk/qcom/gcc-msm8996.c +++ b/drivers/clk/qcom/gcc-msm8996.c @@ -464,7 +464,7 @@ static struct clk_rcg2 sdcc1_apps_clk_src = { .name = "sdcc1_apps_clk_src", .parent_names = gcc_xo_gpll0_gpll4_gpll0_early_div, .num_parents = 4, - .ops = _rcg2_floor_ops, + .ops = _rcg2_ops, }, }; @@ -509,7 +509,7 @@ static struct clk_rcg2 sdcc2_apps_clk_src = { .name = "sdcc2_apps_clk_src", .parent_names = gcc_xo_gpll0_gpll4, .num_parents = 3, - .ops = _rcg2_floor_ops, + .ops = _rcg2_ops, }, }; @@ -523,7 +523,7 @@ static struct clk_rcg2 sdcc3_apps_clk_src = { .name = "sdcc3_apps_clk_src", .parent_names = gcc_xo_gpll0_gpll4, .num_parents = 3, - .ops = _rcg2_floor_ops, + .ops = _rcg2_ops, }, }; @@ -547,7 +547,7 @@ static struct clk_rcg2 sdcc4_apps_clk_src = { .name = "sdcc4_apps_clk_src", .parent_names = gcc_xo_gpll0, .num_parents = 2, - .ops = _rcg2_floor_ops, + .ops = _rcg2_ops, }, }; diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index c283291db705..8e6abc0a23c7 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "sdhci-pltfm.h" @@ -137,6 +138,7 @@ struct sdhci_msm_host { struct clk *bus_clk;/* SDHC bus voter clock */ struct clk *xo_clk; /* TCXO clk needed for FLL feature of cm_dll*/ struct clk_bulk_data bulk_clks[4]; /* core, iface, cal, sleep clocks */ + struct opp_table *opp_table; unsigned long clk_rate; struct mmc_host *mmc; bool use_14lpp_dll_reset; @@ -150,7 +152,7 @@ struct sdhci_msm_host { bool pwr_irq_flag; }; -static unsigned int
[PATCH 7/7] soc: qcom: rpmpd: Add a max vote on all corners at init
As we move from no clients/consumers in kernel voting on corners, to *some* voting and some not voting, we might end up in a situation where the clients which remove votes can adversly impact others who still don't have a way to vote. To avoid this situation, have a max vote on all corners at init. This should/can be removed once we have all clients moved to be able to vote/unvote for themselves. Signed-off-by: Rajendra Nayak--- drivers/soc/qcom/rpmpd.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c index 4058c5b450c6..ebdcf9398441 100644 --- a/drivers/soc/qcom/rpmpd.c +++ b/drivers/soc/qcom/rpmpd.c @@ -304,6 +304,15 @@ static int rpmpd_probe(struct platform_device *pdev) pm_genpd_init([i]->pd, NULL, true); data->domains[i] = [i]->pd; + + /* +* Until we have all consumers voting on corners +* just vote the max corner on all PDs +* This should ideally be *removed* once we have +* all (most) consumers being able to vote +*/ + rpmpd_set_performance([i]->pd, MAX_RPMPD_STATE); + rpmpd_power_on([i]->pd); } return of_genpd_add_provider_onecell(pdev->dev.of_node, data); -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
[PATCH 2/7] soc: qcom: rpmpd: Add a powerdomain driver to model corners
The powerdomains for corners just pass the performance state set by the consumers to the RPM (Remote Power manager) which then takes care of setting the appropriate voltage on the corresponding rails to meet the performance needs. We add all powerdomain data needed on msm8996 here. This driver can easily be extended by adding data for other qualcomm SoCs as well. Signed-off-by: Rajendra NayakSigned-off-by: Viresh Kumar --- .../devicetree/bindings/power/qcom,rpmpd.txt | 14 + drivers/soc/qcom/Kconfig | 9 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/rpmpd.c | 299 + 4 files changed, 323 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/qcom,rpmpd.txt create mode 100644 drivers/soc/qcom/rpmpd.c diff --git a/Documentation/devicetree/bindings/power/qcom,rpmpd.txt b/Documentation/devicetree/bindings/power/qcom,rpmpd.txt new file mode 100644 index ..4d7a4a1f054f --- /dev/null +++ b/Documentation/devicetree/bindings/power/qcom,rpmpd.txt @@ -0,0 +1,14 @@ +Qualcomm RPM Powerdomains + +* For RPM powerdomains, we communicate a performance state to RPM +which then translates it into a corresponding voltage on a rail + +Required Properties: + - compatible: Should be one of the following + * qcom,rpmpd-msm8996: RPM Powerdomain for the msm8996 family of SoC + - power-domain-cells: number of cells in power domain specifier + must be 1. + - domain-performance-state: One or more nodes describing the performance-states + supported by the powerdomain. + For domain-performance-state bindings refer to + Documentation/devicetree/bindings/power/power_domain.txt diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index e050eb83341d..6e1a0ed7ea3f 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -55,6 +55,15 @@ config QCOM_RMTFS_MEM Say y here if you intend to boot the modem remoteproc. +config QCOM_RPMPD + tristate "Qualcomm RPM Powerdomain driver" + depends on MFD_QCOM_RPM && QCOM_SMD_RPM + help + QCOM RPM powerdomain driver to support powerdomain with + performance states. The driver communicates a performance state + value to RPM which then translates it into corresponding voltage + for the voltage rail. + config QCOM_SMEM tristate "Qualcomm Shared Memory Manager (SMEM)" depends on ARCH_QCOM diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index dcebf2814e6d..12c48a3ea106 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -12,3 +12,4 @@ obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o obj-$(CONFIG_QCOM_SMP2P) += smp2p.o obj-$(CONFIG_QCOM_SMSM)+= smsm.o obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o +obj-$(CONFIG_QCOM_RPMPD) += rpmpd.o diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c new file mode 100644 index ..c8754d867c33 --- /dev/null +++ b/drivers/soc/qcom/rpmpd.c @@ -0,0 +1,299 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define domain_to_rpmpd(domain) container_of(domain, struct rpmpd, pd) + +/* Resource types */ +#define RPMPD_SMPA 0x61706d73 +#define RPMPD_LDOA 0x616f646c + +/* Operation Keys */ +#define KEY_CORNER 0x6e726f63 /* corn */ +#define KEY_ENABLE 0x6e657773 /* swen */ +#define KEY_FLOOR_CORNER 0x636676 /* vfc */ + +#define DEFINE_RPMPD_CORN_SMPA(_platform, _name, _active, r_id) \ + static struct rpmpd _platform##_##_active; \ + static struct rpmpd _platform##_##_name = { \ + .pd = { .name = #_name, }, \ + .peer = &_platform##_##_active, \ + .res_type = RPMPD_SMPA, \ + .res_id = r_id, \ + .key = KEY_CORNER, \ + }; \ + static struct rpmpd _platform##_##_active = { \ + .pd = { .name = #_active, },\ + .peer = &_platform##_##_name, \ + .active_only = true,\ + .res_type = RPMPD_SMPA, \ + .res_id = r_id, \ + .key = KEY_CORNER, \ + } + +#define
[PATCH 7/7] soc: qcom: rpmpd: Add a max vote on all corners at init
As we move from no clients/consumers in kernel voting on corners, to *some* voting and some not voting, we might end up in a situation where the clients which remove votes can adversly impact others who still don't have a way to vote. To avoid this situation, have a max vote on all corners at init. This should/can be removed once we have all clients moved to be able to vote/unvote for themselves. Signed-off-by: Rajendra Nayak --- drivers/soc/qcom/rpmpd.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c index 4058c5b450c6..ebdcf9398441 100644 --- a/drivers/soc/qcom/rpmpd.c +++ b/drivers/soc/qcom/rpmpd.c @@ -304,6 +304,15 @@ static int rpmpd_probe(struct platform_device *pdev) pm_genpd_init([i]->pd, NULL, true); data->domains[i] = [i]->pd; + + /* +* Until we have all consumers voting on corners +* just vote the max corner on all PDs +* This should ideally be *removed* once we have +* all (most) consumers being able to vote +*/ + rpmpd_set_performance([i]->pd, MAX_RPMPD_STATE); + rpmpd_power_on([i]->pd); } return of_genpd_add_provider_onecell(pdev->dev.of_node, data); -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
[PATCH 2/7] soc: qcom: rpmpd: Add a powerdomain driver to model corners
The powerdomains for corners just pass the performance state set by the consumers to the RPM (Remote Power manager) which then takes care of setting the appropriate voltage on the corresponding rails to meet the performance needs. We add all powerdomain data needed on msm8996 here. This driver can easily be extended by adding data for other qualcomm SoCs as well. Signed-off-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- .../devicetree/bindings/power/qcom,rpmpd.txt | 14 + drivers/soc/qcom/Kconfig | 9 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/rpmpd.c | 299 + 4 files changed, 323 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/qcom,rpmpd.txt create mode 100644 drivers/soc/qcom/rpmpd.c diff --git a/Documentation/devicetree/bindings/power/qcom,rpmpd.txt b/Documentation/devicetree/bindings/power/qcom,rpmpd.txt new file mode 100644 index ..4d7a4a1f054f --- /dev/null +++ b/Documentation/devicetree/bindings/power/qcom,rpmpd.txt @@ -0,0 +1,14 @@ +Qualcomm RPM Powerdomains + +* For RPM powerdomains, we communicate a performance state to RPM +which then translates it into a corresponding voltage on a rail + +Required Properties: + - compatible: Should be one of the following + * qcom,rpmpd-msm8996: RPM Powerdomain for the msm8996 family of SoC + - power-domain-cells: number of cells in power domain specifier + must be 1. + - domain-performance-state: One or more nodes describing the performance-states + supported by the powerdomain. + For domain-performance-state bindings refer to + Documentation/devicetree/bindings/power/power_domain.txt diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index e050eb83341d..6e1a0ed7ea3f 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -55,6 +55,15 @@ config QCOM_RMTFS_MEM Say y here if you intend to boot the modem remoteproc. +config QCOM_RPMPD + tristate "Qualcomm RPM Powerdomain driver" + depends on MFD_QCOM_RPM && QCOM_SMD_RPM + help + QCOM RPM powerdomain driver to support powerdomain with + performance states. The driver communicates a performance state + value to RPM which then translates it into corresponding voltage + for the voltage rail. + config QCOM_SMEM tristate "Qualcomm Shared Memory Manager (SMEM)" depends on ARCH_QCOM diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index dcebf2814e6d..12c48a3ea106 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -12,3 +12,4 @@ obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o obj-$(CONFIG_QCOM_SMP2P) += smp2p.o obj-$(CONFIG_QCOM_SMSM)+= smsm.o obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o +obj-$(CONFIG_QCOM_RPMPD) += rpmpd.o diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c new file mode 100644 index ..c8754d867c33 --- /dev/null +++ b/drivers/soc/qcom/rpmpd.c @@ -0,0 +1,299 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define domain_to_rpmpd(domain) container_of(domain, struct rpmpd, pd) + +/* Resource types */ +#define RPMPD_SMPA 0x61706d73 +#define RPMPD_LDOA 0x616f646c + +/* Operation Keys */ +#define KEY_CORNER 0x6e726f63 /* corn */ +#define KEY_ENABLE 0x6e657773 /* swen */ +#define KEY_FLOOR_CORNER 0x636676 /* vfc */ + +#define DEFINE_RPMPD_CORN_SMPA(_platform, _name, _active, r_id) \ + static struct rpmpd _platform##_##_active; \ + static struct rpmpd _platform##_##_name = { \ + .pd = { .name = #_name, }, \ + .peer = &_platform##_##_active, \ + .res_type = RPMPD_SMPA, \ + .res_id = r_id, \ + .key = KEY_CORNER, \ + }; \ + static struct rpmpd _platform##_##_active = { \ + .pd = { .name = #_active, },\ + .peer = &_platform##_##_name, \ + .active_only = true,\ + .res_type = RPMPD_SMPA, \ + .res_id = r_id, \ + .key = KEY_CORNER, \ + } + +#define DEFINE_RPMPD_CORN_LDOA(_platform, _name, r_id) \ +
[PATCH 1/7] PM / OPP: Add dev_pm_opp_get_of_node()
From: Viresh KumarThis adds a new helper to let the power domain drivers to access opp->np, so that they can read platform specific properties from the node. Signed-off-by: Viresh Kumar Signed-off-by: Rajendra Nayak --- drivers/opp/of.c | 19 +++ include/linux/pm_opp.h | 5 + 2 files changed, 24 insertions(+) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 21265af55117..b17715bc3c0a 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -736,3 +736,22 @@ struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device *dev, return opp; } EXPORT_SYMBOL_GPL(of_dev_pm_opp_find_required_opp); + +/** + * dev_pm_opp_get_of_node() - Gets the DT node corresponding to an opp + * @opp: opp for which DT node has to be returned for + * + * Return: DT node corresponding to the opp, else 0 on success. + * + * The caller needs to put the node of_node_put() after using it. + */ +struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp) +{ + if (IS_ERR_OR_NULL(opp)) { + pr_err("%s: Invalid parameters\n", __func__); + return NULL; + } + + return of_node_get(opp->np); +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_of_node); diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 528a7d9cf2ef..099b31960dec 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -300,6 +300,7 @@ void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask); int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev); struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device *dev, struct device_node *np); +struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp); #else static inline int dev_pm_opp_of_add_table(struct device *dev) { @@ -338,6 +339,10 @@ static inline struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device * { return NULL; } +static inline struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp) +{ + return NULL; +} #endif #endif /* __LINUX_OPP_H__ */ -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
[PATCH 1/7] PM / OPP: Add dev_pm_opp_get_of_node()
From: Viresh Kumar This adds a new helper to let the power domain drivers to access opp->np, so that they can read platform specific properties from the node. Signed-off-by: Viresh Kumar Signed-off-by: Rajendra Nayak --- drivers/opp/of.c | 19 +++ include/linux/pm_opp.h | 5 + 2 files changed, 24 insertions(+) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 21265af55117..b17715bc3c0a 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -736,3 +736,22 @@ struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device *dev, return opp; } EXPORT_SYMBOL_GPL(of_dev_pm_opp_find_required_opp); + +/** + * dev_pm_opp_get_of_node() - Gets the DT node corresponding to an opp + * @opp: opp for which DT node has to be returned for + * + * Return: DT node corresponding to the opp, else 0 on success. + * + * The caller needs to put the node of_node_put() after using it. + */ +struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp) +{ + if (IS_ERR_OR_NULL(opp)) { + pr_err("%s: Invalid parameters\n", __func__); + return NULL; + } + + return of_node_get(opp->np); +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_of_node); diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 528a7d9cf2ef..099b31960dec 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -300,6 +300,7 @@ void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask); int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev); struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device *dev, struct device_node *np); +struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp); #else static inline int dev_pm_opp_of_add_table(struct device *dev) { @@ -338,6 +339,10 @@ static inline struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device * { return NULL; } +static inline struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp) +{ + return NULL; +} #endif #endif /* __LINUX_OPP_H__ */ -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCH RFC 2/2] virtio_ring: support packed ring
On 2018年02月23日 19:18, Tiwei Bie wrote: Signed-off-by: Tiwei Bie--- drivers/virtio/virtio_ring.c | 699 +-- include/linux/virtio_ring.h | 8 +- 2 files changed, 618 insertions(+), 89 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index eb30f3e09a47..393778a2f809 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -58,14 +58,14 @@ struct vring_desc_state { void *data; /* Data for callback. */ - struct vring_desc *indir_desc; /* Indirect descriptor, if any. */ + void *indir_desc; /* Indirect descriptor, if any. */ + int num;/* Descriptor list length. */ }; struct vring_virtqueue { struct virtqueue vq; - /* Actual memory layout for this queue */ - struct vring vring; + bool packed; /* Can we use weak barriers? */ bool weak_barriers; @@ -87,11 +87,28 @@ struct vring_virtqueue { /* Last used index we've seen. */ u16 last_used_idx; - /* Last written value to avail->flags */ - u16 avail_flags_shadow; - - /* Last written value to avail->idx in guest byte order */ - u16 avail_idx_shadow; + union { + /* Available for split ring */ + struct { + /* Actual memory layout for this queue */ + struct vring vring; + + /* Last written value to avail->flags */ + u16 avail_flags_shadow; + + /* Last written value to avail->idx in +* guest byte order */ + u16 avail_idx_shadow; + }; + + /* Available for packed ring */ + struct { + /* Actual memory layout for this queue */ + struct vring_packed vring_packed; + u8 wrap_counter : 1; + bool chaining; + }; + }; /* How to notify other side. FIXME: commonalize hcalls! */ bool (*notify)(struct virtqueue *vq); @@ -201,26 +218,37 @@ static dma_addr_t vring_map_single(const struct vring_virtqueue *vq, cpu_addr, size, direction); } -static void vring_unmap_one(const struct vring_virtqueue *vq, - struct vring_desc *desc) +static void vring_unmap_one(const struct vring_virtqueue *vq, void *_desc) { Let's split the helpers to packed/split version like other helpers? (Consider the caller has already known the type of vq). + u64 addr; + u32 len; u16 flags; if (!vring_use_dma_api(vq->vq.vdev)) return; - flags = virtio16_to_cpu(vq->vq.vdev, desc->flags); + if (vq->packed) { + struct vring_packed_desc *desc = _desc; + + addr = virtio64_to_cpu(vq->vq.vdev, desc->addr); + len = virtio32_to_cpu(vq->vq.vdev, desc->len); + flags = virtio16_to_cpu(vq->vq.vdev, desc->flags); + } else { + struct vring_desc *desc = _desc; + + addr = virtio64_to_cpu(vq->vq.vdev, desc->addr); + len = virtio32_to_cpu(vq->vq.vdev, desc->len); + flags = virtio16_to_cpu(vq->vq.vdev, desc->flags); + } if (flags & VRING_DESC_F_INDIRECT) { dma_unmap_single(vring_dma_dev(vq), -virtio64_to_cpu(vq->vq.vdev, desc->addr), -virtio32_to_cpu(vq->vq.vdev, desc->len), +addr, len, (flags & VRING_DESC_F_WRITE) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } else { dma_unmap_page(vring_dma_dev(vq), - virtio64_to_cpu(vq->vq.vdev, desc->addr), - virtio32_to_cpu(vq->vq.vdev, desc->len), + addr, len, (flags & VRING_DESC_F_WRITE) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } @@ -235,8 +263,9 @@ static int vring_mapping_error(const struct vring_virtqueue *vq, return dma_mapping_error(vring_dma_dev(vq), addr); } -static struct vring_desc *alloc_indirect(struct virtqueue *_vq, -unsigned int total_sg, gfp_t gfp) +static struct vring_desc *alloc_indirect_split(struct virtqueue *_vq, + unsigned int total_sg, + gfp_t gfp) { struct vring_desc *desc; unsigned int i; @@ -257,14 +286,32 @@ static struct vring_desc *alloc_indirect(struct virtqueue *_vq, return desc; } -static inline int virtqueue_add(struct virtqueue *_vq, -
Re: [PATCH RFC 2/2] virtio_ring: support packed ring
On 2018年02月23日 19:18, Tiwei Bie wrote: Signed-off-by: Tiwei Bie --- drivers/virtio/virtio_ring.c | 699 +-- include/linux/virtio_ring.h | 8 +- 2 files changed, 618 insertions(+), 89 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index eb30f3e09a47..393778a2f809 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -58,14 +58,14 @@ struct vring_desc_state { void *data; /* Data for callback. */ - struct vring_desc *indir_desc; /* Indirect descriptor, if any. */ + void *indir_desc; /* Indirect descriptor, if any. */ + int num;/* Descriptor list length. */ }; struct vring_virtqueue { struct virtqueue vq; - /* Actual memory layout for this queue */ - struct vring vring; + bool packed; /* Can we use weak barriers? */ bool weak_barriers; @@ -87,11 +87,28 @@ struct vring_virtqueue { /* Last used index we've seen. */ u16 last_used_idx; - /* Last written value to avail->flags */ - u16 avail_flags_shadow; - - /* Last written value to avail->idx in guest byte order */ - u16 avail_idx_shadow; + union { + /* Available for split ring */ + struct { + /* Actual memory layout for this queue */ + struct vring vring; + + /* Last written value to avail->flags */ + u16 avail_flags_shadow; + + /* Last written value to avail->idx in +* guest byte order */ + u16 avail_idx_shadow; + }; + + /* Available for packed ring */ + struct { + /* Actual memory layout for this queue */ + struct vring_packed vring_packed; + u8 wrap_counter : 1; + bool chaining; + }; + }; /* How to notify other side. FIXME: commonalize hcalls! */ bool (*notify)(struct virtqueue *vq); @@ -201,26 +218,37 @@ static dma_addr_t vring_map_single(const struct vring_virtqueue *vq, cpu_addr, size, direction); } -static void vring_unmap_one(const struct vring_virtqueue *vq, - struct vring_desc *desc) +static void vring_unmap_one(const struct vring_virtqueue *vq, void *_desc) { Let's split the helpers to packed/split version like other helpers? (Consider the caller has already known the type of vq). + u64 addr; + u32 len; u16 flags; if (!vring_use_dma_api(vq->vq.vdev)) return; - flags = virtio16_to_cpu(vq->vq.vdev, desc->flags); + if (vq->packed) { + struct vring_packed_desc *desc = _desc; + + addr = virtio64_to_cpu(vq->vq.vdev, desc->addr); + len = virtio32_to_cpu(vq->vq.vdev, desc->len); + flags = virtio16_to_cpu(vq->vq.vdev, desc->flags); + } else { + struct vring_desc *desc = _desc; + + addr = virtio64_to_cpu(vq->vq.vdev, desc->addr); + len = virtio32_to_cpu(vq->vq.vdev, desc->len); + flags = virtio16_to_cpu(vq->vq.vdev, desc->flags); + } if (flags & VRING_DESC_F_INDIRECT) { dma_unmap_single(vring_dma_dev(vq), -virtio64_to_cpu(vq->vq.vdev, desc->addr), -virtio32_to_cpu(vq->vq.vdev, desc->len), +addr, len, (flags & VRING_DESC_F_WRITE) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } else { dma_unmap_page(vring_dma_dev(vq), - virtio64_to_cpu(vq->vq.vdev, desc->addr), - virtio32_to_cpu(vq->vq.vdev, desc->len), + addr, len, (flags & VRING_DESC_F_WRITE) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } @@ -235,8 +263,9 @@ static int vring_mapping_error(const struct vring_virtqueue *vq, return dma_mapping_error(vring_dma_dev(vq), addr); } -static struct vring_desc *alloc_indirect(struct virtqueue *_vq, -unsigned int total_sg, gfp_t gfp) +static struct vring_desc *alloc_indirect_split(struct virtqueue *_vq, + unsigned int total_sg, + gfp_t gfp) { struct vring_desc *desc; unsigned int i; @@ -257,14 +286,32 @@ static struct vring_desc *alloc_indirect(struct virtqueue *_vq, return desc; } -static inline int virtqueue_add(struct virtqueue *_vq, - struct
Re: [PATCH] KVM: x86: Fix device passthrough when SME is active
On 3/8/2018 5:17 PM, Tom Lendacky wrote: > When using device passthrough with SME active, the MMIO range that is > mapped for the device should not be mapped encrypted. Add a check in > set_spte() to insure that a page is not mapped encrypted if that page > is a device MMIO page as indicated by kvm_is_mmio_pfn(). > > Cc:# 4.14.x- > Signed-off-by: Tom Lendacky Any concerns with this fix? Thanks, Tom > --- > arch/x86/kvm/mmu.c |4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c > index f551962..763bb3b 100644 > --- a/arch/x86/kvm/mmu.c > +++ b/arch/x86/kvm/mmu.c > @@ -2770,8 +2770,10 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep, > else > pte_access &= ~ACC_WRITE_MASK; > > + if (!kvm_is_mmio_pfn(pfn)) > + spte |= shadow_me_mask; > + > spte |= (u64)pfn << PAGE_SHIFT; > - spte |= shadow_me_mask; > > if (pte_access & ACC_WRITE_MASK) { > >
Re: [PATCH] KVM: x86: Fix device passthrough when SME is active
On 3/8/2018 5:17 PM, Tom Lendacky wrote: > When using device passthrough with SME active, the MMIO range that is > mapped for the device should not be mapped encrypted. Add a check in > set_spte() to insure that a page is not mapped encrypted if that page > is a device MMIO page as indicated by kvm_is_mmio_pfn(). > > Cc: # 4.14.x- > Signed-off-by: Tom Lendacky Any concerns with this fix? Thanks, Tom > --- > arch/x86/kvm/mmu.c |4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c > index f551962..763bb3b 100644 > --- a/arch/x86/kvm/mmu.c > +++ b/arch/x86/kvm/mmu.c > @@ -2770,8 +2770,10 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep, > else > pte_access &= ~ACC_WRITE_MASK; > > + if (!kvm_is_mmio_pfn(pfn)) > + spte |= shadow_me_mask; > + > spte |= (u64)pfn << PAGE_SHIFT; > - spte |= shadow_me_mask; > > if (pte_access & ACC_WRITE_MASK) { > >
Re: [RFC PATCH V1 01/12] audit: add container id
On 2018-03-15 16:27, Stefan Berger wrote: > On 03/01/2018 02:41 PM, Richard Guy Briggs wrote: > > Implement the proc fs write to set the audit container ID of a process, > > emitting an AUDIT_CONTAINER record to document the event. > > > > This is a write from the container orchestrator task to a proc entry of > > the form /proc/PID/containerid where PID is the process ID of the newly > > created task that is to become the first task in a container, or an > > additional task added to a container. > > > > The write expects up to a u64 value (unset: 18446744073709551615). > > > > This will produce a record such as this: > > type=UNKNOWN[1333] msg=audit(1519903238.968:261): op=set pid=596 uid=0 > > subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 auid=0 tty=pts0 > > ses=1 opid=596 old-contid=18446744073709551615 contid=123455 res=0 > > > > The "op" field indicates an initial set. The "pid" to "ses" fields are > > the orchestrator while the "opid" field is the object's PID, the process > > being "contained". Old and new container ID values are given in the > > "contid" fields, while res indicates its success. > > > > It is not permitted to self-set, unset or re-set the container ID. A > > child inherits its parent's container ID, but then can be set only once > > after. > > > > See: https://github.com/linux-audit/audit-kernel/issues/32 > > > > > > /* audit_rule_data supports filter rules with both integer and string > >* fields. It corresponds with AUDIT_ADD_RULE, AUDIT_DEL_RULE and > > diff --git a/kernel/auditsc.c b/kernel/auditsc.c > > index 4e0a4ac..0ee1e59 100644 > > --- a/kernel/auditsc.c > > +++ b/kernel/auditsc.c > > @@ -2073,6 +2073,92 @@ int audit_set_loginuid(kuid_t loginuid) > > return rc; > > } > > > > +static int audit_set_containerid_perm(struct task_struct *task, u64 > > containerid) > > +{ > > + struct task_struct *parent; > > + u64 pcontainerid, ccontainerid; > > + pid_t ppid; > > + > > + /* Don't allow to set our own containerid */ > > + if (current == task) > > + return -EPERM; > > + /* Don't allow the containerid to be unset */ > > + if (!cid_valid(containerid)) > > + return -EINVAL; > > + /* if we don't have caps, reject */ > > + if (!capable(CAP_AUDIT_CONTROL)) > > + return -EPERM; > > + /* if containerid is unset, allow */ > > + if (!audit_containerid_set(task)) > > + return 0; > > I am wondering whether there should be a check for the target process that > will receive the containerid to not have CAP_SYS_ADMIN that would otherwise > allow it to arbitrarily unshare()/clone() and leave the set of namespaces > that may make up the container whose containerid we assign here? This is a reasonable question. This has been debated and I understood the conclusion was that without a clear definition of a "container", the task still remains in that container that just now has more sub-namespaces (in the case of hierarchical namespaces), we don't want to restrict it in such a way and that allows it to create nested containers. I see setns being more problematic if it could switch to another existing namespace that was set up by the orchestrator for a different container. The coming v2 patchset acknowledges this situation with the network namespace being potentially shared by multiple containers. This is the motivation for the code below that allows to set the containerid even if it is already inherited from its parent. > > + /* it is already set, and not inherited from the parent, reject */ > > + ccontainerid = audit_get_containerid(task); > > + rcu_read_lock(); > > + parent = rcu_dereference(task->real_parent); > > + rcu_read_unlock(); > > + task_lock(parent); > > + pcontainerid = audit_get_containerid(parent); > > + ppid = task_tgid_nr(parent); > > ppid not needed... Thanks for catching this. It was the vestige of a failed devel experiment that didn't flush that useless appendage. :-) > > + task_unlock(parent); > > + if (ccontainerid != pcontainerid) > > + return -EPERM; > > + return 0; > > +} > > + > > +static void audit_log_set_containerid(struct task_struct *task, u64 > > oldcontainerid, > > + u64 containerid, int rc) > > +{ > > + struct audit_buffer *ab; > > + uid_t uid; > > + struct tty_struct *tty; > > + > > + if (!audit_enabled) > > + return; > > + > > + ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_CONTAINER); > > + if (!ab) > > + return; > > + > > + uid = from_kuid(_user_ns, task_uid(current)); > > + tty = audit_get_tty(current); > > + > > + audit_log_format(ab, "op=set pid=%d uid=%u", task_tgid_nr(current), > > uid); > > + audit_log_task_context(ab); > > + audit_log_format(ab, " auid=%u tty=%s ses=%u opid=%d old-contid=%llu > > contid=%llu res=%d", > > +from_kuid(_user_ns, audit_get_loginuid(current)), > > +tty ? tty_name(tty) :
Re: [RFC PATCH V1 01/12] audit: add container id
On 2018-03-15 16:27, Stefan Berger wrote: > On 03/01/2018 02:41 PM, Richard Guy Briggs wrote: > > Implement the proc fs write to set the audit container ID of a process, > > emitting an AUDIT_CONTAINER record to document the event. > > > > This is a write from the container orchestrator task to a proc entry of > > the form /proc/PID/containerid where PID is the process ID of the newly > > created task that is to become the first task in a container, or an > > additional task added to a container. > > > > The write expects up to a u64 value (unset: 18446744073709551615). > > > > This will produce a record such as this: > > type=UNKNOWN[1333] msg=audit(1519903238.968:261): op=set pid=596 uid=0 > > subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 auid=0 tty=pts0 > > ses=1 opid=596 old-contid=18446744073709551615 contid=123455 res=0 > > > > The "op" field indicates an initial set. The "pid" to "ses" fields are > > the orchestrator while the "opid" field is the object's PID, the process > > being "contained". Old and new container ID values are given in the > > "contid" fields, while res indicates its success. > > > > It is not permitted to self-set, unset or re-set the container ID. A > > child inherits its parent's container ID, but then can be set only once > > after. > > > > See: https://github.com/linux-audit/audit-kernel/issues/32 > > > > > > /* audit_rule_data supports filter rules with both integer and string > >* fields. It corresponds with AUDIT_ADD_RULE, AUDIT_DEL_RULE and > > diff --git a/kernel/auditsc.c b/kernel/auditsc.c > > index 4e0a4ac..0ee1e59 100644 > > --- a/kernel/auditsc.c > > +++ b/kernel/auditsc.c > > @@ -2073,6 +2073,92 @@ int audit_set_loginuid(kuid_t loginuid) > > return rc; > > } > > > > +static int audit_set_containerid_perm(struct task_struct *task, u64 > > containerid) > > +{ > > + struct task_struct *parent; > > + u64 pcontainerid, ccontainerid; > > + pid_t ppid; > > + > > + /* Don't allow to set our own containerid */ > > + if (current == task) > > + return -EPERM; > > + /* Don't allow the containerid to be unset */ > > + if (!cid_valid(containerid)) > > + return -EINVAL; > > + /* if we don't have caps, reject */ > > + if (!capable(CAP_AUDIT_CONTROL)) > > + return -EPERM; > > + /* if containerid is unset, allow */ > > + if (!audit_containerid_set(task)) > > + return 0; > > I am wondering whether there should be a check for the target process that > will receive the containerid to not have CAP_SYS_ADMIN that would otherwise > allow it to arbitrarily unshare()/clone() and leave the set of namespaces > that may make up the container whose containerid we assign here? This is a reasonable question. This has been debated and I understood the conclusion was that without a clear definition of a "container", the task still remains in that container that just now has more sub-namespaces (in the case of hierarchical namespaces), we don't want to restrict it in such a way and that allows it to create nested containers. I see setns being more problematic if it could switch to another existing namespace that was set up by the orchestrator for a different container. The coming v2 patchset acknowledges this situation with the network namespace being potentially shared by multiple containers. This is the motivation for the code below that allows to set the containerid even if it is already inherited from its parent. > > + /* it is already set, and not inherited from the parent, reject */ > > + ccontainerid = audit_get_containerid(task); > > + rcu_read_lock(); > > + parent = rcu_dereference(task->real_parent); > > + rcu_read_unlock(); > > + task_lock(parent); > > + pcontainerid = audit_get_containerid(parent); > > + ppid = task_tgid_nr(parent); > > ppid not needed... Thanks for catching this. It was the vestige of a failed devel experiment that didn't flush that useless appendage. :-) > > + task_unlock(parent); > > + if (ccontainerid != pcontainerid) > > + return -EPERM; > > + return 0; > > +} > > + > > +static void audit_log_set_containerid(struct task_struct *task, u64 > > oldcontainerid, > > + u64 containerid, int rc) > > +{ > > + struct audit_buffer *ab; > > + uid_t uid; > > + struct tty_struct *tty; > > + > > + if (!audit_enabled) > > + return; > > + > > + ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_CONTAINER); > > + if (!ab) > > + return; > > + > > + uid = from_kuid(_user_ns, task_uid(current)); > > + tty = audit_get_tty(current); > > + > > + audit_log_format(ab, "op=set pid=%d uid=%u", task_tgid_nr(current), > > uid); > > + audit_log_task_context(ab); > > + audit_log_format(ab, " auid=%u tty=%s ses=%u opid=%d old-contid=%llu > > contid=%llu res=%d", > > +from_kuid(_user_ns, audit_get_loginuid(current)), > > +tty ? tty_name(tty) :
Re: mmotm 2018-03-14-16-24 uploaded (lustre)
On Thu, Mar 15 2018, Randy Dunlap wrote: > On 03/14/2018 04:24 PM, a...@linux-foundation.org wrote: >> The mm-of-the-moment snapshot 2018-03-14-16-24 has been uploaded to >> >>http://www.ozlabs.org/~akpm/mmotm/ > > (not from the mmotm patches, but in its linux-next.patch) > > CONFIG_LUSTRE_FS=y > # CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK is not set > > > In file included from > ../drivers/staging/lustre/include/linux/libcfs/libcfs.h:42:0, > from > ../drivers/staging/lustre/lustre/obdclass/lu_object.c:44: > ../drivers/staging/lustre/lustre/obdclass/lu_object.c: In function > 'lu_context_key_degister': > ../drivers/staging/lustre/lustre/obdclass/lu_object.c:1410:51: error: > dereferencing pointer to incomplete type > __func__, key->lct_owner ? key->lct_owner->name : "", >^ Thanks for the report. Arnd Bergmann posted a patch to fix this on Tuesday Message-Id: <20180313130425.3975930-1-a...@arndb.de> http://lkml.kernel.org/r/<20180313130425.3975930-1-a...@arndb.de> so the error should disappear soon. Thanks, NeilBrown > ../drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h:123:41: note: > in definition of macro '__CDEBUG' >libcfs_debug_msg(, format, ## __VA_ARGS__); \ > ^ > ../drivers/staging/lustre/lustre/obdclass/lu_object.c:1409:3: note: in > expansion of macro 'CDEBUG' >CDEBUG(D_INFO, "%s: \"%s\" %p, %d\n", >^ > ../drivers/staging/lustre/lustre/obdclass/lu_object.c: In function > 'lu_context_key_quiesce': > ../drivers/staging/lustre/lustre/obdclass/lu_object.c:1550:42: error: > dereferencing pointer to incomplete type >key->lct_owner ? key->lct_owner->name : "", > ^ > ../drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h:123:41: note: > in definition of macro '__CDEBUG' >libcfs_debug_msg(, format, ## __VA_ARGS__); \ > ^ > ../drivers/staging/lustre/lustre/obdclass/lu_object.c:1548:4: note: in > expansion of macro 'CDEBUG' > CDEBUG(D_INFO, "%s: \"%s\" %p, %d (%d)\n", > ^ > > > > -- > ~Randy signature.asc Description: PGP signature
Re: mmotm 2018-03-14-16-24 uploaded (lustre)
On Thu, Mar 15 2018, Randy Dunlap wrote: > On 03/14/2018 04:24 PM, a...@linux-foundation.org wrote: >> The mm-of-the-moment snapshot 2018-03-14-16-24 has been uploaded to >> >>http://www.ozlabs.org/~akpm/mmotm/ > > (not from the mmotm patches, but in its linux-next.patch) > > CONFIG_LUSTRE_FS=y > # CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK is not set > > > In file included from > ../drivers/staging/lustre/include/linux/libcfs/libcfs.h:42:0, > from > ../drivers/staging/lustre/lustre/obdclass/lu_object.c:44: > ../drivers/staging/lustre/lustre/obdclass/lu_object.c: In function > 'lu_context_key_degister': > ../drivers/staging/lustre/lustre/obdclass/lu_object.c:1410:51: error: > dereferencing pointer to incomplete type > __func__, key->lct_owner ? key->lct_owner->name : "", >^ Thanks for the report. Arnd Bergmann posted a patch to fix this on Tuesday Message-Id: <20180313130425.3975930-1-a...@arndb.de> http://lkml.kernel.org/r/<20180313130425.3975930-1-a...@arndb.de> so the error should disappear soon. Thanks, NeilBrown > ../drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h:123:41: note: > in definition of macro '__CDEBUG' >libcfs_debug_msg(, format, ## __VA_ARGS__); \ > ^ > ../drivers/staging/lustre/lustre/obdclass/lu_object.c:1409:3: note: in > expansion of macro 'CDEBUG' >CDEBUG(D_INFO, "%s: \"%s\" %p, %d\n", >^ > ../drivers/staging/lustre/lustre/obdclass/lu_object.c: In function > 'lu_context_key_quiesce': > ../drivers/staging/lustre/lustre/obdclass/lu_object.c:1550:42: error: > dereferencing pointer to incomplete type >key->lct_owner ? key->lct_owner->name : "", > ^ > ../drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h:123:41: note: > in definition of macro '__CDEBUG' >libcfs_debug_msg(, format, ## __VA_ARGS__); \ > ^ > ../drivers/staging/lustre/lustre/obdclass/lu_object.c:1548:4: note: in > expansion of macro 'CDEBUG' > CDEBUG(D_INFO, "%s: \"%s\" %p, %d (%d)\n", > ^ > > > > -- > ~Randy signature.asc Description: PGP signature
[PATCH v8 39/42] ARM: davinci: remove legacy clocks
This removes the unused legacy clock code from arch/arm/mach-davinci/. Signed-off-by: David LechnerReviewed-by: Sekhar Nori --- v8 changes: - none v7 changes: - none v6 changes: - none arch/arm/mach-davinci/clock.c | 745 arch/arm/mach-davinci/clock.h | 72 --- arch/arm/mach-davinci/common.c | 2 - arch/arm/mach-davinci/devices.c | 1 - arch/arm/mach-davinci/include/mach/clock.h | 3 - arch/arm/mach-davinci/include/mach/common.h | 2 - arch/arm/mach-davinci/psc.c | 137 - arch/arm/mach-davinci/psc.h | 10 - arch/arm/mach-davinci/time.c| 2 - 9 files changed, 974 deletions(-) delete mode 100644 arch/arm/mach-davinci/clock.c delete mode 100644 arch/arm/mach-davinci/psc.c diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c deleted file mode 100644 index f77a4f7..000 --- a/arch/arm/mach-davinci/clock.c +++ /dev/null @@ -1,745 +0,0 @@ -/* - * Clock and PLL control for DaVinci devices - * - * Copyright (C) 2006-2007 Texas Instruments. - * Copyright (C) 2008-2009 Deep Root Systems, LLC - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include "psc.h" -#include -#include "clock.h" - -static LIST_HEAD(clocks); -static DEFINE_MUTEX(clocks_mutex); -static DEFINE_SPINLOCK(clockfw_lock); - -void davinci_clk_enable(struct clk *clk) -{ - if (clk->parent) - davinci_clk_enable(clk->parent); - if (clk->usecount++ == 0) { - if (clk->flags & CLK_PSC) - davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc, - true, clk->flags); - else if (clk->clk_enable) - clk->clk_enable(clk); - } -} - -void davinci_clk_disable(struct clk *clk) -{ - if (WARN_ON(clk->usecount == 0)) - return; - if (--clk->usecount == 0) { - if (!(clk->flags & CLK_PLL) && (clk->flags & CLK_PSC)) - davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc, - false, clk->flags); - else if (clk->clk_disable) - clk->clk_disable(clk); - } - if (clk->parent) - davinci_clk_disable(clk->parent); -} - -int davinci_clk_reset(struct clk *clk, bool reset) -{ - unsigned long flags; - - if (clk == NULL || IS_ERR(clk)) - return -EINVAL; - - spin_lock_irqsave(_lock, flags); - if (clk->flags & CLK_PSC) - davinci_psc_reset(clk->gpsc, clk->lpsc, reset); - spin_unlock_irqrestore(_lock, flags); - - return 0; -} -EXPORT_SYMBOL(davinci_clk_reset); - -int davinci_clk_reset_assert(struct clk *clk) -{ - if (clk == NULL || IS_ERR(clk) || !clk->reset) - return -EINVAL; - - return clk->reset(clk, true); -} -EXPORT_SYMBOL(davinci_clk_reset_assert); - -int davinci_clk_reset_deassert(struct clk *clk) -{ - if (clk == NULL || IS_ERR(clk) || !clk->reset) - return -EINVAL; - - return clk->reset(clk, false); -} -EXPORT_SYMBOL(davinci_clk_reset_deassert); - -int clk_enable(struct clk *clk) -{ - unsigned long flags; - - if (!clk) - return 0; - else if (IS_ERR(clk)) - return -EINVAL; - - spin_lock_irqsave(_lock, flags); - davinci_clk_enable(clk); - spin_unlock_irqrestore(_lock, flags); - - return 0; -} -EXPORT_SYMBOL(clk_enable); - -void clk_disable(struct clk *clk) -{ - unsigned long flags; - - if (clk == NULL || IS_ERR(clk)) - return; - - spin_lock_irqsave(_lock, flags); - davinci_clk_disable(clk); - spin_unlock_irqrestore(_lock, flags); -} -EXPORT_SYMBOL(clk_disable); - -unsigned long clk_get_rate(struct clk *clk) -{ - if (clk == NULL || IS_ERR(clk)) - return 0; - - return clk->rate; -} -EXPORT_SYMBOL(clk_get_rate); - -long clk_round_rate(struct clk *clk, unsigned long rate) -{ - if (clk == NULL || IS_ERR(clk)) - return 0; - - if (clk->round_rate) - return clk->round_rate(clk, rate); - - return clk->rate; -} -EXPORT_SYMBOL(clk_round_rate); - -/* Propagate rate to children */ -static void propagate_rate(struct clk *root) -{ - struct clk *clk; - - list_for_each_entry(clk, >children, childnode) { - if (clk->recalc) - clk->rate = clk->recalc(clk); - propagate_rate(clk); - } -} -
[PATCH v8 39/42] ARM: davinci: remove legacy clocks
This removes the unused legacy clock code from arch/arm/mach-davinci/. Signed-off-by: David Lechner Reviewed-by: Sekhar Nori --- v8 changes: - none v7 changes: - none v6 changes: - none arch/arm/mach-davinci/clock.c | 745 arch/arm/mach-davinci/clock.h | 72 --- arch/arm/mach-davinci/common.c | 2 - arch/arm/mach-davinci/devices.c | 1 - arch/arm/mach-davinci/include/mach/clock.h | 3 - arch/arm/mach-davinci/include/mach/common.h | 2 - arch/arm/mach-davinci/psc.c | 137 - arch/arm/mach-davinci/psc.h | 10 - arch/arm/mach-davinci/time.c| 2 - 9 files changed, 974 deletions(-) delete mode 100644 arch/arm/mach-davinci/clock.c delete mode 100644 arch/arm/mach-davinci/psc.c diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c deleted file mode 100644 index f77a4f7..000 --- a/arch/arm/mach-davinci/clock.c +++ /dev/null @@ -1,745 +0,0 @@ -/* - * Clock and PLL control for DaVinci devices - * - * Copyright (C) 2006-2007 Texas Instruments. - * Copyright (C) 2008-2009 Deep Root Systems, LLC - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include "psc.h" -#include -#include "clock.h" - -static LIST_HEAD(clocks); -static DEFINE_MUTEX(clocks_mutex); -static DEFINE_SPINLOCK(clockfw_lock); - -void davinci_clk_enable(struct clk *clk) -{ - if (clk->parent) - davinci_clk_enable(clk->parent); - if (clk->usecount++ == 0) { - if (clk->flags & CLK_PSC) - davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc, - true, clk->flags); - else if (clk->clk_enable) - clk->clk_enable(clk); - } -} - -void davinci_clk_disable(struct clk *clk) -{ - if (WARN_ON(clk->usecount == 0)) - return; - if (--clk->usecount == 0) { - if (!(clk->flags & CLK_PLL) && (clk->flags & CLK_PSC)) - davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc, - false, clk->flags); - else if (clk->clk_disable) - clk->clk_disable(clk); - } - if (clk->parent) - davinci_clk_disable(clk->parent); -} - -int davinci_clk_reset(struct clk *clk, bool reset) -{ - unsigned long flags; - - if (clk == NULL || IS_ERR(clk)) - return -EINVAL; - - spin_lock_irqsave(_lock, flags); - if (clk->flags & CLK_PSC) - davinci_psc_reset(clk->gpsc, clk->lpsc, reset); - spin_unlock_irqrestore(_lock, flags); - - return 0; -} -EXPORT_SYMBOL(davinci_clk_reset); - -int davinci_clk_reset_assert(struct clk *clk) -{ - if (clk == NULL || IS_ERR(clk) || !clk->reset) - return -EINVAL; - - return clk->reset(clk, true); -} -EXPORT_SYMBOL(davinci_clk_reset_assert); - -int davinci_clk_reset_deassert(struct clk *clk) -{ - if (clk == NULL || IS_ERR(clk) || !clk->reset) - return -EINVAL; - - return clk->reset(clk, false); -} -EXPORT_SYMBOL(davinci_clk_reset_deassert); - -int clk_enable(struct clk *clk) -{ - unsigned long flags; - - if (!clk) - return 0; - else if (IS_ERR(clk)) - return -EINVAL; - - spin_lock_irqsave(_lock, flags); - davinci_clk_enable(clk); - spin_unlock_irqrestore(_lock, flags); - - return 0; -} -EXPORT_SYMBOL(clk_enable); - -void clk_disable(struct clk *clk) -{ - unsigned long flags; - - if (clk == NULL || IS_ERR(clk)) - return; - - spin_lock_irqsave(_lock, flags); - davinci_clk_disable(clk); - spin_unlock_irqrestore(_lock, flags); -} -EXPORT_SYMBOL(clk_disable); - -unsigned long clk_get_rate(struct clk *clk) -{ - if (clk == NULL || IS_ERR(clk)) - return 0; - - return clk->rate; -} -EXPORT_SYMBOL(clk_get_rate); - -long clk_round_rate(struct clk *clk, unsigned long rate) -{ - if (clk == NULL || IS_ERR(clk)) - return 0; - - if (clk->round_rate) - return clk->round_rate(clk, rate); - - return clk->rate; -} -EXPORT_SYMBOL(clk_round_rate); - -/* Propagate rate to children */ -static void propagate_rate(struct clk *root) -{ - struct clk *clk; - - list_for_each_entry(clk, >children, childnode) { - if (clk->recalc) - clk->rate = clk->recalc(clk); - propagate_rate(clk); - } -} - -int clk_set_rate(struct clk *clk,
[PATCH v8 34/42] ARM: davinci: dm355: Remove legacy clock init
This removes the unused legacy clock init code from arch/arm/mach-davinci/dm355.c. Signed-off-by: David LechnerReviewed-by: Sekhar Nori --- v8 changes: - none v7 changes: - rebased - add davinci prefix to commit message v6 changes: - rebased arch/arm/mach-davinci/dm355.c | 357 -- 1 file changed, 357 deletions(-) diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c index f53e07a..a2d1246 100644 --- a/arch/arm/mach-davinci/dm355.c +++ b/arch/arm/mach-davinci/dm355.c @@ -32,11 +32,6 @@ #include "davinci.h" #include "mux.h" -#ifndef CONFIG_COMMON_CLK -#include "clock.h" -#include "psc.h" -#endif - #define DM355_UART2_BASE (IO_PHYS + 0x206000) #define DM355_OSD_BASE (IO_PHYS + 0x70200) #define DM355_VENC_BASE(IO_PHYS + 0x70400) @@ -46,349 +41,6 @@ */ #define DM355_REF_FREQ 2400/* 24 or 36 MHz */ -#ifndef CONFIG_COMMON_CLK -static struct pll_data pll1_data = { - .num = 1, - .phys_base = DAVINCI_PLL1_BASE, - .flags = PLL_HAS_PREDIV | PLL_HAS_POSTDIV, -}; - -static struct pll_data pll2_data = { - .num = 2, - .phys_base = DAVINCI_PLL2_BASE, - .flags = PLL_HAS_PREDIV, -}; - -static struct clk ref_clk = { - .name = "ref_clk", - /* FIXME -- crystal rate is board-specific */ - .rate = DM355_REF_FREQ, -}; - -static struct clk pll1_clk = { - .name = "pll1", - .parent = _clk, - .flags = CLK_PLL, - .pll_data = _data, -}; - -static struct clk pll1_aux_clk = { - .name = "pll1_aux_clk", - .parent = _clk, - .flags = CLK_PLL | PRE_PLL, -}; - -static struct clk pll1_sysclk1 = { - .name = "pll1_sysclk1", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV1, -}; - -static struct clk pll1_sysclk2 = { - .name = "pll1_sysclk2", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV2, -}; - -static struct clk pll1_sysclk3 = { - .name = "pll1_sysclk3", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV3, -}; - -static struct clk pll1_sysclk4 = { - .name = "pll1_sysclk4", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV4, -}; - -static struct clk pll1_sysclkbp = { - .name = "pll1_sysclkbp", - .parent = _clk, - .flags = CLK_PLL | PRE_PLL, - .div_reg = BPDIV -}; - -static struct clk vpss_dac_clk = { - .name = "vpss_dac", - .parent = _sysclk3, - .lpsc = DM355_LPSC_VPSS_DAC, -}; - -static struct clk vpss_master_clk = { - .name = "vpss_master", - .parent = _sysclk4, - .lpsc = DAVINCI_LPSC_VPSSMSTR, - .flags = CLK_PSC, -}; - -static struct clk vpss_slave_clk = { - .name = "vpss_slave", - .parent = _sysclk4, - .lpsc = DAVINCI_LPSC_VPSSSLV, -}; - -static struct clk clkout1_clk = { - .name = "clkout1", - .parent = _aux_clk, - /* NOTE: clkout1 can be externally gated by muxing GPIO-18 */ -}; - -static struct clk clkout2_clk = { - .name = "clkout2", - .parent = _sysclkbp, -}; - -static struct clk pll2_clk = { - .name = "pll2", - .parent = _clk, - .flags = CLK_PLL, - .pll_data = _data, -}; - -static struct clk pll2_sysclk1 = { - .name = "pll2_sysclk1", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV1, -}; - -static struct clk pll2_sysclkbp = { - .name = "pll2_sysclkbp", - .parent = _clk, - .flags = CLK_PLL | PRE_PLL, - .div_reg = BPDIV -}; - -static struct clk clkout3_clk = { - .name = "clkout3", - .parent = _sysclkbp, - /* NOTE: clkout3 can be externally gated by muxing GPIO-16 */ -}; - -static struct clk arm_clk = { - .name = "arm_clk", - .parent = _sysclk1, - .lpsc = DAVINCI_LPSC_ARM, - .flags = ALWAYS_ENABLED, -}; - -/* - * NOT LISTED below, and not touched by Linux - * - in SyncReset state by default - * .lpsc = DAVINCI_LPSC_TPCC, - * .lpsc = DAVINCI_LPSC_TPTC0, - * .lpsc = DAVINCI_LPSC_TPTC1, - * .lpsc = DAVINCI_LPSC_DDR_EMIF, .parent = _clk, - * .lpsc = DAVINCI_LPSC_MEMSTICK, - * - in Enabled state by default - * .lpsc = DAVINCI_LPSC_SYSTEM_SUBSYS, - * .lpsc = DAVINCI_LPSC_SCR2, // "bus" - * .lpsc = DAVINCI_LPSC_SCR3, // "bus" - * .lpsc = DAVINCI_LPSC_SCR4, // "bus" - * .lpsc = DAVINCI_LPSC_CROSSBAR, // "emulation" - * .lpsc = DAVINCI_LPSC_CFG27, // "test" - * .lpsc = DAVINCI_LPSC_CFG3, // "test" - * .lpsc = DAVINCI_LPSC_CFG5, // "test" - */ - -static struct clk mjcp_clk = { - .name = "mjcp", - .parent = _sysclk1, - .lpsc = DAVINCI_LPSC_IMCOP, -}; - -static struct clk uart0_clk = { - .name = "uart0", - .parent = _aux_clk, - .lpsc = DAVINCI_LPSC_UART0, -}; - -static struct clk
[PATCH v8 34/42] ARM: davinci: dm355: Remove legacy clock init
This removes the unused legacy clock init code from arch/arm/mach-davinci/dm355.c. Signed-off-by: David Lechner Reviewed-by: Sekhar Nori --- v8 changes: - none v7 changes: - rebased - add davinci prefix to commit message v6 changes: - rebased arch/arm/mach-davinci/dm355.c | 357 -- 1 file changed, 357 deletions(-) diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c index f53e07a..a2d1246 100644 --- a/arch/arm/mach-davinci/dm355.c +++ b/arch/arm/mach-davinci/dm355.c @@ -32,11 +32,6 @@ #include "davinci.h" #include "mux.h" -#ifndef CONFIG_COMMON_CLK -#include "clock.h" -#include "psc.h" -#endif - #define DM355_UART2_BASE (IO_PHYS + 0x206000) #define DM355_OSD_BASE (IO_PHYS + 0x70200) #define DM355_VENC_BASE(IO_PHYS + 0x70400) @@ -46,349 +41,6 @@ */ #define DM355_REF_FREQ 2400/* 24 or 36 MHz */ -#ifndef CONFIG_COMMON_CLK -static struct pll_data pll1_data = { - .num = 1, - .phys_base = DAVINCI_PLL1_BASE, - .flags = PLL_HAS_PREDIV | PLL_HAS_POSTDIV, -}; - -static struct pll_data pll2_data = { - .num = 2, - .phys_base = DAVINCI_PLL2_BASE, - .flags = PLL_HAS_PREDIV, -}; - -static struct clk ref_clk = { - .name = "ref_clk", - /* FIXME -- crystal rate is board-specific */ - .rate = DM355_REF_FREQ, -}; - -static struct clk pll1_clk = { - .name = "pll1", - .parent = _clk, - .flags = CLK_PLL, - .pll_data = _data, -}; - -static struct clk pll1_aux_clk = { - .name = "pll1_aux_clk", - .parent = _clk, - .flags = CLK_PLL | PRE_PLL, -}; - -static struct clk pll1_sysclk1 = { - .name = "pll1_sysclk1", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV1, -}; - -static struct clk pll1_sysclk2 = { - .name = "pll1_sysclk2", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV2, -}; - -static struct clk pll1_sysclk3 = { - .name = "pll1_sysclk3", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV3, -}; - -static struct clk pll1_sysclk4 = { - .name = "pll1_sysclk4", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV4, -}; - -static struct clk pll1_sysclkbp = { - .name = "pll1_sysclkbp", - .parent = _clk, - .flags = CLK_PLL | PRE_PLL, - .div_reg = BPDIV -}; - -static struct clk vpss_dac_clk = { - .name = "vpss_dac", - .parent = _sysclk3, - .lpsc = DM355_LPSC_VPSS_DAC, -}; - -static struct clk vpss_master_clk = { - .name = "vpss_master", - .parent = _sysclk4, - .lpsc = DAVINCI_LPSC_VPSSMSTR, - .flags = CLK_PSC, -}; - -static struct clk vpss_slave_clk = { - .name = "vpss_slave", - .parent = _sysclk4, - .lpsc = DAVINCI_LPSC_VPSSSLV, -}; - -static struct clk clkout1_clk = { - .name = "clkout1", - .parent = _aux_clk, - /* NOTE: clkout1 can be externally gated by muxing GPIO-18 */ -}; - -static struct clk clkout2_clk = { - .name = "clkout2", - .parent = _sysclkbp, -}; - -static struct clk pll2_clk = { - .name = "pll2", - .parent = _clk, - .flags = CLK_PLL, - .pll_data = _data, -}; - -static struct clk pll2_sysclk1 = { - .name = "pll2_sysclk1", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV1, -}; - -static struct clk pll2_sysclkbp = { - .name = "pll2_sysclkbp", - .parent = _clk, - .flags = CLK_PLL | PRE_PLL, - .div_reg = BPDIV -}; - -static struct clk clkout3_clk = { - .name = "clkout3", - .parent = _sysclkbp, - /* NOTE: clkout3 can be externally gated by muxing GPIO-16 */ -}; - -static struct clk arm_clk = { - .name = "arm_clk", - .parent = _sysclk1, - .lpsc = DAVINCI_LPSC_ARM, - .flags = ALWAYS_ENABLED, -}; - -/* - * NOT LISTED below, and not touched by Linux - * - in SyncReset state by default - * .lpsc = DAVINCI_LPSC_TPCC, - * .lpsc = DAVINCI_LPSC_TPTC0, - * .lpsc = DAVINCI_LPSC_TPTC1, - * .lpsc = DAVINCI_LPSC_DDR_EMIF, .parent = _clk, - * .lpsc = DAVINCI_LPSC_MEMSTICK, - * - in Enabled state by default - * .lpsc = DAVINCI_LPSC_SYSTEM_SUBSYS, - * .lpsc = DAVINCI_LPSC_SCR2, // "bus" - * .lpsc = DAVINCI_LPSC_SCR3, // "bus" - * .lpsc = DAVINCI_LPSC_SCR4, // "bus" - * .lpsc = DAVINCI_LPSC_CROSSBAR, // "emulation" - * .lpsc = DAVINCI_LPSC_CFG27, // "test" - * .lpsc = DAVINCI_LPSC_CFG3, // "test" - * .lpsc = DAVINCI_LPSC_CFG5, // "test" - */ - -static struct clk mjcp_clk = { - .name = "mjcp", - .parent = _sysclk1, - .lpsc = DAVINCI_LPSC_IMCOP, -}; - -static struct clk uart0_clk = { - .name = "uart0", - .parent = _aux_clk, - .lpsc = DAVINCI_LPSC_UART0, -}; - -static struct clk uart1_clk = { - .name = "uart1", -
[PATCH v8 40/42] ARM: davinci: add device tree support to timer
This adds device tree support to the davinci timer so that when clocks are moved to device tree, the timer will still work. Signed-off-by: David Lechner--- v8 changes: - none v7 changes: - add workaround for platform devices not available in early boot v6 changes: - none arch/arm/mach-davinci/Kconfig | 1 + arch/arm/mach-davinci/time.c | 31 +++ 2 files changed, 32 insertions(+) diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig index ba9912b..da8a039 100644 --- a/arch/arm/mach-davinci/Kconfig +++ b/arch/arm/mach-davinci/Kconfig @@ -59,6 +59,7 @@ config MACH_DA8XX_DT default y depends on ARCH_DAVINCI_DA850 select PINCTRL + select TIMER_OF help Say y here to include support for TI DaVinci DA850 based using Flattened Device Tree. More information at Documentation/devicetree diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c index d6a78f7..590b118 100644 --- a/arch/arm/mach-davinci/time.c +++ b/arch/arm/mach-davinci/time.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -405,3 +406,33 @@ void __init davinci_timer_init(struct clk *timer_clk) for (i=0; i< ARRAY_SIZE(timers); i++) timer32_config([i]); } + +static int __init of_davinci_timer_init(struct device_node *np) +{ + struct clk *clk; + + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) { + struct of_phandle_args clkspec; + + /* +* Fall back to using ref_clk if the actual clock is not +* available. This currently always happens because platform +* clocks (i.e PLLs and PSCs) are registered as platform +* devices and therefore are not available at this point in +* the boot process. +*/ + clkspec.np = of_find_node_by_name(NULL, "ref_clk"); + if (IS_ERR(clkspec.np)) { + pr_err("%s: No clock available for timer!\n", __func__); + return PTR_ERR(clkspec.np); + } + clk = of_clk_get_from_provider(); + of_node_put(clkspec.np); + } + + davinci_timer_init(clk); + + return 0; +} +TIMER_OF_DECLARE(davinci_timer, "ti,davinci-timer", of_davinci_timer_init); -- 2.7.4
[PATCH v8 40/42] ARM: davinci: add device tree support to timer
This adds device tree support to the davinci timer so that when clocks are moved to device tree, the timer will still work. Signed-off-by: David Lechner --- v8 changes: - none v7 changes: - add workaround for platform devices not available in early boot v6 changes: - none arch/arm/mach-davinci/Kconfig | 1 + arch/arm/mach-davinci/time.c | 31 +++ 2 files changed, 32 insertions(+) diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig index ba9912b..da8a039 100644 --- a/arch/arm/mach-davinci/Kconfig +++ b/arch/arm/mach-davinci/Kconfig @@ -59,6 +59,7 @@ config MACH_DA8XX_DT default y depends on ARCH_DAVINCI_DA850 select PINCTRL + select TIMER_OF help Say y here to include support for TI DaVinci DA850 based using Flattened Device Tree. More information at Documentation/devicetree diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c index d6a78f7..590b118 100644 --- a/arch/arm/mach-davinci/time.c +++ b/arch/arm/mach-davinci/time.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -405,3 +406,33 @@ void __init davinci_timer_init(struct clk *timer_clk) for (i=0; i< ARRAY_SIZE(timers); i++) timer32_config([i]); } + +static int __init of_davinci_timer_init(struct device_node *np) +{ + struct clk *clk; + + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) { + struct of_phandle_args clkspec; + + /* +* Fall back to using ref_clk if the actual clock is not +* available. This currently always happens because platform +* clocks (i.e PLLs and PSCs) are registered as platform +* devices and therefore are not available at this point in +* the boot process. +*/ + clkspec.np = of_find_node_by_name(NULL, "ref_clk"); + if (IS_ERR(clkspec.np)) { + pr_err("%s: No clock available for timer!\n", __func__); + return PTR_ERR(clkspec.np); + } + clk = of_clk_get_from_provider(); + of_node_put(clkspec.np); + } + + davinci_timer_init(clk); + + return 0; +} +TIMER_OF_DECLARE(davinci_timer, "ti,davinci-timer", of_davinci_timer_init); -- 2.7.4
[PATCH v8 37/42] ARM: davinci: dm646x: Remove legacy clock init
This removes the unused legacy clock init code from arch/arm/mach-davinci/dm646x.c. Signed-off-by: David LechnerReviewed-by: Sekhar Nori --- v8 changes: - rebased v7 changes: - rebased - add davinci prefix to commit message v6 changes: - rebased arch/arm/mach-davinci/dm646x.c | 329 - 1 file changed, 329 deletions(-) diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c index 553782f..d14ffd6 100644 --- a/arch/arm/mach-davinci/dm646x.c +++ b/arch/arm/mach-davinci/dm646x.c @@ -31,11 +31,6 @@ #include "davinci.h" #include "mux.h" -#ifndef CONFIG_COMMON_CLK -#include "clock.h" -#include "psc.h" -#endif - #define DAVINCI_VPIF_BASE (0x01C12000) #define VDD3P3V_VID_MASK (BIT_MASK(3) | BIT_MASK(2) | BIT_MASK(1) |\ @@ -50,319 +45,6 @@ #define DM646X_EMAC_CNTRL_RAM_OFFSET 0x2000 #define DM646X_EMAC_CNTRL_RAM_SIZE 0x2000 -#ifndef CONFIG_COMMON_CLK -static struct pll_data pll1_data = { - .num = 1, - .phys_base = DAVINCI_PLL1_BASE, -}; - -static struct pll_data pll2_data = { - .num = 2, - .phys_base = DAVINCI_PLL2_BASE, -}; - -static struct clk ref_clk = { - .name = "ref_clk", - /* rate is initialized in dm646x_init_time() */ -}; - -static struct clk aux_clkin = { - .name = "aux_clkin", - /* rate is initialized in dm646x_init_time() */ -}; - -static struct clk pll1_clk = { - .name = "pll1", - .parent = _clk, - .pll_data = _data, - .flags = CLK_PLL, -}; - -static struct clk pll1_sysclk1 = { - .name = "pll1_sysclk1", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV1, -}; - -static struct clk pll1_sysclk2 = { - .name = "pll1_sysclk2", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV2, -}; - -static struct clk pll1_sysclk3 = { - .name = "pll1_sysclk3", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV3, -}; - -static struct clk pll1_sysclk4 = { - .name = "pll1_sysclk4", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV4, -}; - -static struct clk pll1_sysclk5 = { - .name = "pll1_sysclk5", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV5, -}; - -static struct clk pll1_sysclk6 = { - .name = "pll1_sysclk6", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV6, -}; - -static struct clk pll1_sysclk8 = { - .name = "pll1_sysclk8", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV8, -}; - -static struct clk pll1_sysclk9 = { - .name = "pll1_sysclk9", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV9, -}; - -static struct clk pll1_sysclkbp = { - .name = "pll1_sysclkbp", - .parent = _clk, - .flags = CLK_PLL | PRE_PLL, - .div_reg = BPDIV, -}; - -static struct clk pll1_aux_clk = { - .name = "pll1_aux_clk", - .parent = _clk, - .flags = CLK_PLL | PRE_PLL, -}; - -static struct clk pll2_clk = { - .name = "pll2_clk", - .parent = _clk, - .pll_data = _data, - .flags = CLK_PLL, -}; - -static struct clk pll2_sysclk1 = { - .name = "pll2_sysclk1", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV1, -}; - -static struct clk dsp_clk = { - .name = "dsp", - .parent = _sysclk1, - .lpsc = DM646X_LPSC_C64X_CPU, - .usecount = 1, /* REVISIT how to disable? */ -}; - -static struct clk arm_clk = { - .name = "arm", - .parent = _sysclk2, - .lpsc = DM646X_LPSC_ARM, - .flags = ALWAYS_ENABLED, -}; - -static struct clk edma_cc_clk = { - .name = "edma_cc", - .parent = _sysclk2, - .lpsc = DM646X_LPSC_TPCC, - .flags = ALWAYS_ENABLED, -}; - -static struct clk edma_tc0_clk = { - .name = "edma_tc0", - .parent = _sysclk2, - .lpsc = DM646X_LPSC_TPTC0, - .flags = ALWAYS_ENABLED, -}; - -static struct clk edma_tc1_clk = { - .name = "edma_tc1", - .parent = _sysclk2, - .lpsc = DM646X_LPSC_TPTC1, - .flags = ALWAYS_ENABLED, -}; - -static struct clk edma_tc2_clk = { - .name = "edma_tc2", - .parent = _sysclk2, - .lpsc = DM646X_LPSC_TPTC2, - .flags = ALWAYS_ENABLED, -}; - -static struct clk edma_tc3_clk = { - .name = "edma_tc3", - .parent = _sysclk2, - .lpsc = DM646X_LPSC_TPTC3, - .flags = ALWAYS_ENABLED, -}; - -static struct clk uart0_clk = { - .name = "uart0", - .parent = _clkin, - .lpsc = DM646X_LPSC_UART0, -}; - -static struct clk uart1_clk = { - .name = "uart1", - .parent = _clkin, - .lpsc = DM646X_LPSC_UART1, -}; - -static struct clk uart2_clk = { - .name = "uart2", - .parent = _clkin, - .lpsc = DM646X_LPSC_UART2, -}; - -static struct clk i2c_clk = { - .name =
[PATCH v8 37/42] ARM: davinci: dm646x: Remove legacy clock init
This removes the unused legacy clock init code from arch/arm/mach-davinci/dm646x.c. Signed-off-by: David Lechner Reviewed-by: Sekhar Nori --- v8 changes: - rebased v7 changes: - rebased - add davinci prefix to commit message v6 changes: - rebased arch/arm/mach-davinci/dm646x.c | 329 - 1 file changed, 329 deletions(-) diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c index 553782f..d14ffd6 100644 --- a/arch/arm/mach-davinci/dm646x.c +++ b/arch/arm/mach-davinci/dm646x.c @@ -31,11 +31,6 @@ #include "davinci.h" #include "mux.h" -#ifndef CONFIG_COMMON_CLK -#include "clock.h" -#include "psc.h" -#endif - #define DAVINCI_VPIF_BASE (0x01C12000) #define VDD3P3V_VID_MASK (BIT_MASK(3) | BIT_MASK(2) | BIT_MASK(1) |\ @@ -50,319 +45,6 @@ #define DM646X_EMAC_CNTRL_RAM_OFFSET 0x2000 #define DM646X_EMAC_CNTRL_RAM_SIZE 0x2000 -#ifndef CONFIG_COMMON_CLK -static struct pll_data pll1_data = { - .num = 1, - .phys_base = DAVINCI_PLL1_BASE, -}; - -static struct pll_data pll2_data = { - .num = 2, - .phys_base = DAVINCI_PLL2_BASE, -}; - -static struct clk ref_clk = { - .name = "ref_clk", - /* rate is initialized in dm646x_init_time() */ -}; - -static struct clk aux_clkin = { - .name = "aux_clkin", - /* rate is initialized in dm646x_init_time() */ -}; - -static struct clk pll1_clk = { - .name = "pll1", - .parent = _clk, - .pll_data = _data, - .flags = CLK_PLL, -}; - -static struct clk pll1_sysclk1 = { - .name = "pll1_sysclk1", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV1, -}; - -static struct clk pll1_sysclk2 = { - .name = "pll1_sysclk2", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV2, -}; - -static struct clk pll1_sysclk3 = { - .name = "pll1_sysclk3", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV3, -}; - -static struct clk pll1_sysclk4 = { - .name = "pll1_sysclk4", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV4, -}; - -static struct clk pll1_sysclk5 = { - .name = "pll1_sysclk5", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV5, -}; - -static struct clk pll1_sysclk6 = { - .name = "pll1_sysclk6", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV6, -}; - -static struct clk pll1_sysclk8 = { - .name = "pll1_sysclk8", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV8, -}; - -static struct clk pll1_sysclk9 = { - .name = "pll1_sysclk9", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV9, -}; - -static struct clk pll1_sysclkbp = { - .name = "pll1_sysclkbp", - .parent = _clk, - .flags = CLK_PLL | PRE_PLL, - .div_reg = BPDIV, -}; - -static struct clk pll1_aux_clk = { - .name = "pll1_aux_clk", - .parent = _clk, - .flags = CLK_PLL | PRE_PLL, -}; - -static struct clk pll2_clk = { - .name = "pll2_clk", - .parent = _clk, - .pll_data = _data, - .flags = CLK_PLL, -}; - -static struct clk pll2_sysclk1 = { - .name = "pll2_sysclk1", - .parent = _clk, - .flags = CLK_PLL, - .div_reg = PLLDIV1, -}; - -static struct clk dsp_clk = { - .name = "dsp", - .parent = _sysclk1, - .lpsc = DM646X_LPSC_C64X_CPU, - .usecount = 1, /* REVISIT how to disable? */ -}; - -static struct clk arm_clk = { - .name = "arm", - .parent = _sysclk2, - .lpsc = DM646X_LPSC_ARM, - .flags = ALWAYS_ENABLED, -}; - -static struct clk edma_cc_clk = { - .name = "edma_cc", - .parent = _sysclk2, - .lpsc = DM646X_LPSC_TPCC, - .flags = ALWAYS_ENABLED, -}; - -static struct clk edma_tc0_clk = { - .name = "edma_tc0", - .parent = _sysclk2, - .lpsc = DM646X_LPSC_TPTC0, - .flags = ALWAYS_ENABLED, -}; - -static struct clk edma_tc1_clk = { - .name = "edma_tc1", - .parent = _sysclk2, - .lpsc = DM646X_LPSC_TPTC1, - .flags = ALWAYS_ENABLED, -}; - -static struct clk edma_tc2_clk = { - .name = "edma_tc2", - .parent = _sysclk2, - .lpsc = DM646X_LPSC_TPTC2, - .flags = ALWAYS_ENABLED, -}; - -static struct clk edma_tc3_clk = { - .name = "edma_tc3", - .parent = _sysclk2, - .lpsc = DM646X_LPSC_TPTC3, - .flags = ALWAYS_ENABLED, -}; - -static struct clk uart0_clk = { - .name = "uart0", - .parent = _clkin, - .lpsc = DM646X_LPSC_UART0, -}; - -static struct clk uart1_clk = { - .name = "uart1", - .parent = _clkin, - .lpsc = DM646X_LPSC_UART1, -}; - -static struct clk uart2_clk = { - .name = "uart2", - .parent = _clkin, - .lpsc = DM646X_LPSC_UART2, -}; - -static struct clk i2c_clk = { - .name = "I2CCLK", - .parent = _sysclk3, -
[PATCH v8 38/42] ARM: davinci: da8xx: Remove legacy USB and SATA clock init
This removes the unused legacy USB and SATA clock init code from arch/arm/mach-davinci/{devices,usb}-da8xx}.c. Signed-off-by: David LechnerReviewed-by: Sekhar Nori --- v8 changes: - none v7 changes: - rebased - add davinci prefix to commit message - mention SATA and USB in commit message v6 changes: - rebased arch/arm/mach-davinci/devices-da8xx.c | 29 arch/arm/mach-davinci/include/mach/da8xx.h | 3 - arch/arm/mach-davinci/usb-da8xx.c | 238 - 3 files changed, 270 deletions(-) diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c index 73de449..1fd3619 100644 --- a/arch/arm/mach-davinci/devices-da8xx.c +++ b/arch/arm/mach-davinci/devices-da8xx.c @@ -30,11 +30,6 @@ #include "cpuidle.h" #include "sram.h" -#ifndef CONFIG_COMMON_CLK -#include -#include "clock.h" -#endif - #define DA8XX_TPCC_BASE0x01c0 #define DA8XX_TPTC0_BASE 0x01c08000 #define DA8XX_TPTC1_BASE 0x01c08400 @@ -1045,29 +1040,6 @@ int __init da8xx_register_spi_bus(int instance, unsigned num_chipselect) } #ifdef CONFIG_ARCH_DAVINCI_DA850 -#ifndef CONFIG_COMMON_CLK -static struct clk sata_refclk = { - .name = "sata_refclk", - .set_rate = davinci_simple_set_rate, -}; - -static struct clk_lookup sata_refclk_lookup = - CLK("ahci_da850", "refclk", _refclk); - -int __init da850_register_sata_refclk(int rate) -{ - int ret; - - sata_refclk.rate = rate; - ret = clk_register(_refclk); - if (ret) - return ret; - - clkdev_add(_refclk_lookup); - - return 0; -} -#else int __init da850_register_sata_refclk(int rate) { struct clk *clk; @@ -1078,7 +1050,6 @@ int __init da850_register_sata_refclk(int rate) return clk_register_clkdev(clk, "refclk", "ahci_da850"); } -#endif static struct resource da850_sata_resources[] = { { diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h b/arch/arm/mach-davinci/include/mach/da8xx.h index 5d7b1de..ab4a57f 100644 --- a/arch/arm/mach-davinci/include/mach/da8xx.h +++ b/arch/arm/mach-davinci/include/mach/da8xx.h @@ -103,9 +103,6 @@ int da8xx_register_watchdog(void); int da8xx_register_usb_phy(void); int da8xx_register_usb20(unsigned mA, unsigned potpgt); int da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata); -int da8xx_register_usb_refclkin(int rate); -int da8xx_register_usb20_phy_clk(bool use_usb_refclkin); -int da8xx_register_usb11_phy_clk(bool use_usb_refclkin); int da8xx_register_usb_phy_clocks(void); int da850_register_sata_refclk(int rate); int da8xx_register_emac(void); diff --git a/arch/arm/mach-davinci/usb-da8xx.c b/arch/arm/mach-davinci/usb-da8xx.c index d0ba725..b17253f 100644 --- a/arch/arm/mach-davinci/usb-da8xx.c +++ b/arch/arm/mach-davinci/usb-da8xx.c @@ -20,11 +20,6 @@ #include #include -#ifndef CONFIG_COMMON_CLK -#include -#include "clock.h" -#endif - #define DA8XX_USB0_BASE0x01e0 #define DA8XX_USB1_BASE0x01e25000 @@ -89,11 +84,6 @@ static struct platform_device da8xx_usb20_dev = { .name = "musb-da8xx", .id = -1, .dev = { - /* -* Setting init_name so that clock lookup will work in -* usb20_phy_clk_enable() even if this device is not registered. -*/ - .init_name = "musb-da8xx", .platform_data = _data, .dma_mask = _dmamask, .coherent_dma_mask = DMA_BIT_MASK(32), @@ -142,234 +132,6 @@ int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata) return platform_device_register(_usb11_device); } -#ifndef CONFIG_COMMON_CLK -static struct clk usb_refclkin = { - .name = "usb_refclkin", - .set_rate = davinci_simple_set_rate, -}; - -static struct clk_lookup usb_refclkin_lookup = - CLK(NULL, "usb_refclkin", _refclkin); - -/** - * da8xx_register_usb_refclkin - register USB_REFCLKIN clock - * - * @rate: The clock rate in Hz - * - * This clock is only needed if the board provides an external USB_REFCLKIN - * signal, in which case it will be used as the parent of usb20_phy_clk and/or - * usb11_phy_clk. - */ -int __init da8xx_register_usb_refclkin(int rate) -{ - int ret; - - usb_refclkin.rate = rate; - ret = clk_register(_refclkin); - if (ret) - return ret; - - clkdev_add(_refclkin_lookup); - - return 0; -} - -static void usb20_phy_clk_enable(struct clk *clk) -{ - u32 val; - u32 timeout = 50; /* 500 msec */ - - val = readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); - - /* The USB 2.O PLL requires that the USB 2.O PSC is enabled as well. */ - davinci_clk_enable(usb20_clk); - - /* -* Turn on the
[PATCH v8 38/42] ARM: davinci: da8xx: Remove legacy USB and SATA clock init
This removes the unused legacy USB and SATA clock init code from arch/arm/mach-davinci/{devices,usb}-da8xx}.c. Signed-off-by: David Lechner Reviewed-by: Sekhar Nori --- v8 changes: - none v7 changes: - rebased - add davinci prefix to commit message - mention SATA and USB in commit message v6 changes: - rebased arch/arm/mach-davinci/devices-da8xx.c | 29 arch/arm/mach-davinci/include/mach/da8xx.h | 3 - arch/arm/mach-davinci/usb-da8xx.c | 238 - 3 files changed, 270 deletions(-) diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c index 73de449..1fd3619 100644 --- a/arch/arm/mach-davinci/devices-da8xx.c +++ b/arch/arm/mach-davinci/devices-da8xx.c @@ -30,11 +30,6 @@ #include "cpuidle.h" #include "sram.h" -#ifndef CONFIG_COMMON_CLK -#include -#include "clock.h" -#endif - #define DA8XX_TPCC_BASE0x01c0 #define DA8XX_TPTC0_BASE 0x01c08000 #define DA8XX_TPTC1_BASE 0x01c08400 @@ -1045,29 +1040,6 @@ int __init da8xx_register_spi_bus(int instance, unsigned num_chipselect) } #ifdef CONFIG_ARCH_DAVINCI_DA850 -#ifndef CONFIG_COMMON_CLK -static struct clk sata_refclk = { - .name = "sata_refclk", - .set_rate = davinci_simple_set_rate, -}; - -static struct clk_lookup sata_refclk_lookup = - CLK("ahci_da850", "refclk", _refclk); - -int __init da850_register_sata_refclk(int rate) -{ - int ret; - - sata_refclk.rate = rate; - ret = clk_register(_refclk); - if (ret) - return ret; - - clkdev_add(_refclk_lookup); - - return 0; -} -#else int __init da850_register_sata_refclk(int rate) { struct clk *clk; @@ -1078,7 +1050,6 @@ int __init da850_register_sata_refclk(int rate) return clk_register_clkdev(clk, "refclk", "ahci_da850"); } -#endif static struct resource da850_sata_resources[] = { { diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h b/arch/arm/mach-davinci/include/mach/da8xx.h index 5d7b1de..ab4a57f 100644 --- a/arch/arm/mach-davinci/include/mach/da8xx.h +++ b/arch/arm/mach-davinci/include/mach/da8xx.h @@ -103,9 +103,6 @@ int da8xx_register_watchdog(void); int da8xx_register_usb_phy(void); int da8xx_register_usb20(unsigned mA, unsigned potpgt); int da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata); -int da8xx_register_usb_refclkin(int rate); -int da8xx_register_usb20_phy_clk(bool use_usb_refclkin); -int da8xx_register_usb11_phy_clk(bool use_usb_refclkin); int da8xx_register_usb_phy_clocks(void); int da850_register_sata_refclk(int rate); int da8xx_register_emac(void); diff --git a/arch/arm/mach-davinci/usb-da8xx.c b/arch/arm/mach-davinci/usb-da8xx.c index d0ba725..b17253f 100644 --- a/arch/arm/mach-davinci/usb-da8xx.c +++ b/arch/arm/mach-davinci/usb-da8xx.c @@ -20,11 +20,6 @@ #include #include -#ifndef CONFIG_COMMON_CLK -#include -#include "clock.h" -#endif - #define DA8XX_USB0_BASE0x01e0 #define DA8XX_USB1_BASE0x01e25000 @@ -89,11 +84,6 @@ static struct platform_device da8xx_usb20_dev = { .name = "musb-da8xx", .id = -1, .dev = { - /* -* Setting init_name so that clock lookup will work in -* usb20_phy_clk_enable() even if this device is not registered. -*/ - .init_name = "musb-da8xx", .platform_data = _data, .dma_mask = _dmamask, .coherent_dma_mask = DMA_BIT_MASK(32), @@ -142,234 +132,6 @@ int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata) return platform_device_register(_usb11_device); } -#ifndef CONFIG_COMMON_CLK -static struct clk usb_refclkin = { - .name = "usb_refclkin", - .set_rate = davinci_simple_set_rate, -}; - -static struct clk_lookup usb_refclkin_lookup = - CLK(NULL, "usb_refclkin", _refclkin); - -/** - * da8xx_register_usb_refclkin - register USB_REFCLKIN clock - * - * @rate: The clock rate in Hz - * - * This clock is only needed if the board provides an external USB_REFCLKIN - * signal, in which case it will be used as the parent of usb20_phy_clk and/or - * usb11_phy_clk. - */ -int __init da8xx_register_usb_refclkin(int rate) -{ - int ret; - - usb_refclkin.rate = rate; - ret = clk_register(_refclkin); - if (ret) - return ret; - - clkdev_add(_refclkin_lookup); - - return 0; -} - -static void usb20_phy_clk_enable(struct clk *clk) -{ - u32 val; - u32 timeout = 50; /* 500 msec */ - - val = readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); - - /* The USB 2.O PLL requires that the USB 2.O PSC is enabled as well. */ - davinci_clk_enable(usb20_clk); - - /* -* Turn on the USB 2.0 PHY, but just the PLL, and
[PATCH v8 42/42] ARM: dts: da850: Add clocks
This adds clock provider nodes for da850 and wires them up to all of the devices. Signed-off-by: David Lechner--- v8 changes: - fix typo in clock-names property of psc0 - added power-domains properties to nodes that define that property in their device tree bindings v7 changes: - move ref_clk frequency to board-specific DT files - enable sata_refclk in da850-lcdk.dts - drop async2 fixed factor clock - add power-domains for devices that use them - fix USB PHY clock-names property - move assigned-clocks to PSC device node - drop clocks property from devices that don't use it (e.g. EDMA) - add clock to RTC node - add clock-ranges to usb0 and aemif nodes - add clock-names property to aemif node - fix typo in psc1 clock-names v6 changes: - updated for device tree bindings changes earlier in this series - use single async2 clock instead of duplicate fixed factor clocks - add clock-names property to mdio node arch/arm/boot/dts/da850-enbw-cmc.dts | 4 + arch/arm/boot/dts/da850-evm.dts | 4 + arch/arm/boot/dts/da850-lcdk.dts | 9 ++ arch/arm/boot/dts/da850-lego-ev3.dts | 4 + arch/arm/boot/dts/da850.dtsi | 167 +++ 5 files changed, 188 insertions(+) diff --git a/arch/arm/boot/dts/da850-enbw-cmc.dts b/arch/arm/boot/dts/da850-enbw-cmc.dts index 14dff3e..0102ffc 100644 --- a/arch/arm/boot/dts/da850-enbw-cmc.dts +++ b/arch/arm/boot/dts/da850-enbw-cmc.dts @@ -35,6 +35,10 @@ }; }; +_clk { + clock-frequency = <2400>; +}; + { ti,edma-reserved-slot-ranges = <32 50>; }; diff --git a/arch/arm/boot/dts/da850-evm.dts b/arch/arm/boot/dts/da850-evm.dts index c82368c..38a53dd 100644 --- a/arch/arm/boot/dts/da850-evm.dts +++ b/arch/arm/boot/dts/da850-evm.dts @@ -200,6 +200,10 @@ }; }; +_clk { + clock-frequency = <2400>; +}; + /include/ "tps6507x.dtsi" { diff --git a/arch/arm/boot/dts/da850-lcdk.dts b/arch/arm/boot/dts/da850-lcdk.dts index a1f4d6d..90b917c 100644 --- a/arch/arm/boot/dts/da850-lcdk.dts +++ b/arch/arm/boot/dts/da850-lcdk.dts @@ -123,6 +123,10 @@ }; }; +_clk { + clock-frequency = <2400>; +}; + _core { status = "okay"; @@ -175,6 +179,11 @@ status = "okay"; }; +_refclk { + status = "okay"; + clock-frequency = <1>; +}; + { status = "okay"; }; diff --git a/arch/arm/boot/dts/da850-lego-ev3.dts b/arch/arm/boot/dts/da850-lego-ev3.dts index 1ffd877..4425cb4 100644 --- a/arch/arm/boot/dts/da850-lego-ev3.dts +++ b/arch/arm/boot/dts/da850-lego-ev3.dts @@ -203,6 +203,10 @@ }; }; +_clk { + clock-frequency = <2400>; +}; + _core { status = "okay"; diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi index c66cf78..e8117c7 100644 --- a/arch/arm/boot/dts/da850.dtsi +++ b/arch/arm/boot/dts/da850.dtsi @@ -21,6 +21,26 @@ #interrupt-cells = <1>; ti,intc-size = <101>; reg = <0xfffee000 0x2000>; + clocks = < 6>; + }; + }; + clocks: clocks { + ref_clk: ref_clk { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-output-names = "ref_clk"; + }; + sata_refclk: sata_refclk { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-output-names = "sata_refclk"; + status = "disabled"; + }; + usb_refclkin: usb_refclkin { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-output-names = "usb_refclkin"; + status = "disabled"; }; }; dsp: dsp@1180 { @@ -33,6 +53,7 @@ reg-names = "l2sram", "l1pram", "l1dram", "host1cfg", "chipsig"; interrupt-parent = <>; interrupts = <28>; + clocks = < 15>; status = "disabled"; }; soc@1c0 { @@ -43,6 +64,37 @@ ranges = <0x0 0x01c0 0x40>; interrupt-parent = <>; + psc0: clock-controller@1 { + compatible = "ti,da850-psc0"; + reg = <0x1 0x1000>; + #clock-cells = <1>; + #power-domain-cells = <1>; + clocks = <_sysclk 1>, <_sysclk 2>, +<_sysclk 4>, <_sysclk 6>, +<_clk>; + clock-names = "pll0_sysclk1", "pll0_sysclk2", + "pll0_sysclk4", "pll0_sysclk6", + "async1"; + }; + pll0: clock-controller@11000 { +
[PATCH v8 42/42] ARM: dts: da850: Add clocks
This adds clock provider nodes for da850 and wires them up to all of the devices. Signed-off-by: David Lechner --- v8 changes: - fix typo in clock-names property of psc0 - added power-domains properties to nodes that define that property in their device tree bindings v7 changes: - move ref_clk frequency to board-specific DT files - enable sata_refclk in da850-lcdk.dts - drop async2 fixed factor clock - add power-domains for devices that use them - fix USB PHY clock-names property - move assigned-clocks to PSC device node - drop clocks property from devices that don't use it (e.g. EDMA) - add clock to RTC node - add clock-ranges to usb0 and aemif nodes - add clock-names property to aemif node - fix typo in psc1 clock-names v6 changes: - updated for device tree bindings changes earlier in this series - use single async2 clock instead of duplicate fixed factor clocks - add clock-names property to mdio node arch/arm/boot/dts/da850-enbw-cmc.dts | 4 + arch/arm/boot/dts/da850-evm.dts | 4 + arch/arm/boot/dts/da850-lcdk.dts | 9 ++ arch/arm/boot/dts/da850-lego-ev3.dts | 4 + arch/arm/boot/dts/da850.dtsi | 167 +++ 5 files changed, 188 insertions(+) diff --git a/arch/arm/boot/dts/da850-enbw-cmc.dts b/arch/arm/boot/dts/da850-enbw-cmc.dts index 14dff3e..0102ffc 100644 --- a/arch/arm/boot/dts/da850-enbw-cmc.dts +++ b/arch/arm/boot/dts/da850-enbw-cmc.dts @@ -35,6 +35,10 @@ }; }; +_clk { + clock-frequency = <2400>; +}; + { ti,edma-reserved-slot-ranges = <32 50>; }; diff --git a/arch/arm/boot/dts/da850-evm.dts b/arch/arm/boot/dts/da850-evm.dts index c82368c..38a53dd 100644 --- a/arch/arm/boot/dts/da850-evm.dts +++ b/arch/arm/boot/dts/da850-evm.dts @@ -200,6 +200,10 @@ }; }; +_clk { + clock-frequency = <2400>; +}; + /include/ "tps6507x.dtsi" { diff --git a/arch/arm/boot/dts/da850-lcdk.dts b/arch/arm/boot/dts/da850-lcdk.dts index a1f4d6d..90b917c 100644 --- a/arch/arm/boot/dts/da850-lcdk.dts +++ b/arch/arm/boot/dts/da850-lcdk.dts @@ -123,6 +123,10 @@ }; }; +_clk { + clock-frequency = <2400>; +}; + _core { status = "okay"; @@ -175,6 +179,11 @@ status = "okay"; }; +_refclk { + status = "okay"; + clock-frequency = <1>; +}; + { status = "okay"; }; diff --git a/arch/arm/boot/dts/da850-lego-ev3.dts b/arch/arm/boot/dts/da850-lego-ev3.dts index 1ffd877..4425cb4 100644 --- a/arch/arm/boot/dts/da850-lego-ev3.dts +++ b/arch/arm/boot/dts/da850-lego-ev3.dts @@ -203,6 +203,10 @@ }; }; +_clk { + clock-frequency = <2400>; +}; + _core { status = "okay"; diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi index c66cf78..e8117c7 100644 --- a/arch/arm/boot/dts/da850.dtsi +++ b/arch/arm/boot/dts/da850.dtsi @@ -21,6 +21,26 @@ #interrupt-cells = <1>; ti,intc-size = <101>; reg = <0xfffee000 0x2000>; + clocks = < 6>; + }; + }; + clocks: clocks { + ref_clk: ref_clk { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-output-names = "ref_clk"; + }; + sata_refclk: sata_refclk { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-output-names = "sata_refclk"; + status = "disabled"; + }; + usb_refclkin: usb_refclkin { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-output-names = "usb_refclkin"; + status = "disabled"; }; }; dsp: dsp@1180 { @@ -33,6 +53,7 @@ reg-names = "l2sram", "l1pram", "l1dram", "host1cfg", "chipsig"; interrupt-parent = <>; interrupts = <28>; + clocks = < 15>; status = "disabled"; }; soc@1c0 { @@ -43,6 +64,37 @@ ranges = <0x0 0x01c0 0x40>; interrupt-parent = <>; + psc0: clock-controller@1 { + compatible = "ti,da850-psc0"; + reg = <0x1 0x1000>; + #clock-cells = <1>; + #power-domain-cells = <1>; + clocks = <_sysclk 1>, <_sysclk 2>, +<_sysclk 4>, <_sysclk 6>, +<_clk>; + clock-names = "pll0_sysclk1", "pll0_sysclk2", + "pll0_sysclk4", "pll0_sysclk6", + "async1"; + }; + pll0: clock-controller@11000 { + compatible =