summaryrefslogtreecommitdiff
path: root/drivers/net/ipa/ipa_main.c
AgeCommit message (Collapse)Author
2020-11-20net: ipa: define clock and interconnect dataAlex Elder
Define a new type of configuration data, used to initialize the IPA core clock and interconnects. This is the first of three patches, and defines the data types and interface but doesn't yet use them. Switch the return value if there is no matching configuration data to ENODEV instead of ENOTSUPP (to avoid using the nonstandard errno). Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2020-11-18net: ipa: use _FMASK consistentlyAlex Elder
Several IPA register field masks are defined without the "_FMASK" suffix naming convention. Rename these, so all field masks are consistently named. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2020-11-18net: ipa: make filter/routing hash enable register variableAlex Elder
For IPA v3.5.1, the IPA filter/routing hash enable register actually does exist, but it is at offset 0x8c into the IPA register space. For newer versions of IPA it is at offset 0x148. Define a new inline function ipa_reg_filt_rout_hash_en_offset() to return the appropriate value for a given version of IPA hardware. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2020-11-11net: ipa: get rid of a useless line of codeAlex Elder
Delete a spurious line of code in ipa_hardware_config(). It reads a register value then ignores the value, so is completely unnecessary. Add a missing word in a comment. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2020-11-11net: ipa: don't break build on large transaction sizeAlex Elder
The following call in ipa_validate_build() is erroneous: BUILD_BUG_ON(sizeof(struct gsi_trans) > 128); The fact is, it is not a bug for the size of a GSI transaction to be bigger than 128 bytes. The correct operation of the driver is not dependent on the size of this structure. The only consequence of the transaction being large is that the amount of memory required is larger. The problem this was trying to flag is that a *slight* increase in the size of this structure will have a disproportionate effect on the amount of memory used. E.g. if the structure grew to 132 bytes the memory requirement for the transaction arrays would be about double. With various debugging build flags enabled, the size grows to 160 bytes. But there's no reason to treat that as a build-time bug. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2020-11-04net: ipa: eliminate legacy argumentsAlex Elder
We enable a channel doorbell engine only for IPA v3.5.1, and that is now handled directly by gsi_channel_program(). When initially setting up a channel, we want that doorbell engine enabled, and we can request that independent of the IPA version. Doing that makes the "legacy" argument to gsi_channel_setup_one() unnecessary. And with that gone we can get rid of the "legacy" argument to gsi_channel_setup(), and gsi_setup() as well. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2020-11-04net: ipa: expose IPA version to the GSI layerAlex Elder
Although GSI is integral to IPA, it is a separate hardware component and the IPA code supporting it has been structured to avoid explicit dependence on IPA details. An example of this is that gsi_init() is passed a number of Boolean flags to indicate special behaviors, whose values are dependent on the IPA hardware version. Looking ahead, newer hardware versions would require even more such special behaviors. For any given version of IPA hardware (like 3.5.1 or 4.2), the GSI hardware version is fixed (in this case, 1.3 and 2.2, respectively). So the IPA version *implies* the GSI version, and the IPA version can be used as effectively the equivalent of the GSI hardware version. Rather than proliferating new special behavior flags, just provide the IPA version to the GSI layer when it is initialized. The GSI code can then use that directly to determine whether special behaviors are required. The IPA version enumerated type is already isolated to its own header file, so the exposure of this IPA detail is very limited. For now, just change gsi_init() to pass the version rather than the Boolean flags, and set the flag values internal to that function. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2020-10-30net: ipa: avoid going past end of resource group arrayAlex Elder
The minimum and maximum limits for resources assigned to a given resource group are programmed in pairs, with the limits for two groups set in a single register. If the number of supported resource groups is odd, only half of the register that defines these limits is valid for the last group; that group has no second group in the pair. Currently we ignore this constraint, and it turns out to be harmless, but it is not guaranteed to be. This patch addresses that, and adds support for programming the 5th resource group's limits. Rework how the resource group limit registers are programmed by having a single function program all group pairs rather than having one function program each pair. Add the programming of the 4-5 resource group pair limits to this function. If a resource group is not supported, pass a null pointer to ipa_resource_config_common() for that group and have that function write zeroes in that case. Tested-by: Sujit Kautkar <sujitka@chromium.org> Signed-off-by: Alex Elder <elder@linaro.org> Acked-by: Willem de Bruijn <willemb@google.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2020-10-30net: ipa: distinguish between resource group typesAlex Elder
The number of resource groups supported by the hardware can be different for source and destination resources. Determine the number supported for each using separate functions. Make the functions inline end move their definitions into "ipa_reg.h", because they determine whether certain register definitions are valid. Pass just the IPA hardware version as argument. IPA_RESOURCE_GROUP_COUNT represents the maximum number of resource groups the driver supports for any hardware version. Change that symbol to be two separate constants, one for source and the other for destination resource groups. Rename them to end with "_MAX" rather than "_COUNT", to reflect their true purpose. Tested-by: Sujit Kautkar <sujitka@chromium.org> Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2020-09-28net: ipa: rename a phandle variableAlex Elder
When "W=2" is supplied to the build command, we get a warning about shadowing a global declaration (of a typedef) for a variable defined in ipa_probe(). Rename the variable to get rid of the warning. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2020-09-18net: ipa: repurpose CLOCK_HELD flagAlex Elder
The previous patch causes a system resume to be triggered when a packet is available for receipt on a suspended RX endpoint. The CLOCK_HELD flag was previously used to indicate that an extra clock reference was held, preventing suspend. But we no longer need such a flag: - We take an initial reference in ipa_config(). - That reference is held until ipa_suspend() releases it. - A subsequent system resume leads to a reference getting re-acquired in ipa_resume(). - This can repeat until ultimately the module is removed, where ipa_remove() releases the reference. We no longer need a special flag to determine whether this extra reference is held--it is, provided probe has completed successfully and the driver is not suspended (or removed). On the other hand, once suspended, it's possible for more than one endpoint to trip the IPA SUSPEND interrupt, and we only want to trigger the system resume once. So repurpose the Boolean CLOCK_HELD flag to record whether the IPA SUSPEND handler should initiate a system resume. The flag will be be cleared each time ipa_suspend() is called, *before* any endpoints are suspended. And it will be set inside the IPA SUSPEND interrupt handler exactly once per suspend. Rename the flag IPA_FLAG_RESUMED to reflect its new purpose. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2020-09-18net: ipa: use device_init_wakeup()Alex Elder
The call to wakeup_source_register() in ipa_probe() does not do what it was intended to do. Call device_init_wakeup() in ipa_setup() instead, to set the IPA device as wakeup-capable and to initially enable wakeup capability. When we receive a SUSPEND interrupt, call pm_wakeup_dev_event() with a zero processing time, to simply call for a resume without any other processing. The ipa_resume() call will take care of waking things up again, and will handle receiving the packet. Note that this gets rid of a clock reference counting bug that occurred when handling an IPA SUSPEND interrupt. Specifically, ipa_suspend_handler() took an IPA clock reference *in addition* to the one taken by ipa_resume(). There is no need to back-port this fix however, because it only affects code that was not previously working (this patch is part of fixing that). Signed-off-by: Alex Elder <elder@linaro.org> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2020-09-18net: ipa: manage endpoints separate from clockAlex Elder
Currently, when (before) the last IPA clock reference is dropped, all endpoints are suspended. And whenever the first IPA clock reference is taken, all endpoints are resumed (or started). In most cases there's no need to start endpoints when the clock starts. So move the calls to ipa_endpoint_suspend() and ipa_endpoint_resume() out of ipa_clock_put() and ipa_clock_get(), respectiely. Instead, only suspend endpoints when handling a system suspend, and only resume endpoints when handling a system resume. Signed-off-by: Alex Elder <elder@linaro.org> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2020-09-18net: ipa: replace ipa->suspend_ref with a flag bitAlex Elder
We take a clock reference in ipa_config() in order to prevent the the IPA clock from being shutdown until a power management suspend request arrives. An atomic field in the IPA structure records whether that extra reference had been taken. Rather than using an atomic to represent a Boolean value, define a new flags bitmap, and define a "clock held" flag to represent whether the extra clock reference has been taken. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-13net: ipa: fix kerneldoc commentsAlex Elder
This commit affects comments (and in one case, whitespace) only. Throughout the IPA code, return statements are documented using "@Return:", whereas they should use "Return:" instead. Fix these mistakes. In function definitions, some parameters are missing their comment to describe them. And in structure definitions, some fields are missing their comment to describe them. Add these missing descriptions. Some arguments changed name and type along the way, but their descriptions were not updated (an endpoint pointer is now used in many places that previously used an endpoint ID). Fix these incorrect parameter descriptions. In the description for the ipa_clock structure, one field had a semicolon instead of a colon in its description. Fix this. Add a missing function description for ipa_gsi_endpoint_data_empty(). All of these issues were identified when building with "W=1". Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-01net: ipa: rework ipa_aggr_granularity_val()Alex Elder
The timer used for aggregation makes use of an internal 32 KHz clock. The granularity of the timer is programmed by a field whose value is computed by ipa_aggr_granularity_val(). Redefine the way that value is computed by using a new TIMER_FREQUENCY constant representing the underlying clock frequency. Add two BUILD_BUG_ON() calls to ensure the value used is valid. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2020-05-16net: ipa: don't use noirq suspend/resume callbacksAlex Elder
Use the suspend and resume callbacks rather than suspend_noirq and resume_noirq. With IPA v4.2, we use the CHANNEL_STOP command to implement a suspend, and without interrupts enabled, that command won't complete. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2020-05-06net: ipa: rename db_enable flagAlex Elder
In several places, a Boolean flag is used in the GSI code to indicate whether the "doorbell engine" should be enabled or not when a channel is configured. This is basically done to abstract this property from the IPA version; the GSI code doesn't otherwise "know" what the IPA hardware version is. The doorbell engine is enabled only for IPA v3.5.1, not for IPA v4.0 and later. The next patch makes another change that affects behavior during channel reset (which also involves programming the channel). It also distinguishes IPA v3.5.1 hardware from newer hardware. Rather than creating another flag whose value matches the "db_enable" value, just rename "db_enable" to be "legacy" so it can be used to signal more than just the special doorbell handling. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2020-05-04net: ipa: redefine struct ipa_mem_dataAlex Elder
The ipa_mem_data structure type was never actually used. Instead, the IPA memory regions were defined using the ipa_mem structure. Redefine struct ipa_mem_data so it encapsulates the array of IPA-local memory region descriptors along with the count of entries in that array. Pass just an ipa_mem structure pointer to ipa_mem_init(). Rename the ipa_mem_data[] array ipa_mem_local_data[] to emphasize that the memory regions it defines are IPA-local memory. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-19net: ipa: fix platform_no_drv_owner.cocci warningsYueHaibing
Remove .owner field if calls are used which set it automatically Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci Signed-off-by: YueHaibing <yuehaibing@huawei.com> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-08soc: qcom: ipa: main codeAlex Elder
This patch includes three source files that represent some basic "main program" code for the IPA driver. They are: - "ipa.h" defines the top-level IPA structure which represents an IPA device throughout the code. - "ipa_main.c" contains the platform driver probe function, along with some general code used during initialization. - "ipa_reg.h" defines the offsets of the 32-bit registers used for the IPA device, along with masks that define the position and width of fields within these registers. - "version.h" defines some symbolic IPA version numbers. Each file includes some documentation that provides a little more overview of how the code is organized and used. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>